On 31.03.2012 15:43, [email protected] wrote:
>> And a complication:
>> In [17]: f(1,2)
>> Out[17]:
>>
>>  log(cos(2) + 1)
>>        log(-1 + cos(2))
>> - ─────────────── + 2.99489845376757 - 0.5⋅ⅈ⋅π + ──────────────── > 1
>>         2
>>               2
> 
> The problem here seems to be in the rounding:
> 
> In [32]: a = log(cos(y) - 1)/2 - log(cos(y) + 1)/2 + 2.99489845376757 - 
> 1j*pi/2
> 
> In [33]: a.subs(y, 2).evalf()
> Out[33]: 3.43792117788449 - .0e-21⋅ⅈ
> 

There is undocumented chop parameter for evalf

In [9]: a.subs(y, 2).evalf(chop=True)
Out[9]: 3.43792117788449

Which is like the chop function from mpmath library.

--
Alexey Gudchenko

> In [34]: a.subs(y,1.1).evalf()
> Out[34]: 2.50567973267913
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to