Re: [Python-ideas] Trigonometry in degrees

2019-05-08 Thread Kyle Lahnakoski
Maybe a library of trig functions that include an Angle type? This is related to the timespan units discussion we just had def sin(angle): On 2018-06-08 01:44, Yuval Greenfield wrote: > On Thu, Jun 7, 2018 at 10:38 PM Stephen J. Turnbull > > wrote:

Re: [Python-ideas] Trigonometry in degrees

2018-06-12 Thread Wes Turner
Sym: SymPy, SymEngine, PySym, SymCXX, Diofant (re: \pi, symbolic computation and trigonometry instead of surprisingly useful piecewise optimizations) On Fri, Jun 8, 2018 at 10:09 PM Wes Turner wrote: > # Python, NumPy, SymPy, mpmath, sage trigonometric functions > https://en.wikipedia.org/wiki/

Re: [Python-ideas] Trigonometry in degrees

2018-06-10 Thread Terry Reedy
On 6/10/2018 7:53 PM, Neil Girdhar wrote: On Sun, Jun 10, 2018 at 5:41 PM Terry Reedy > wrote: On 6/10/2018 10:44 AM, Stephan Houben wrote: > I would suggest that compatibility with a major Python library such as > SciPy is more important than comp

Re: [Python-ideas] Trigonometry in degrees

2018-06-10 Thread Neil Girdhar
On Sun, Jun 10, 2018 at 5:41 PM Terry Reedy wrote: > On 6/10/2018 10:44 AM, Stephan Houben wrote: > > > I would suggest that compatibility with a major Python library such as > > SciPy is more important than compatibility > > with other programming languages. > > > > I would go even further and a

Re: [Python-ideas] Trigonometry in degrees

2018-06-10 Thread Terry Reedy
On 6/10/2018 10:44 AM, Stephan Houben wrote: I would suggest that compatibility with a major Python library such as SciPy is more important than compatibility with other programming languages. I would go even further and argue that scipy.special.sindg and its friends cosdg and tandg can serv

Re: [Python-ideas] Trigonometry in degrees

2018-06-10 Thread Stephan Houben
2018-06-09 8:18 GMT+02:00 Robert Vanden Eynde : > For the naming convention, scipy using sindg (therefore Nor sind nor > sindeg) will make the sind choice less obvious. However if Matlab and Julia > chooses sind that's a good path to go, Matlab is pretty popular, as other > pointed out, with Unive

Re: [Python-ideas] Trigonometry in degrees

2018-06-10 Thread Neil Girdhar
I think this suggestion should result in a library on PyPi, which can then be considered for the standard library if it sees a lot of use. Also, modern OpenGL does this just like Python does: all of the trigonometric functions take radians and a "radians" function is provided. Best, Neil On S

Re: [Python-ideas] Trigonometry in degrees

2018-06-09 Thread Robert Vanden Eynde
Indeed what we need for exact math for multiple of 90 (and 30) is ideas from the symbolic libraries (sympy, sage). Of course the symbolic lib can do more like : sage: k = var('k', domain='integer') sage: cos(1 + 2*k*pi) cos(1) sage: cos(k*pi) cos(pi*k) sage: cos(pi/3 + 2*k*pi) 1/2 But that woul

Re: [Python-ideas] Trigonometry in degrees

2018-06-09 Thread Michael Selik
On Sat, Jun 9, 2018 at 2:22 AM Adam Bartoš wrote: > The idea was that the functions could handle the PiMultiple instances in a > special way and fall back to float only when a special value is not detected. > It would be like the proposed dsin functionality, but with a magic class > instead of

Re: [Python-ideas] Trigonometry in degrees

2018-06-09 Thread Adam Bartoš
Steven D'Arpano wrote: > On Fri, Jun 08, 2018 at 11:11:09PM +0200, Adam Bartoš wrote: > >>* But if there are both sin and dsin, and you ask about the difference *>>* between them, the obvious answer would be that one takes radians and the *>>* other takes degrees. The point that the degrees versio

Re: [Python-ideas] Trigonometry in degrees

2018-06-08 Thread Wes Turner
On Fri, Jun 8, 2018 at 11:44 PM Robert Kern wrote: > On 6/8/18 01:45, Robert Vanden Eynde wrote: > > - Thanks for pointing out a language (Julia) that already had a name > convention. > > Interestingly they don't have a atan2d function. Choosing the same > convention as > > another language is a

Re: [Python-ideas] Trigonometry in degrees

2018-06-08 Thread Robert Kern
On 6/8/18 01:45, Robert Vanden Eynde wrote: - Thanks for pointing out a language (Julia) that already had a name convention. Interestingly they don't have a atan2d function. Choosing the same convention as another language is a big plus. For what it's worth, scipy calls them sindg, cosdg, tand

Re: [Python-ideas] Trigonometry in degrees

2018-06-08 Thread Wes Turner
# Python, NumPy, SymPy, mpmath, sage trigonometric functions https://en.wikipedia.org/wiki/Trigonometric_functions ## Python math module https://docs.python.org/3/library/math.html#trigonometric-functions - degrees(radians): Float degrees - radians(degrees): Float degrees ## NumPy https://docs.sc

Re: [Python-ideas] Trigonometry in degrees

2018-06-08 Thread Steven D'Aprano
On Fri, Jun 08, 2018 at 11:11:09PM +0200, Adam Bartoš wrote: > But if there are both sin and dsin, and you ask about the difference > between them, the obvious answer would be that one takes radians and the > other takes degrees. The point that the degrees version is additionally > exact on specia

Re: [Python-ideas] Trigonometry in degrees

2018-06-08 Thread Steven D'Aprano
On Fri, Jun 08, 2018 at 08:45:54AM +, Robert Vanden Eynde wrote: > from math import sin, tau > from fractions import Fraction > sin(Fraction(1,6) * tau) > sindeg(Fraction(1,6) * 360) > > These already work today by the way. You obviously have a different understanding of the words "already w

Re: [Python-ideas] Trigonometry in degrees

2018-06-08 Thread Robert Vanden Eynde
- Thanks for pointing out a language (Julia) that already had a name convention. Interestingly they don't have a atan2d function. Choosing the same convention as another language is a big plus. - Adding trig function using floats between 0 and 1 is nice, currently one needs to do sin(tau * t) w

Re: [Python-ideas] Trigonometry in degrees

2018-06-08 Thread Richard Damon
On 6/8/18 5:11 PM, Adam Bartoš wrote: > Steven D'Aprano wrote: > > On Fri, Jun 08, 2018 at 10:53:34AM +0200, Adam Bartoš wrote: > >> Wouldn't sin(45 * DEG) where DEG = 2 * math.pi / 360 be better that > >> sind(45)? This way we woudn't have to introduce new functions. (The > problem > >> with nonex

Re: [Python-ideas] Trigonometry in degrees

2018-06-08 Thread Adam Bartoš
Steven D'Aprano wrote: > On Fri, Jun 08, 2018 at 10:53:34AM +0200, Adam Bartoš wrote: >> Wouldn't sin(45 * DEG) where DEG = 2 * math.pi / 360 be better that >> sind(45)? This way we woudn't have to introduce new functions. (The problem >> with nonexact results for nice angles is a separate issue.)

Re: [Python-ideas] Trigonometry in degrees

2018-06-08 Thread Jacco van Dorp
2018-06-08 15:19 GMT+02:00 Hugh Fisher : >> Julia provides a full set of trigonometric functions in both radians and >> degrees: >> >> https://docs.julialang.org/en/release-0.4/manual/mathematical-operations/#trigonometric-and-hyperbolic-functions >> >> They use sind, cosd, tand etc for the varian

Re: [Python-ideas] Trigonometry in degrees

2018-06-08 Thread Kyle Lahnakoski
On 2018-06-08 01:44, Yuval Greenfield wrote: > On Thu, Jun 7, 2018 at 10:38 PM Stephen J. Turnbull > > wrote: > > > 6.123233995736766e-17 > >>> > > is good enough for government work, including at the local public high > school. > > > T

Re: [Python-ideas] Trigonometry in degrees

2018-06-08 Thread Hugh Fisher
> Date: Fri, 8 Jun 2018 15:45:31 +1000 > From: Steven D'Aprano > To: python-ideas@python.org > Subject: Re: [Python-ideas] Trigonometry in degrees > Message-ID: <20180608054530.gc12...@ando.pearwood.info> > Content-Type: text/plain; charset=us-ascii > > On Fr

Re: [Python-ideas] Trigonometry in degrees

2018-06-08 Thread Steven D'Aprano
On Fri, Jun 08, 2018 at 06:34:25PM +1200, Greg Ewing wrote: > I'm not sure what all the fuss is about: > > >>> from math import pi, sin > >>> sin(pi/2) > 1.0 Try cos(pi/2) or sin(pi/6). Or try: sin(pi/4) == sqrt(2)/2 tan(pi/4) == 1 tan(pi/3) == sqrt(3) And even tan(pi/2), which ought to be an

Re: [Python-ideas] Trigonometry in degrees

2018-06-08 Thread Steven D'Aprano
On Fri, Jun 08, 2018 at 10:53:34AM +0200, Adam Bartoš wrote: > Wouldn't sin(45 * DEG) where DEG = 2 * math.pi / 360 be better that > sind(45)? This way we woudn't have to introduce new functions. (The problem > with nonexact results for nice angles is a separate issue.) But that's not a separate i

Re: [Python-ideas] Trigonometry in degrees

2018-06-08 Thread Adam Bartoš
Wouldn't sin(45 * DEG) where DEG = 2 * math.pi / 360 be better that sind(45)? This way we woudn't have to introduce new functions. (The problem with nonexact results for nice angles is a separate issue.) Regards, Adam Bartoš ___ Python-ideas mailing list

Re: [Python-ideas] Trigonometry in degrees

2018-06-08 Thread Steven D'Aprano
On Fri, Jun 08, 2018 at 03:55:34PM +1000, Chris Angelico wrote: > On Fri, Jun 8, 2018 at 3:45 PM, Steven D'Aprano wrote: > > Although personally I prefer the look of d as a prefix: > > > > dsin, dcos, dtan > > > > That's more obviously pronounced "d(egrees) sin" etc rather than "sined" > > "tanned

Re: [Python-ideas] Trigonometry in degrees

2018-06-08 Thread Jacco van Dorp
Or when students get stuff e-17 out of a function, you teach them what floating point numbers are and what gotcha's they can expect. The simple version is "value is stored as a float, and a float gets rounding errors below e-16", or for the more inquisitive minds you give them nice places like http

Re: [Python-ideas] Trigonometry in degrees

2018-06-07 Thread Greg Ewing
Steven D'Aprano wrote: Even old-school scientific calcuators without the fancy CAS symbolic maths are capable of having cos(90) return zero in degree mode. FWIW, my Casio fx-100 (over 30 years old) produces exactly 1 for both sin(90°) and sin(pi/2) for its version of pi. -- Greg _

Re: [Python-ideas] Trigonometry in degrees

2018-06-07 Thread Greg Ewing
Chris Angelico wrote: The math module would need a hyperbolic sine function which accepts an argument in; Except that the argument to hyperbolic trig functions is not an angle in any normal sense of the word, so expressing it in degrees makes little sense. (However I do like the idea of a func

Re: [Python-ideas] Trigonometry in degrees

2018-06-07 Thread Greg Ewing
Stephen J. Turnbull wrote: Since Pi is irrational, Pi/4 is too, so it definitely cannot be represented. Making a correction to a number that "looks like" Pi/4 is against this philosophy. I'm not sure what all the fuss is about: >>> from math import pi, sin >>> sin(pi/2) 1.0 >>> sin(pi/2 + 2 *

Re: [Python-ideas] Trigonometry in degrees

2018-06-07 Thread Steven D'Aprano
On Fri, Jun 08, 2018 at 02:37:33PM +0900, Stephen J. Turnbull wrote: > My bias is that people who want to program this kind of thing just > need to learn about floating point numbers and be aware that they're > going to have to accept that > > >>> from math import cos, radians > >>> cos(radians(9

Re: [Python-ideas] Trigonometry in degrees

2018-06-07 Thread Steven D'Aprano
On Thu, Jun 07, 2018 at 10:39:06PM -0400, Richard Damon wrote: > First I feel the need to point out that radians are actually fairly > fundamental in trigonometry, so there is good reasons for the base > functions to be based on radians. The fact that the arc length of the > angle on the unit circ

Re: [Python-ideas] Trigonometry in degrees

2018-06-07 Thread Chris Angelico
On Fri, Jun 8, 2018 at 3:45 PM, Steven D'Aprano wrote: > Although personally I prefer the look of d as a prefix: > > dsin, dcos, dtan > > That's more obviously pronounced "d(egrees) sin" etc rather than "sined" > "tanned" etc. Having it as a suffix does have one advantage. The math module would n

Re: [Python-ideas] Trigonometry in degrees

2018-06-07 Thread Steven D'Aprano
On Fri, Jun 08, 2018 at 08:17:02AM +1000, Hugh Fisher wrote: > But I think that the use of > radians in programming language APIs is more prevalent, so the initial > advantage > of easy learning will be outweighed by the long term inconvenience of > adjusting to what everyone else is doing. But

Re: [Python-ideas] Trigonometry in degrees

2018-06-07 Thread Yuval Greenfield
On Thu, Jun 7, 2018 at 10:38 PM Stephen J. Turnbull < turnbull.stephen...@u.tsukuba.ac.jp> wrote: > > 6.123233995736766e-17 > >>> > > is good enough for government work, including at the local public high > school. > > There probably is room for a library like "fractions" that represents multiples

Re: [Python-ideas] Trigonometry in degrees

2018-06-07 Thread Stephen J. Turnbull
Richard Damon writes: > To make it so that sindeg/cosdeg of multiples of 90 come out exact is > probably easiest to do by doing the angle reduction in degrees (so the > nice precise angles stay as nice precise angles) and then either adjust > the final computation formulas for degrees, or conv

Re: [Python-ideas] Trigonometry in degrees

2018-06-07 Thread Greg Ewing
Richard Damon wrote: First I feel the need to point out that radians are actually fairly fundamental in trigonometry, Even more so in calculus, since the derivative of sin(x) is cos(x) if and only if x is in radians. -- Greg ___ Python-ideas mailing

Re: [Python-ideas] Trigonometry in degrees

2018-06-07 Thread Richard Damon
On 6/7/18 7:08 PM, Robert Vanden Eynde wrote: > - I didn't know there were sinf in C (that's since C99), I was aware > of the 'd' postfix in opengl. > > So yeah, sind would be a bad idea, but sindeg or degsin would be too > long, hmm, and I can settle for the Pre or Post fix. sindeg(90) > degsin(90

Re: [Python-ideas] Trigonometry in degrees

2018-06-07 Thread Robert Vanden Eynde
(...) make it clear and explicit. That's why I strongly discourage people defining their own "sin" function that'd take degrees, therefore I look for a new function name (sindeg). Le ven. 8 juin 2018 à 00:17, Hugh Fisher a écrit : > > Date: Thu, 7 Jun 2018 12:33:29 +

Re: [Python-ideas] Trigonometry in degrees

2018-06-07 Thread Hugh Fisher
> Date: Thu, 7 Jun 2018 12:33:29 + > From: Robert Vanden Eynde > To: python-ideas > Subject: [Python-ideas] Trigonometry in degrees > Message-ID: > > > I suggest adding degrees version of the trigonometric functions in the math > module. > > -

Re: [Python-ideas] Trigonometry in degrees

2018-06-07 Thread Yuval Greenfield
On Thu, Jun 7, 2018 at 1:07 PM Robert Vanden Eynde < robertvandeney...@hotmail.com> wrote: > I suggest adding degrees version of the trigonometric functions in the > math module. > > You can create a pypi package that suits your needs. If it becomes popular it could considered for inclusion in the

Re: [Python-ideas] Trigonometry in degrees

2018-06-07 Thread Rob Speer
You meant math.radians(degrees), and Robert already mentioned the problem with this: >>> math.cos(math.radians(90)) 6.123233995736766e-17 On Thu, 7 Jun 2018 at 16:22 Ryan Gonzalez wrote: > You could always do e.g. math.sin(math.degress(radians)) and so forth... > > On June 7, 2018 3:07:21 PM Ro

Re: [Python-ideas] Trigonometry in degrees

2018-06-07 Thread Ryan Gonzalez
You could always do e.g. math.sin(math.degress(radians)) and so forth... On June 7, 2018 3:07:21 PM Robert Vanden Eynde wrote: I suggest adding degrees version of the trigonometric functions in the math module. - Useful in Teaching and replacing calculators by python, importing something

[Python-ideas] Trigonometry in degrees

2018-06-07 Thread Robert Vanden Eynde
I suggest adding degrees version of the trigonometric functions in the math module. - Useful in Teaching and replacing calculators by python, importing something is seen by the young students much more easy than to define a function. - Special values could be treated, aka when the angle is a mu