Message98228
Johannes: note that the reduction needs to be by 2*pi, not pi. The remainder_near method is slightly better than the modulo operator here:
remainder_near reduces to the range [-pi, pi], while the modulo operator reduces to the range (-2*pi, 2*pi), so ends up passing larger arguments to the Taylor series. (And it's a nice excuse to show what remainder_near is good for!) Also, the reduction should happen *after* the temporary increase in context precision.
Here's a doc patch, that just adds a single line:
x = x.remainder_near(2*pi())
after getcontext().prec += 2, for both the sin and cos recipes. It also removes the float and complex examples in the docstrings, since remainder_near doesn't exist for those types.
Raymond, is this change okay with you? |
|
Date |
User |
Action |
Args |
2010-01-24 14:46:43 | mark.dickinson | set | recipients:
+ mark.dickinson, georg.brandl, rhettinger, ahojnnes |
2010-01-24 14:46:43 | mark.dickinson | set | messageid: <1264344403.51.0.570909965501.issue7770@psf.upfronthosting.co.za> |
2010-01-24 14:46:41 | mark.dickinson | link | issue7770 messages |
2010-01-24 14:46:41 | mark.dickinson | create | |
|