Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.9K Views
|
9 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Is this a correct way of ensuring a preselected precision in calculations?

Posted 2 years ago
POSTED BY: Leslaw Bieniasz
9 Replies

What do you mean by " careful numerical analysis of the inputs and results"? 1) Comparison of results obtained assuming different precisions? 2) Some kind of interval arithmetics? Is any sort of it available in MATHEMATICA? 3) Comparisons of the results with any independently available data? 4) Anything else? Lesław

POSTED BY: Leslaw Bieniasz

SetPrecision takes all numbers and mathematical constants it sees and assigns them their numerical equivalents at the requested precision. Then the expressions containing them are evaluated, and error is probagated (assuming one did not use MachinePrecision as the second argument). N by contrast attempts to evaluate the entire expression to the requested precision (same caveat). Here is an example.

ee = Sin[10^5];
prec = 4;
{InputForm@N[ee, prec], InputForm@SetPrecision[ee, prec]}

(* Out[829]= {InputForm[0.0357487979720165093`4.], InputForm[0``0.0]} *)

Notice that all precision was lost in the second case, where SetPrecision was used.

There are situations where the attained precision on application of N to a numeric expression might not be correct. The cause I am aware of is in evaluation of special functions, in cases where the error estimates might be off. I believe this is a rare situation though.

Using N in a symbolic computation is a different fish. For example, code in definite integration needs to account for presence of singular points that might only be approximately known. Code in functions such as Together (used by Integrate) might use Rationalize or take other steps just to avoid crashing; such code was not designed for handling approximate numbers (and indeed, the literature on this is far from complete).

With all this in mind, your approach seems reasonable, but I cannot offer any guarantee. Moreover I am fairly sure it would require careful numerical analysis of the inputs and results in order to provide such guarantee.

POSTED BY: Daniel Lichtblau
POSTED BY: Leslaw Bieniasz

... if I use floating point numbers with a a user-selected precision, the precision of the calculations will be adaptively maintained to ensure a selected level.

N[f[x], precision] adapts precision if f[x] has infinite precision, but f[N[x, precision]] does not. The error will propagate through f[N[x, precision]].

POSTED BY: Michael Rogers
POSTED BY: Daniel Lichtblau
Posted 2 years ago
POSTED BY: Eric Rimbey
POSTED BY: Gianluca Gorni
POSTED BY: Leslaw Bieniasz
Posted 2 years ago
POSTED BY: Eric Rimbey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard