3
$\begingroup$

I find, in version 11 on Windows 7,64 bit, in the following example that, Rationalize and Plot together give unnecessary warnings (ps: this example can be find in documentation center: ref/Rationalize)

Plot[Log[Abs[Pi - Rationalize[Pi, Exp[-n]]]], {n, 0, 20}]

Rationalize::tolnn: Tolerance specification E^-n must be a non-negative number.

Rationalize::tolnn: Tolerance specification 2.71828^(-1. n) must be a non-negative number.

Rationalize::tolnn: Tolerance specification 2.71828^(-1. n) must be a non-negative number.

General::stop: Further output of Rationalize::tolnn will be suppressed during this calculation.

For Chop and other functions related to N, similar things occur.

$\endgroup$
4
$\begingroup$

This behaviour is not surprising, in fact it is quite expected. Exp[-n] is not a number. It is a symbolic expression. It only becomes a number if we substitute a number for n. Read more here:

Why would this be in the documentation then? Plot is such a commonly used function (also by complete beginners) that they made it try to guess your intention and automatically decide whether the evaluate the input symbolically or not.

I noticed that several cases where plotting functions didn't evaluate symbolically in v11.0.0 started evaluating in v11.0.1, e.g. the StreamPlot here. Maybe this is one of those cases.

Still, the answer is: you should control the evaluation manually as the software won't be able to guess what you meant with perfect accuracy.

f[n_?NumericQ] := Log[Abs[Pi - Rationalize[Pi, Exp[-n]]]]

Plot[f[n], {n, 0, 20}]
|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.