[issue7770] sin/cos function in decimal-docs

2010-11-20 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- resolution: -> fixed status: open -> closed ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue7770] sin/cos function in decimal-docs

2010-11-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: Added a comment to the docstring. See r86631. -- ___ Python tracker ___ ___ Python-bugs-list mail

[issue7770] sin/cos function in decimal-docs

2010-01-29 Thread showell
showell added the comment: +1 on showing off remainder_near. I recently wrote a program where I reinvented the logic (on a unit circle too), not knowing it was already implemented in Decimal. -- nosy: +Steve Howell ___ Python tracker

[issue7770] sin/cos function in decimal-docs

2010-01-24 Thread Johannes Schönberger
Johannes Schönberger added the comment: sorry, forgot the str: def rsin(x): """Return the sine of x as measured in radians. >>> print sin(Decimal('0.5')) 0.4794255386042030002732879352 >>> print sin(0.5) 0.479425538604 >>> print sin(0.5+0j) (0.479425538604+0j)

[issue7770] sin/cos function in decimal-docs

2010-01-24 Thread Johannes Schönberger
Johannes Schönberger added the comment: This adds two further lines, so you can pass int's, float's or Decimal types to the function. def sin(x): """Return the sine of x as measured in radians. >>> print sin(Decimal('0.5')) 0.4794255386042030002732879352 >>> print sin(0.5)

[issue7770] sin/cos function in decimal-docs

2010-01-24 Thread Raymond Hettinger
Raymond Hettinger added the comment: I'll look at it when I get a chance. Want to continue to show how the same recipe can work for different input types. I may just document the function's range of inputs. -- assignee: georg.brandl -> rhettinger priority: normal -> low ___

[issue7770] sin/cos function in decimal-docs

2010-01-24 Thread Mark Dickinson
Mark Dickinson added the comment: 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

[issue7770] sin/cos function in decimal-docs

2010-01-24 Thread Johannes Schönberger
Johannes Schönberger added the comment: stupid, it is much better to just use the modulo operator. The same works with cos... def sin(x): """Return the sine of x as measured in radians. >>> print sin(Decimal('0.5')) 0.4794255386042030002732879352 >>> print sin(0.5) 0.47942

[issue7770] sin/cos function in decimal-docs

2010-01-24 Thread Mark Dickinson
Mark Dickinson added the comment: Hmm. Isn't sine periodic with period 2*pi, not pi? I'd also suggest making use of remainder_near. -- ___ Python tracker ___ __

[issue7770] sin/cos function in decimal-docs

2010-01-24 Thread Johannes Schönberger
Johannes Schönberger added the comment: This is the version I would suggest and which is quite accurate unless the numbers get extremely large. def sin(x): """Return the sine of x as measured in radians. >>> print sin(Decimal('0.5')) 0.4794255386042030002732879352 >>> print si

[issue7770] sin/cos function in decimal-docs

2010-01-24 Thread Mark Dickinson
Mark Dickinson added the comment: I think that recipe is meant more as a simple example of what's possible than as a bullet-proof library function. Can you suggest changes that would improve accuracy while also keeping the recipe clear and simple? The usual method for sin/cos is to do an ini

[issue7770] sin/cos function in decimal-docs

2010-01-24 Thread Ezio Melotti
Changes by Ezio Melotti : -- nosy: +mark.dickinson priority: -> normal stage: -> test needed ___ Python tracker ___ ___ Python-bugs-l

[issue7770] sin/cos function in decimal-docs

2010-01-24 Thread Johannes Schönberger
New submission from Johannes Schönberger : Unfortunately the sin/cos function in the decimal docs seems to return false results. In [33]: sin(decimal.Decimal('75')) Out[33]: Decimal('0.377879483645203210442266845614') In [34]: sin(decimal.Decimal('76')) Out[34]: Decimal('-2.0882846000972488932