Numerical evaluation of the power function
- Subject: Numerical evaluation of the power function
- From: Barton Willis
- Date: Wed, 20 Jan 2010 20:11:25 -0600
Instead, would it be possible to use Raymond Toy's bigfloat package to do
floating point evaluation of ^?
Barton
-----maxima-bounces at math.utexas.edu wrote: -----
>To:?Maxima?<maxima at math.utexas.edu>
>From:?Dieter?Kaiser?<drdieterkaiser at web.de>
>Sent?by:?maxima-bounces at math.utexas.edu
>Date:?01/20/2010?03:53PM
>Subject:?[Maxima]?Numerical?evaluation?of?the?power?function
>
>I?would?like?to?suggest?to?implement?the?numerical?evaluation?of?the
>power?function?z^a?for?complex?values?z?or?a?in?float?or?bigfloat
>precision?too.?We?already?evaluate?numerically?for?real?float?or
>bigfloat?values.?Furthermore,?we?have?special?code?to?evaluate?the?exp
>function?and?the?sqrt?function.
>
>This?could?be?the?implementation?for?float?precision.?The?bigfloat
>implementation?is?similar.
>
>((and?(complex-float-numerical-eval-p?gr?pot)
>??????(or?(not?(ratnump?gr))?(not?(ratnump?pot))))
>?(let?((xr?($float?($realpart?gr)))
>???????(xi?($float?($imagpart?gr)))
>???????(yr?(if?(integerp?pot)?pot?($float?($realpart?pot))))
>???????(yi?($float?($imagpart?pot))))
>??(return?($float?($rectform?(list?'(mexpt)
>???????????????????????????????????(add?xr?(mul?'$%i?xi))
>???????????????????????????????????(if?(integerp?yr)
>???????????????????????????????????yr
>???????????????????????????????????(add?yr?(mul?'$%i?yi)))))))))
>
>The?testsuite?and?the?share_testsuite?will?have?no?problems.
>
>The?sqrt?and?exp?functions?evalutate?already?numerically:
>
>(%i7)?sqrt(1.0+%i);
>(%o7)?.4550898605622273*%i+1.09868411346781
>
>(%i8)?exp(1.0+%i);
>(%o8)?2.287355287178842*%i+1.468693939915885
>
>But?not?the?power?function?in?general:
>
>(%i9)?(1.0+%i)^2;
>(%o9)?(%i+1.0)^2
>
>(%i10)?(1.0+%i)^(1/3);
>(%o10)?(%i+1.0)^(1/3)
>
>(%i11)?(1.0+%i)^2.5;
>(%o11)?(%i+1.0)^2.5
>
>That?is?what?we?will?get:
>
>(%i3)?(1.0+%i)^2;
>(%o3)?2.0?%i
>
>(%i4)?(1.0+%i)^(1/3);
>(%o4)?.2905145555072514?%i?+?1.084215081491351
>
>(%i5)?(1.0+%i)^2.5;
>(%o5)?2.19736822693562?%i?-?.9101797211244543
>
>Furthermore,?numer?and?float?will?work?as?expected:
>
>(%i5)?(1.0+%i)^2,numer;
>(%o5)?2.0*%i
>
>(%i6)?1/(1.0+%i)^2,numer;
>(%o6)?-0.5*%i
>
>(%i8)?float((1+%i)^(1/3));
>(%o8)?.2905145555072514*%i+1.084215081491351
>
>
>I?think?a?lot?of?things?would?become?much?simpler?if?the?power?function
>evaluates?numerically?for?complex?values?too.?Furthermore,?I?think?it?is
>the?expected?behavior.
>
>Dieter?Kaiser
>
>_______________________________________________
>Maxima?mailing?list
>Maxima at math.utexas.edu
>http://www.math.utexas.edu/mailman/listinfo/maxima