Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #110252 > unrolled thread

Can math.atan2 return INF?

Started bySteven D'Aprano <steve@pearwood.info>
First post2016-06-22 03:50 +1000
Last post2016-06-23 15:37 +0100
Articles 20 on this page of 84 — 19 participants

Back to article view | Back to comp.lang.python


Contents

  Can math.atan2 return INF? Steven D'Aprano <steve@pearwood.info> - 2016-06-22 03:50 +1000
    Re: Can math.atan2 return INF? pdorange@pas-de-pub-merci.mac.com (Pierre-Alain Dorange) - 2016-06-21 20:01 +0200
      Re: Can math.atan2 return INF? Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-06-21 21:32 +0300
        Re: Can math.atan2 return INF? Steven D'Aprano <steve@pearwood.info> - 2016-06-22 11:40 +1000
          Re: Can math.atan2 return INF? Nagy László Zsolt <gandalf@shopzeus.com> - 2016-06-27 15:27 +0200
      Re: Can math.atan2 return INF? Steven D'Aprano <steve@pearwood.info> - 2016-06-22 11:38 +1000
        Re: Can math.atan2 return INF? pdorange@pas-de-pub-merci.mac.com (Pierre-Alain Dorange) - 2016-06-22 08:21 +0200
        Re: Can math.atan2 return INF? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-06-22 16:34 +0100
          Re: Can math.atan2 return INF? Random832 <random832@fastmail.com> - 2016-06-22 12:19 -0400
          Re: Can math.atan2 return INF? pdorange@pas-de-pub-merci.mac.com (Pierre-Alain Dorange) - 2016-06-22 19:18 +0200
            Re: Can math.atan2 return INF? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-06-22 20:17 +0100
              Re: Can math.atan2 return INF? Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-22 12:50 -0700
              Re: Can math.atan2 return INF? Steven D'Aprano <steve@pearwood.info> - 2016-06-23 13:59 +1000
                Re: Can math.atan2 return INF? Dan Sommers <dan@tombstonezero.net> - 2016-06-23 04:40 +0000
                  Re: Can math.atan2 return INF? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-06-23 16:45 +1000
                    Re: Can math.atan2 return INF? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-06-23 15:39 +0100
                      Re: Can math.atan2 return INF? alister <alister.ware@ntlworld.com> - 2016-06-23 15:04 +0000
                        Re: Can math.atan2 return INF? Steven D'Aprano <steve@pearwood.info> - 2016-06-24 02:44 +1000
                          Re: Can math.atan2 return INF? pdorange@pas-de-pub-merci.mac.com (Pierre-Alain Dorange) - 2016-06-23 19:14 +0200
                            Re: Can math.atan2 return INF? Marko Rauhamaa <marko@pacujo.net> - 2016-06-23 20:22 +0300
                              Re: Can math.atan2 return INF? pdorange@pas-de-pub-merci.mac.com (Pierre-Alain Dorange) - 2016-06-24 09:53 +0200
                                Re: Can math.atan2 return INF? Marko Rauhamaa <marko@pacujo.net> - 2016-06-24 13:38 +0300
                                  Re: Can math.atan2 return INF? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-06-26 11:43 +1200
                              Re: Can math.atan2 return INF? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-06-26 11:40 +1200
                                Re: Can math.atan2 return INF? Marko Rauhamaa <marko@pacujo.net> - 2016-06-26 10:09 +0300
                                  Re: Can math.atan2 return INF? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-06-27 11:08 +1200
                                    Re: Can math.atan2 return INF? Steven D'Aprano <steve@pearwood.info> - 2016-06-27 12:59 +1000
                                      Re: Can math.atan2 return INF? Marko Rauhamaa <marko@pacujo.net> - 2016-06-27 09:40 +0300
                                        Re: Can math.atan2 return INF? Rustom Mody <rustompmody@gmail.com> - 2016-06-27 06:15 -0700
                                          Re: Can math.atan2 return INF? Marko Rauhamaa <marko@pacujo.net> - 2016-06-27 16:45 +0300
                                            Re: Can math.atan2 return INF? Rustom Mody <rustompmody@gmail.com> - 2016-06-27 07:01 -0700
                                              Re: Can math.atan2 return INF? Marko Rauhamaa <marko@pacujo.net> - 2016-06-27 17:12 +0300
                                                Re: Can math.atan2 return INF? Rustom Mody <rustompmody@gmail.com> - 2016-06-27 07:27 -0700
                                                  Re: Can math.atan2 return INF? Marko Rauhamaa <marko@pacujo.net> - 2016-06-27 20:03 +0300
                                          Re: Can math.atan2 return INF? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-06-28 18:12 +1200
                                            Re: Can math.atan2 return INF? Rustom Mody <rustompmody@gmail.com> - 2016-06-27 23:25 -0700
                                            Re: Can math.atan2 return INF? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-06-28 16:27 +1000
                                        Re: Can math.atan2 return INF? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-06-28 18:12 +1200
                                          Re: Can math.atan2 return INF? Marko Rauhamaa <marko@pacujo.net> - 2016-06-28 09:23 +0300
                                      Re: Can math.atan2 return INF? Random832 <random832@fastmail.com> - 2016-06-28 09:39 -0400
                                        Re: Can math.atan2 return INF? Steven D'Aprano <steve@pearwood.info> - 2016-06-29 01:22 +1000
                                        Re: Can math.atan2 return INF? Marko Rauhamaa <marko@pacujo.net> - 2016-06-28 19:36 +0300
                                        Re: Can math.atan2 return INF? Marko Rauhamaa <marko@pacujo.net> - 2016-06-28 19:42 +0300
                                Re: Can math.atan2 return INF? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-06-29 19:35 +1000
                                  Re: Can math.atan2 return INF? Marko Rauhamaa <marko@pacujo.net> - 2016-06-29 13:54 +0300
                                    Re: Can math.atan2 return INF? Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-29 18:33 -0700
                                      Re: Can math.atan2 return INF? Rustom Mody <rustompmody@gmail.com> - 2016-06-29 19:13 -0700
                                        Re: Can math.atan2 return INF? Chris Angelico <rosuav@gmail.com> - 2016-06-30 12:38 +1000
                                        Re: Can math.atan2 return INF? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-06-30 18:24 +1000
                                          Re: Can math.atan2 return INF? Andreas Röhler <andreas.roehler@online.de> - 2016-06-30 11:35 +0200
                                            Re: Can math.atan2 return INF? Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-30 02:42 -0700
                                              Re: Can math.atan2 return INF? Andreas Röhler <andreas.roehler@online.de> - 2016-06-30 12:13 +0200
                                          Re: Can math.atan2 return INF? Andreas Röhler <andreas.roehler@online.de> - 2016-06-30 12:11 +0200
                                            Re: Can math.atan2 return INF? Steven D'Aprano <steve@pearwood.info> - 2016-07-01 03:18 +1000
                                          Re: Can math.atan2 return INF? Rustom Mody <rustompmody@gmail.com> - 2016-06-30 08:28 -0700
                                            Re: Can math.atan2 return INF? Steven D'Aprano <steve@pearwood.info> - 2016-07-01 04:03 +1000
                                              Re: Can math.atan2 return INF? Rustom Mody <rustompmody@gmail.com> - 2016-07-01 07:19 -0700
                                                Re: Can math.atan2 return INF? Marko Rauhamaa <marko@pacujo.net> - 2016-07-01 18:20 +0300
                                              Re: Can math.atan2 return INF? Rustom Mody <rustompmody@gmail.com> - 2016-07-29 22:46 -0700
                                                Re: Can math.atan2 return INF? Steven D'Aprano <steve@pearwood.info> - 2016-08-01 12:53 +1000
                                                  Re: Can math.atan2 return INF? Paul Rubin <no.email@nospam.invalid> - 2016-07-31 20:41 -0700
                                                    Re: Can math.atan2 return INF? Rustom Mody <rustompmody@gmail.com> - 2016-07-31 20:54 -0700
                                                  Re: Can math.atan2 return INF? Rustom Mody <rustompmody@gmail.com> - 2016-07-31 21:05 -0700
                                                    Re: Can math.atan2 return INF? Ian Kelly <ian.g.kelly@gmail.com> - 2016-08-01 01:05 -0600
                                          Re: Can math.atan2 return INF? Rustom Mody <rustompmody@gmail.com> - 2016-07-24 19:48 -0700
                                      Re: Can math.atan2 return INF? Marko Rauhamaa <marko@pacujo.net> - 2016-06-30 09:24 +0300
                                        Re: Can math.atan2 return INF? Rustom Mody <rustompmody@gmail.com> - 2016-06-29 23:29 -0700
                                          Re: Can math.atan2 return INF? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-06-30 07:47 -0400
                                        Re: Can math.atan2 return INF? alister <alister.ware@ntlworld.com> - 2016-06-30 14:54 +0000
                                      Re: Can math.atan2 return INF? Paul Rubin <no.email@nospam.invalid> - 2016-06-29 23:57 -0700
                                        Re: Can math.atan2 return INF? Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-30 00:16 -0700
                                          Re: Can math.atan2 return INF? Paul Rubin <no.email@nospam.invalid> - 2016-06-30 00:32 -0700
                                            Re: Can math.atan2 return INF? Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-30 00:39 -0700
                                          Re: Can math.atan2 return INF? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-06-30 18:27 +1000
                                      Re: Can math.atan2 return INF? Andreas Röhler <andreas.roehler@online.de> - 2016-06-30 09:17 +0200
                                        Re: Can math.atan2 return INF? Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-30 00:17 -0700
                                    Re: Can math.atan2 return INF? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-06-30 18:06 +1200
                                      Re: Can math.atan2 return INF? Marko Rauhamaa <marko@pacujo.net> - 2016-06-30 09:32 +0300
                                  Re: Can math.atan2 return INF? Random832 <random832@fastmail.com> - 2016-06-29 09:55 -0400
                          Re: Can math.atan2 return INF? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-06-26 11:15 +1200
                            Re: Can math.atan2 return INF? MRAB <python@mrabarnett.plus.com> - 2016-06-26 00:31 +0100
                        Re: Can math.atan2 return INF? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-06-23 20:04 +0100
                  Re: Can math.atan2 return INF? pdorange@pas-de-pub-merci.mac.com (Pierre-Alain Dorange) - 2016-06-23 19:07 +0200
                Re: Can math.atan2 return INF? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-06-23 15:37 +0100

Page 1 of 5  [1] 2 3 4 5  Next page →


#110252 — Can math.atan2 return INF?

FromSteven D'Aprano <steve@pearwood.info>
Date2016-06-22 03:50 +1000
SubjectCan math.atan2 return INF?
Message-ID<57697e61$0$1590$c3e8da3$5496439d@news.astraweb.com>
Are there any circumstances where math.atan2(a, b) can return an infinity?

I know it will return a NAN under some circumstances.



-- 
Steven

[toc] | [next] | [standalone]


#110253

Frompdorange@pas-de-pub-merci.mac.com (Pierre-Alain Dorange)
Date2016-06-21 20:01 +0200
Message-ID<1mp7m3g.picev12e77h4N%pdorange@pas-de-pub-merci.mac.com>
In reply to#110252
Steven D'Aprano <steve@pearwood.info> wrote:

> Are there any circumstances where math.atan2(a, b) can return an infinity?
> 
> I know it will return a NAN under some circumstances.

atan or atan2 can't return INFINITE, it was the arc tangent of a value,
then arc tangent can only be between -PI and +PI (is was an angle).

I do not know under what circumstance atan2 can return NAN, atan2 taks 2
argument (y and x) and return the angle corresponding to y/x.
If x is 0.0, atan2 return 0.0 (do not try to make the division).

atan2 was used over atan to optimize and so that it can used the correct
quadrant (for angle answer).

-- 
Pierre-Alain Dorange        <http://microwar.sourceforge.net/>

Ce message est sous licence Creative Commons "by-nc-sa-2.0"
        <http://creativecommons.org/licenses/by-nc-sa/2.0/fr/>

[toc] | [prev] | [next] | [standalone]


#110260

FromJussi Piitulainen <jussi.piitulainen@helsinki.fi>
Date2016-06-21 21:32 +0300
Message-ID<lf57fdigzov.fsf@ling.helsinki.fi>
In reply to#110253
pdorange@pas-de-pub-merci.mac.com (Pierre-Alain Dorange) writes:

> Steven D'Aprano <steve@pearwood.info> wrote:
>
>> Are there any circumstances where math.atan2(a, b) can return an infinity?
>> 
>> I know it will return a NAN under some circumstances.
>
> atan or atan2 can't return INFINITE, it was the arc tangent of a
> value, then arc tangent can only be between -PI and +PI (is was an
> angle).
>
> I do not know under what circumstance atan2 can return NAN, atan2 taks
> 2 argument (y and x) and return the angle corresponding to y/x.  If x
> is 0.0, atan2 return 0.0 (do not try to make the division).

It seems to return NaN when either argument is NaN. It seems to return
finite values when either argument is Inf or -Inf, and negative zeroes
lead to different but finite answers.

Wikipedia says ata2(0,0) is considered undefined traditionally and in
symbolic maths but otherwise most computer implementations define it.
Python seems to produce +-0.0 and +-pi for variously signed zeroes.

I didn't see any mention of it ever being infinite, which makes sense
given that arcus functions are supposed to return angles. The extreme
case seemed to be the inclusion of -pi as a possible value.

(I know nothing, I was just curious enough to play with this a bit.)

[toc] | [prev] | [next] | [standalone]


#110279

FromSteven D'Aprano <steve@pearwood.info>
Date2016-06-22 11:40 +1000
Message-ID<5769ec9e$0$22142$c3e8da3$5496439d@news.astraweb.com>
In reply to#110260
On Wed, 22 Jun 2016 04:32 am, Jussi Piitulainen wrote:

> pdorange@pas-de-pub-merci.mac.com (Pierre-Alain Dorange) writes:
> 
>> Steven D'Aprano <steve@pearwood.info> wrote:
>>
>>> Are there any circumstances where math.atan2(a, b) can return an
>>> infinity?
[...]
> I didn't see any mention of it ever being infinite, which makes sense
> given that arcus functions are supposed to return angles. The extreme
> case seemed to be the inclusion of -pi as a possible value.
> 
> (I know nothing, I was just curious enough to play with this a bit.)

Thanks, I'm in the same position as you, except that I'm in the position
where I need it use the result, and if it ever returns INF my function will
blow up. But it doesn't look like that can happen.



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#110578

FromNagy László Zsolt <gandalf@shopzeus.com>
Date2016-06-27 15:27 +0200
Message-ID<mailman.30.1467034498.2358.python-list@python.org>
In reply to#110279
> Thanks, I'm in the same position as you, except that I'm in the position
> where I need it use the result, and if it ever returns INF my function will
> blow up. But it doesn't look like that can happen.
>
Doesn't atan2 relies on the C lib math floating point library? At least
in CPython. I think (but not 100% sure) that it is implementation
dependent, and returns what is returned by clib floating point lib.
Since the meaning of atan2 is an angle, it should always be between
[-pi,pi]. The only exception maybe when there is a NaN in the arguments.
But I cannot think of any interpretation where atan2 would return Inf or
-Inf.

[toc] | [prev] | [next] | [standalone]


#110278

FromSteven D'Aprano <steve@pearwood.info>
Date2016-06-22 11:38 +1000
Message-ID<5769ec12$0$1610$c3e8da3$5496439d@news.astraweb.com>
In reply to#110253
On Wed, 22 Jun 2016 04:01 am, Pierre-Alain Dorange wrote:

> Steven D'Aprano <steve@pearwood.info> wrote:
> 
>> Are there any circumstances where math.atan2(a, b) can return an
>> infinity?
>> 
>> I know it will return a NAN under some circumstances.
> 
> atan or atan2 can't return INFINITE, it was the arc tangent of a value,
> then arc tangent can only be between -PI and +PI (is was an angle).

I should hope it wouldn't. That's why I'm asking.


> I do not know under what circumstance atan2 can return NAN, atan2 taks 2
> argument (y and x) and return the angle corresponding to y/x.
> If x is 0.0, atan2 return 0.0 (do not try to make the division).

py> math.atan2(NAN, 0)
nan

I think that the only way it will return a NAN is if passed a NAN.



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#110293

Frompdorange@pas-de-pub-merci.mac.com (Pierre-Alain Dorange)
Date2016-06-22 08:21 +0200
Message-ID<1mp8kh1.153tmc61yolko1N%pdorange@pas-de-pub-merci.mac.com>
In reply to#110278
Steven D'Aprano <steve@pearwood.info> wrote:

> py> math.atan2(NAN, 0)
> nan
> 
> I think that the only way it will return a NAN is if passed a NAN.

yes of course if you pass an invalid argument (NAN is not a real value,
atan2 except coordinate x,y), the result would be invalid...

-- 
Pierre-Alain Dorange        <http://microwar.sourceforge.net/>

Ce message est sous licence Creative Commons "by-nc-sa-2.0"
        <http://creativecommons.org/licenses/by-nc-sa/2.0/fr/>

[toc] | [prev] | [next] | [standalone]


#110320

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2016-06-22 16:34 +0100
Message-ID<87d1n9kzk9.fsf@bsb.me.uk>
In reply to#110278
Steven D'Aprano <steve@pearwood.info> writes:

> On Wed, 22 Jun 2016 04:01 am, Pierre-Alain Dorange wrote:
<snip>
>> I do not know under what circumstance atan2 can return NAN, atan2 taks 2
>> argument (y and x) and return the angle corresponding to y/x.
>> If x is 0.0, atan2 return 0.0 (do not try to make the division).
>
> py> math.atan2(NAN, 0)
> nan
>
> I think that the only way it will return a NAN is if passed a NAN.

That seems to be the case but I was a little surprised to find that

  >>> math.atan2(INF, INF)
  0.7853981633974483

I would have expected NaN since atan2(INF, INF) could be thought of as
the limit of atan2(x, y) which could be any value in the range.  And I'd
have guessed atan2(0, 0) would have been NaN too but

  >>> math.atan2(0, 0)
  0.0

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#110324

FromRandom832 <random832@fastmail.com>
Date2016-06-22 12:19 -0400
Message-ID<mailman.43.1466612389.11516.python-list@python.org>
In reply to#110320
On Wed, Jun 22, 2016, at 11:34, Ben Bacarisse wrote:
> Steven D'Aprano <steve@pearwood.info> writes:
> > I think that the only way it will return a NAN is if passed a NAN.
> 
> That seems to be the case but I was a little surprised to find that
> 
>   >>> math.atan2(INF, INF)
>   0.7853981633974483
> 
> I would have expected NaN since atan2(INF, INF) could be thought of as
> the limit of atan2(x, y) which could be any value in the range.  And I'd
> have guessed atan2(0, 0) would have been NaN too but
> 
>   >>> math.atan2(0, 0)
>   0.0

In C, the result of atan2(0, 0) [for any sign of zero] may be
implementation-dependent: "A domain error may occur if both arguments
are zero." In CPython, though, they're explicitly handled as special
cases by the m_atan2 function. The results match that of the x87 FPATAN
instruction, and presumably the IEEE standard (the same results are
prescribed in the IEC 60559 appendix of the C standard)

http://www.charlespetzold.com/blog/2008/09/180741.html mentions Intel's
rationale (in short, it's because 0+0j is a real number).

[toc] | [prev] | [next] | [standalone]


#110330

Frompdorange@pas-de-pub-merci.mac.com (Pierre-Alain Dorange)
Date2016-06-22 19:18 +0200
Message-ID<1mp9e9m.s25gk61k28dhhN%pdorange@pas-de-pub-merci.mac.com>
In reply to#110320
Ben Bacarisse <ben.usenet@bsb.me.uk> wrote:

>   >>> math.atan2(INF, INF)
>   0.7853981633974483
> 
> I would have expected NaN since atan2(INF, INF) could be thought of as
> the limit of atan2(x, y) which could be any value in the range.  And I'd
> have guessed atan2(0, 0) would have been NaN too but

i'm not a math expert, but the limit of atan2 would be 45°, so pi/4
radians (0,7854). 
As x,y are coordinates, the both infinite would tend toward 45°.

x only infinite would be  0° (0 radians)
y only infinite woudl be 180° (pi/2 radians)

-- 
Pierre-Alain Dorange        <http://microwar.sourceforge.net/>

Ce message est sous licence Creative Commons "by-nc-sa-2.0"
        <http://creativecommons.org/licenses/by-nc-sa/2.0/fr/>

[toc] | [prev] | [next] | [standalone]


#110334

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2016-06-22 20:17 +0100
Message-ID<87inx1janx.fsf@bsb.me.uk>
In reply to#110330
pdorange@pas-de-pub-merci.mac.com (Pierre-Alain Dorange) writes:

> Ben Bacarisse <ben.usenet@bsb.me.uk> wrote:
>
>>   >>> math.atan2(INF, INF)
>>   0.7853981633974483
>> 
>> I would have expected NaN since atan2(INF, INF) could be thought of as
>> the limit of atan2(x, y) which could be any value in the range.  And I'd
>> have guessed atan2(0, 0) would have been NaN too but
>
> i'm not a math expert, but the limit of atan2 would be 45°, so pi/4
> radians (0,7854).
> As x,y are coordinates, the both infinite would tend toward 45°.

The limit of atan2(x, x) is as you describe, but there is no reason to
pick that one case.  lim{x->oo,y->oo}atan2(x, y) is undefined unless a
relationship is given between x and y and you get get any result you
like in the range of atan2 by choosing one or other relationship.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#110336

FromLawrence D’Oliveiro <lawrencedo99@gmail.com>
Date2016-06-22 12:50 -0700
Message-ID<bc56abfa-4088-4508-9d32-fc5c1768f7c8@googlegroups.com>
In reply to#110334
On Thursday, June 23, 2016 at 7:17:37 AM UTC+12, Ben Bacarisse wrote:

> The limit of atan2(x, x) is as you describe, but there is no reason to
> pick that one case.

It’s what’s called a “non-removable discontinuity”. The value you pick at that point will be consistent with approaching it from one particular direction, not from any other.

[toc] | [prev] | [next] | [standalone]


#110355

FromSteven D'Aprano <steve@pearwood.info>
Date2016-06-23 13:59 +1000
Message-ID<576b5eb4$0$1595$c3e8da3$5496439d@news.astraweb.com>
In reply to#110334
On Thu, 23 Jun 2016 05:17 am, Ben Bacarisse wrote:

> pdorange@pas-de-pub-merci.mac.com (Pierre-Alain Dorange) writes:
> 
>> Ben Bacarisse <ben.usenet@bsb.me.uk> wrote:
>>
>>>   >>> math.atan2(INF, INF)
>>>   0.7853981633974483
>>> 
>>> I would have expected NaN since atan2(INF, INF) could be thought of as
>>> the limit of atan2(x, y) which could be any value in the range.  And I'd
>>> have guessed atan2(0, 0) would have been NaN too but
>>
>> i'm not a math expert, but the limit of atan2 would be 45°, so pi/4
>> radians (0,7854).
>> As x,y are coordinates, the both infinite would tend toward 45°.
> 
> The limit of atan2(x, x) is as you describe, but there is no reason to
> pick that one case.

Given:

x = INF
y = INF
assert x == y

there is a reason to pick atan2(y, x) = pi/4:

Since x == y, the answer should be the same as for any other pair of x == y.

It might not be a *great* reason, but it's a reason.



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#110362

FromDan Sommers <dan@tombstonezero.net>
Date2016-06-23 04:40 +0000
Message-ID<nkfp80$4je$1@dont-email.me>
In reply to#110355
On Thu, 23 Jun 2016 13:59:46 +1000, Steven D'Aprano wrote:

> Given:
> 
> x = INF
> y = INF
> assert x == y
> 
> there is a reason to pick atan2(y, x) = pi/4:
> 
> Since x == y, the answer should be the same as for any other pair of x == y.

When x == y == 0, then atan2(y, x) is 0.

[toc] | [prev] | [next] | [standalone]


#110372

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2016-06-23 16:45 +1000
Message-ID<576b8576$0$1510$c3e8da3$5496439d@news.astraweb.com>
In reply to#110362
On Thursday 23 June 2016 14:40, Dan Sommers wrote:

>> Since x == y, the answer should be the same as for any other pair of x == y.
> 
> When x == y == 0, then atan2(y, x) is 0.

/s/any other pair of x == y/any other pair of x y except for zero/

:-P


Zero is exceptional in many ways.


-- 
Steve

[toc] | [prev] | [next] | [standalone]


#110420

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2016-06-23 15:39 +0100
Message-ID<877fdgj7f4.fsf@bsb.me.uk>
In reply to#110372
Steven D'Aprano <steve+comp.lang.python@pearwood.info> writes:

> On Thursday 23 June 2016 14:40, Dan Sommers wrote:
>
>>> Since x == y, the answer should be the same as for any other pair of x == y.
>> 
>> When x == y == 0, then atan2(y, x) is 0.

I see just added noise by making the same comment before reading the
rest of the thread.  Sorry.

> /s/any other pair of x == y/any other pair of x y except for zero/
>
> :-P
>
>
> Zero is exceptional in many ways.

whereas infinity...  :-)

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#110421

Fromalister <alister.ware@ntlworld.com>
Date2016-06-23 15:04 +0000
Message-ID<gUSaz.193575$JH2.134621@fx45.am4>
In reply to#110420
On Thu, 23 Jun 2016 15:39:43 +0100, Ben Bacarisse wrote:

> Steven D'Aprano <steve+comp.lang.python@pearwood.info> writes:
> 
>> On Thursday 23 June 2016 14:40, Dan Sommers wrote:
>>
>>>> Since x == y, the answer should be the same as for any other pair of
>>>> x == y.
>>> 
>>> When x == y == 0, then atan2(y, x) is 0.
> 
> I see just added noise by making the same comment before reading the
> rest of the thread.  Sorry.
> 
>> /s/any other pair of x == y/any other pair of x y except for zero/
>>
>> :-P
>>
>>
>> Zero is exceptional in many ways.
> 
> whereas infinity...  :-)

which infinity. There are many - some larger than others 



-- 
| |-sshd---tcsh-+-dpkg-buildpacka---rules---sh---make---make---sh---
make---sh---make---sh---make---sh---make---sh---make
	-- While packaging XFree86 for Debian GNU/Linux

[toc] | [prev] | [next] | [standalone]


#110431

FromSteven D'Aprano <steve@pearwood.info>
Date2016-06-24 02:44 +1000
Message-ID<576c1207$0$1597$c3e8da3$5496439d@news.astraweb.com>
In reply to#110421
On Fri, 24 Jun 2016 01:04 am, alister wrote:

> which infinity. There are many - some larger than others

China has just announced a new supercomputer that is so fast it can run an
infinite loop in 3.7 seconds.


-- 
Steven

[toc] | [prev] | [next] | [standalone]


#110435

Frompdorange@pas-de-pub-merci.mac.com (Pierre-Alain Dorange)
Date2016-06-23 19:14 +0200
Message-ID<1mpb97o.f86qm9eqx9uyN%pdorange@pas-de-pub-merci.mac.com>
In reply to#110431
Steven D'Aprano <steve@pearwood.info> wrote:

> > which infinity. There are many - some larger than others
> 
> China has just announced a new supercomputer that is so fast it can run an
> infinite loop in 3.7 seconds.

Near a black hole 3.7 seconds can last an infinite time...

-- 
Pierre-Alain Dorange        <http://microwar.sourceforge.net/>

Ce message est sous licence Creative Commons "by-nc-sa-2.0"
        <http://creativecommons.org/licenses/by-nc-sa/2.0/fr/>

[toc] | [prev] | [next] | [standalone]


#110436

FromMarko Rauhamaa <marko@pacujo.net>
Date2016-06-23 20:22 +0300
Message-ID<87shw3es70.fsf@elektro.pacujo.net>
In reply to#110435
pdorange@pas-de-pub-merci.mac.com (Pierre-Alain Dorange):

> Steven D'Aprano <steve@pearwood.info> wrote:
>> China has just announced a new supercomputer that is so fast it can
>> run an infinite loop in 3.7 seconds.
>
> Near a black hole 3.7 seconds can last an infinite time...

Which phenomenon prevents a black hole from ever forming. Yet
astronomers keep telling us they are all over the place.

   Oppenheimer and his co-authors interpreted the singularity at the
   boundary of the Schwarzschild radius as indicating that this was the
   boundary of a bubble in which time stopped. This is a valid point of
   view for external observers, but not for infalling observers. Because
   of this property, the collapsed stars were called "frozen stars",
   because an outside observer would see the surface of the star frozen
   in time at the instant where its collapse takes it inside the
   Schwarzschild radius.
   <URL: https://en.wikipedia.org/wiki/Black_hole>

Note that the "valid point of view for external observers" is the only
valid scientific point of view.


Marko

[toc] | [prev] | [next] | [standalone]


Page 1 of 5  [1] 2 3 4 5  Next page →

Back to top | Article view | comp.lang.python


csiph-web