problems with abs() and cabs()



Am Sonntag, den 10.01.2010, 23:43 +0300 schrieb Stanislav Maslovski:
> On Fri, Jan 08, 2010 at 09:10:45PM +0100, Dieter Kaiser wrote:
> > >         Sure. Then why
> > >         
> > >         plot3d(sqrt(realpart(subst(k0=%i,Ree)^2+imagpart(k0=%
> > >         i,Ree)^2),...)
> > >         
> > >         still works (see the example I sent in my first mail)?
> > 
> > I had a look at the problem.
> 
> Thank you, Dieter!
> 
> > (%i5) rectform(test)$
> > Evaluation took 0.1360 seconds (0.2420 elapsed) using 302.578 KB.
> > 
> > (%i6) abs(test)$
> > Evaluation took 0.3120 seconds (0.4120 elapsed) using 2.536 MB.
> > 
> > Then I have measured the time to get the plots. Surprisingly, the plot
> > with the absolute value now is much faster: 
> 
> This is probably because the expression returned by the modified abs
> is shorter (better simplified) than just a simple sqrt(re^2+im^2).
> 
> > (%i7) plot3d(sqrt(realpart(test)^2
> > +imagpart(test)^2),[ky,-3,3],[kz,-3,3]);
> > Evaluation took 119.8990 seconds (122.6900 elapsed) using 3259.698 MB.
> > (%o7) false
> > 
> > (%i8) plot3d(abs(test),[ky,-3,3],[kz,-3,3]);
> > Evaluation took 54.8320 seconds (56.3300 elapsed) using 628.454 MB.
> > (%o8) false
> > 
> > I have tried the testsuite with the modified function absarg and I have
> > got no problems. I will do some further tests.
> 
> Thank you once more! BTW, that my code is not copyrighted in any way,
> so if you would like to add it or any part of it to the testsuite I am
> fine with that ;-)

Thank you for your posting too. 

I think I will commit the small change to absarg this evening. I have
not seen any problem with the testsuite and the share_testsuite. Only
two examples in rtest_hygeo.mac give a different noun form.

By the way: To get the test expression I have not used floating point
numbers, but only integers and rationals (It is only necessary to change
vc : [0,0.5]; to vc:[0,1/2] in your example). I think it is preferable
to use exact numbers, because a more general expression might simplify
better.

Dieter Kaiser