Numerical evaluation etc.



To evaluate exp(1 + sqrt(-1)) to a float, first convert
it to rectangular form using rectform. Second, either use numer as you 
did, or use float.  You'll need to use this trick whenever
the argument to a log, trig, exponential, or ... function 
is complex.

(C1) z : exp(1.0+sqrt(-1.0))$
(C2) rectform(z),numer;
(D2)               2.287355287178842 %I + 1.468693939915885
(C3) float(rectform(z));
(D3)               2.287355287178842 %I + 1.468693939915885

Notes: 

(0) In Maxima, the imaginary unit is %i,

(1) expr, numer is the same as ev(expr, numer).

(2) Here is another undocumented(!) trick for evaluating to a float

(C15) z : exp(exp(1))$
(C16) float(z);
(D16) 2.718281828459045^%E
(C17) z,numer;
(D17) %E^%E
(C18) scanmap('float,z);
(D18) 15.15426224147926

(C19) bfloat(z);
(D19) 1.515426224147926B1
(C20) 

This is all very frustrating---both (d16) and (d17) don't 
evaluate to a float due to bugs. Oddly, the bfloat 
function (evaluate to a big float) doesn't have this 
bug---line (c19) evaluates correctly to a bigfloat.


Barton




Andrew Archibald <archibal@math.mcgill.ca>
Sent by: maxima-admin@math.utexas.edu
03/20/2004 02:29 PM

 
        To:     maxima@www.ma.utexas.edu
        cc: 
        Subject:        [Maxima] Numerical evaluation etc.


Hi,

I'm sure this is probably often asked, but it's not in the FAQ
and I can't figure out how to search the mailing list archive.

How do I persuade an expression to evaluatte numerically?

(C2) EV(exp(1.0+sqrt(-1.0)),NUMER);

                                    %I + 1.0
(D2)                              %E

The documentation claims this should be expanded even while having the
frustrating claim that not all functions will be expanded numerically.

Also, it would be nice if the documentation mentioned somewhere
prominent that the way to specify pi was as %PI (and so on).  This is
aggravated by the habit of TeXmacs of not displaying the % signs, but
that's not Maxima's fault.


Thanks,
Andrew

_______________________________________________
Maxima mailing list
Maxima@www.math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima