0
$\begingroup$

In one of my calculations, I get -1.11022*10^-16 as one of my eigenvalues for a matrix. It's essentially zero and I suppose I could use SetPrecision to make it zero but I wonder what's a good practice here? Should I maybe include something at the beginning of the code to specify precision for everything? Or do I just set arbitrary precision when I feel my expression is not simplified enough?

I'm pretty new to Mathematica.


As others have commented, after trying in different calculations, I think use \Chop after each calculation is the best and safest way.One can also explicitly specify the digits to keep.

$\endgroup$
  • 4
    $\begingroup$ You could apply Chop. $\endgroup$ – Chris K Jan 9 at 4:31
  • 3
    $\begingroup$ I do not believe that you really want to ess with precision here. You just want to push values close to 0. to 0.. This can be done by Threshold and by specifying a suitable tolerance as second argument. $\endgroup$ – Henrik Schumacher Jan 9 at 8:17
  • $\begingroup$ Thank you guys. Is there a way to Chop/Threshold the whole notebook? Or I just apply these functions after whatever output I get? $\endgroup$ – Histoscienology Jan 11 at 17:07
1
$\begingroup$

Mathematica has three different types of numbers.

Exact numbers, e.g.

5, Sqrt[2], 4/3, ...

Machine precision numbers

1.23, 5., .4566, ...

And numbers with a set precision

5.`16, 1.2345`5, ...

You can tell what kind of number something is by applying Precision to it.

If all your input number have an set precision, then the output of you eigenvalue computation should also have a finite precision attached to it. This will allow you to distinguish between an eigenvalue that is really small an one that is consistent with zero within the expected accuracy.

$\endgroup$
  • $\begingroup$ Thanks. So you mean I should set every input with a precision as " `some number?" And how can Sqrt[2] and 4/3 be exact?? $\endgroup$ – Histoscienology Jan 11 at 4:22

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.