numeric evaluation on complex plane



There is a historical problem with Macsyma code in
that it was written before there were complex numbers in lisp.
In Common Lisp there are complex numbers, and so numbers like
3+4i  can be represented as a single element.  (A constructor
for this is (complex 3 4).
In Macsyma/ Maxima  this is ((mplus simp) 3 ((mtimes simp) %$%i 4))
or some such thing.
Thus   we can't directly use a common lisp sin function and have
to make somewhat inefficient translations back and forth.

If we adopt complex numbers from common lisp, some things will
be simpler and faster.   On the other hand, some things will
not work, e.g.  bigfloats cannot be part of a common lisp complex
number,  and the form  a+bi  with a, b,  symbols  will look
quite different from a complex number.

If you know that the value of every variable in an expression
can be represented as a double-float complex, then in principle
it could all be compiled by the lisp compiler and you would only
have to convert to and from the wasteful but general form  at
the beginning of evaluation and at the end.

There may be other ways around this, but this is not easy to
resolve perfectly.
RJF



Vadim V. Zhytnikov wrote:

> Stavros Macrakis writes:
> 
>> Try
>>      rectform(sin(0.3+%i*0.4));
>> or, better,
>>      rectform(sin(0.3+%i*0.4)),numer;
>>
>> If you want the polar form, use instead:
>>
>>      polarform(sin(...))
>>
> I see.  So rectform does the trick by pulling %i out.
> And it probably works for any expression involving
> elementary functions.  Unfortunately this doesn't
> seem like efficient method.  And what about special
> functions?  The ultimate goal is numerical evaluation
> of any expression involving any elementary and special
> functions.  For example, Maxima has the code for numerical
> gamma function on complex plane (gamma-lanczos) but
> it seems to be out of use.
>