unevaluated add in the result of imag_form()
Hi again, While looking into a problem in numerical evaluation in pynac, I ran into the following: ginsh - GiNaC Interactive Shell (ginac V1.5.7) <snip> Type ?? for a list of help topics.
a=(sqrt(4*(sqrt(3) - 5)*(sqrt(3) + 5) + 48) + 4*sqrt(3))/ (sqrt(3) + 5); (sqrt(48+4*(5+sqrt(3))*(-5+sqrt(3)))+4*sqrt(3))*(5+sqrt(3))^(-1) imag_part(a); (5+sqrt(3))^(-1)*sqrt(abs(48+4*(5+sqrt(3))*(-5+sqrt(3))))*sin(1/2*atan2(0,48+4*(-22)))
Note that the second argument of atan2 is an add object in a rather unusual form: 48+4*(-22) Is this intended behavior? Thanks. Burcin
Hi! Burcin Erocal wrote:
While looking into a problem in numerical evaluation in pynac, I ran into the following:
ginsh - GiNaC Interactive Shell (ginac V1.5.7) <snip> Type ?? for a list of help topics.
a=(sqrt(4*(sqrt(3) - 5)*(sqrt(3) + 5) + 48) + 4*sqrt(3))/ (sqrt(3) + 5); (sqrt(48+4*(5+sqrt(3))*(-5+sqrt(3)))+4*sqrt(3))*(5+sqrt(3))^(-1) imag_part(a); (5+sqrt(3))^(-1)*sqrt(abs(48+4*(5+sqrt(3))*(-5+sqrt(3))))*sin(1/2*atan2(0,48+4*(-22)))
Note that the second argument of atan2 is an add object in a rather unusual form: 48+4*(-22)
Is this intended behavior?
Definitely not. A simpler case exhibiting the same problem is real_part(1+2*(sqrt(2)+1)*(sqrt(2)-1)). It seems to me that add::eval() is a little bit too simple-minded: add::real_part() returns an add with overall_coeff 1 and an expair with rest 1 and coeff 2, i.e. 1+2*1, but there is no case in add::eval() to take care of this. Bye, -richy. -- Richard B. Kreckel <http://www.ginac.de/~kreckel/>
Hi! Richard B. Kreckel wrote:
Burcin Erocal wrote:
Note that the second argument of atan2 is an add object in a rather unusual form: 48+4*(-22)
Is this intended behavior?
Definitely not. A simpler case exhibiting the same problem is real_part(1+2*(sqrt(2)+1)*(sqrt(2)-1)).
It seems to me that add::eval() is a little bit too simple-minded: add::real_part() returns an add with overall_coeff 1 and an expair with rest 1 and coeff 2, i.e. 1+2*1, but there is no case in add::eval() to take care of this.
I've pushed a patch to the repository. Thanks a lot for reporting this. -richy. -- Richard B. Kreckel <http://www.ginac.de/~kreckel/>
On Thu, 23 Sep 2010 01:06:30 +0200 "Richard B. Kreckel" <kreckel@ginac.de> wrote:
Richard B. Kreckel wrote:
Burcin Erocal wrote:
Note that the second argument of atan2 is an add object in a rather unusual form: 48+4*(-22)
Is this intended behavior?
Definitely not. A simpler case exhibiting the same problem is real_part(1+2*(sqrt(2)+1)*(sqrt(2)-1)).
It seems to me that add::eval() is a little bit too simple-minded: add::real_part() returns an add with overall_coeff 1 and an expair with rest 1 and coeff 2, i.e. 1+2*1, but there is no case in add::eval() to take care of this.
I've pushed a patch to the repository. Thanks a lot for reporting this.
Thank you Richard. I was able to apply your patch to pynac with minor changes. Best, Burcin
participants (3)
-
Alexei Sheplyakov
-
Burcin Erocal
-
Richard B. Kreckel