rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

sign of atan2 expressions #4072

Open rtoy opened 1 month ago

rtoy commented 1 month ago

Imported from SourceForge on 2024-07-09 11:16:04 Created by willisbl on 2023-11-09 13:21:55 Original: https://sourceforge.net/p/maxima/bugs/4209


Opinions might differ on the correct value for sign(atan2(1,%i)), but a user shouldn't get such a message:

(%i3)   sign(atan2(1,%i));
LOGARC: unrecognized argument: atan2

Notice

(%i22)  logarc(atan2(y,x));
(%o22)  -%i*log((%i*y+x)/sqrt(y^2+x^2))

If atan2(y,x) = carg(x + %i y) is an identity, I claim that sign(atan2(1,%i)) = pos is correct.

rtoy commented 1 month ago

Imported from SourceForge on 2024-07-09 11:16:05 Created by rtoy on 2023-11-09 15:31:39 Original: https://sourceforge.net/p/maxima/bugs/4209/#b07f


What version are you using? In git HEAD, I see

(%i9) sign(atan2(1,%i));

expt: undefined: 0 to a negative exponent.
 -- an error. To debug this try: debugmode(true);
rtoy commented 1 month ago

Imported from SourceForge on 2024-07-09 11:16:09 Created by willisbl on 2023-11-09 15:53:19 Original: https://sourceforge.net/p/maxima/bugs/4209/#0449


Oh, sorry--that was done using my tweaked but buggy version of compar.lisp.

But again, if atan2(y,x) = carg(x + %i y) is an identity, we should have atan2(1,%i) = carg(%i + %i) = carg(2 %i) = %pi/2, I think. And that makes sign(atan2(1,%i)) = pos correct, right?

rtoy commented 1 month ago

Imported from SourceForge on 2024-07-09 11:16:12 Created by rtoy on 2023-11-09 22:01:10 Original: https://sourceforge.net/p/maxima/bugs/4209/#c91e


I'm not really sure what the definition of atan2 should be. Is it carg or the logarc form. If we use the logarcform, I get

 (%i84) logarc(atan2(1,%i*t));

                                      %i t + %i
(%o84)                      - %i log(------------)
                                               2
                                     sqrt(1 - t )
(%i85)

The rectform is then:

(%i91) rectform(%);
Evaluation took 0.0100 seconds (0.0100 elapsed) using 247.898 KB.
                                                                    2
                    abs(t + 1)                        atan2(0, 1 - t )
(%o91)   - %i log(--------------) + atan2(t + 1, 0) - ----------------
                       ! 2    !                              2
                  sqrt(!t  - 1!)

It seems as if the imaginary part approaches minf as t approaches 1 from below.

Assuming I did this correctly.

The documentation for atan2 needs some work because it's clearly talking about x and y being real values.