How evalf chop works?

104 views
Skip to first unread message

Paul Royik

unread,
May 5, 2015, 4:41:24 AM5/5/15
to sy...@googlegroups.com
expr = 2682469501914725726236807146020965585039500052171867725591732162347*exp(-60)/48648670709168952944186714683693506574127

N(expr) outputs 0.482830727370627
but
N(expr, chop=True) outputs 0

In some other expressions chop doesn't make 0.

So, how chop works?

Paul Royik

unread,
May 21, 2015, 9:53:34 AM5/21/15
to sy...@googlegroups.com
Nobody could tell how chop works?

Aaron Meurer

unread,
May 21, 2015, 11:45:41 AM5/21/15
to sy...@googlegroups.com
I'm guessing chop chops some intermediate expression that is smaller
than the cutoff in this case. It probably should be considered a bug.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/3ef42fe1-b3cb-45d3-80ef-6af88a181bb2%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

Paul Royik

unread,
May 21, 2015, 2:49:34 PM5/21/15
to sy...@googlegroups.com
OK.
Thank you.
Could you move it to issues?

Chris Smith

unread,
May 26, 2015, 10:29:09 AM5/26/15
to sy...@googlegroups.com
When chop=True it uses the current precision to replace small arguments with an exact zero. If you want to specify the threshold for chopping, pass in a value instead of a boolean. The exp(-60) is about 8x10^-27 so if you specify chop smaller than that you will not get 0 for the result:

>>> expr.n(chop=1e-27)
0.482830727370613
>>> expr.n(chop=1e-26)
0

Paul Royik

unread,
Jun 2, 2015, 12:50:58 PM6/2/15
to sy...@googlegroups.com
Thank you.
Reply all
Reply to author
Forward
0 new messages