From: SourceForge.net <no...@so...> - 2009-04-05 23:15:07
|
Bugs item #2298099, was opened at 2008-11-16 12:50 Message generated for change (Comment added) made by crategus You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=2298099&group_id=4933 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Lisp Core - Trigonometry Group: Includes proposed fix Status: Open Resolution: None Priority: 5 Private: No Submitted By: Barton Willis (willisbl) Assigned to: Nobody/Anonymous (nobody) Summary: atan2 & logarc Initial Comment: When logarc is true, atan2 returns incorrect values in the left half plane: (%i5) logarc : true$ (%i6) e : atan2(y,x); (%o6) -(%i*(log((%i*y)/x+1)-log(1-(%i*y)/x)))/2 Should be 3 %pi / 4, not - %pi / 4: (%i7) rectform(subst([y=1,x=-1], e)); (%o7) -%pi/4 Should be -3 %pi / 4, not - %pi / 4: (%i8) rectform(subst([y=-1,x=-1],e)); (%o8) %pi/4 ---------------------------------------------------------------------- >Comment By: Dieter Kaiser (crategus) Date: 2009-04-06 01:14 Message: Remark: This topic was discussed already in the bug report SF [626721] "logarc of atan2 wrong". The function $logarc was fixed, but the simplifying function simpatan2 in comm2.lisp has still the problem. Therefore the flag logarc does not work. Dieter Kaiser ---------------------------------------------------------------------- Comment By: Dieter Kaiser (crategus) Date: 2009-04-05 21:27 Message: A more general definition of atan2(y,x) is: - %i * log((x+%i*y)/sqrt(x^2+y^2)) When we use this definition to transform atan2 for logarc:true, we will get the correct results. The changed code is ;($logarc (logarc '%atan (div y x))) ($logarc (mul -1 '$%i (simplify (list '(%log) (div (add x (mul '$%i y)) (power (add (mul x x) (mul y y)) (div 1 2))))))) The examples of this bug report would give the correct results. The testsuite has no problems: (%i13) logarc:true$ (%i16) atan2(x,y); (%o16) -%i*log((y+%i*x)/sqrt(y^2+x^2)) (%i17) rectform(subst([y=1,x=-1],atan2(y,x))); (%o17) 3*%pi/4 (%i18) rectform(subst([y=-1,x=-1],atan2(y,x))); (%o18) -3*%pi/4 Dieter Kaiser ---------------------------------------------------------------------- Comment By: Raymond Toy (rtoy) Date: 2009-03-02 16:50 Message: Perhaps this is really a bug in the logarc variable, or at least an inconsistency. atan2(y,x), logarc returns the expression you give above. But logarc(atan2(y,x)) -> -%i*log((x+%i*y)/sqrt(x^2+y^2)). This latter expression gives 3*%pi/4 for x=-1, and y = 1. This is an example where log(x/y) is not equal to log(x) - log(y), I think. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=2298099&group_id=4933 |