On Wed, Feb 27, 2013 at 1:41 PM, Chris Smith <[email protected]> wrote: >> It looks like Mod doesn't implement evalf at all, and it doesn't work >> automatically (that only happens if the function name is the same as >> the mpmath function name). It should be easy. Just evaluate the >> arguments, and then take the mod of them. > > In general this is not going to work: > > ``` >>>> Mod(1e-30,3) > 1.00000000000000e-30 >>>> Mod(1e-40,3) > 0.0 > ``` > > whereas > > ``` >>>> 1e-40 % 3 > 9.9999999999999993e-41 > ```
Isn't that just a roundoff error. If you use Float, you get 1e-40. Aaron Meurer > > Something like this might work when a > b (when a < b the answer is `a`): > > ``` >>>> a,b=pi**3,S(3) >>>> (a - round(a/b)*b).n() > 1.00627668029982 >>>> a.n() % b.n() > 1.00627668029982 > ``` > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sympy?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
