0
$\begingroup$

I need to understand how Mathematica approximates symbolic numbers.

I have an awful symbolic number to compute.

When I do

N[variable]

Mathematica gives me

-2.54273*10^7

which is not at all the number I am expecting.

But when I do

N[variable,1]

Mathematica gives

2.

which is the correct first digit!

I understand that Mathematica computes with more precision in the second case than in the first. But I have asked for only 1 digit of precision, so I am puzzled why it works.

I read the documentation but it didn't answer my questions (I think I did'nt understood the documentation very well).

Could you help me to understand how Mathematica computes in the first case and in the second?

If you want to reproduce this, I suggest you to download my notebook (I am sorry, the variable is totally awful, but I don't have a simpler variable that will show this behavior. This variable is the result of a computation of a non analytic function).

I didn't copy the variable here because it is like 10 lines long so it would be too long for this post.

Link for the notebook => https://ufile.io/r5ply

$\endgroup$
  • 5
    $\begingroup$ Read the tutorial on Numerical Precision. $\endgroup$ – Carl Woll Jul 4 '17 at 18:26
  • $\begingroup$ @CarlWoll Oh well I didn't see it. Ok I'll read it and if there is still things I don't understand I will notice you ! Thanks ! $\endgroup$ – StarBucK Jul 4 '17 at 18:27
  • 2
    $\begingroup$ One thing that is not made clear in the tutorial is that N[expr, 1] will use extra precision, up to $MaxExtraPrecision to achieve the requested precision (1 digit) in numerically approximating expr. (Whereas N[expr] uses machine precision and ignores rounding error.) Look up $MaxExtraPrecision, too. $\endgroup$ – Michael E2 Jul 4 '17 at 20:15
  • $\begingroup$ @CarlWoll I think it is more clear now. But I would like to know if functions like Solve, Plot etc when they need to access numerical values, do they use by default $MaxExtraPrecision to find/plot results ? For solve for example if I have a variable with 60 digits in a linear system. Will the solve function "cut" my variable to 16 digits for example or it will use all the precision ? $\endgroup$ – StarBucK Jul 5 '17 at 13:45

Your Answer

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

Browse other questions tagged or ask your own question.