Maxima:将 e 展开为 cos 并且 i 为 sin?

Maxima: Expand e to cos and i sin?

Maxima中有没有将复数指数展开为欧拉cos + i sin形式的函数?

例如

expr: %e^(%i*w);
trigsomefunctionplease(expr);

那会给...

(%o1) cos(w) + i sin(w)

?

这是 Euler's formula and not de Moivre's formula, but in Maxima there is a function and an option-variable 调用 demoivre 来完成的。

Function: demoivre (expr)
Option variable: demoivre
The function demoivre (expr) converts one expression without setting the global variable demoivre.

When the variable demoivre is true, complex exponentials are converted into equivalent expressions in terms of circular functions: exp (a + b*%i) simplifies to %e^a * (cos(b) + %i*sin(b)) if b is free of %i. a and b are not expanded.

The default value of demoivre is false.

exponentialize converts circular and hyperbolic functions to exponential form. demoivre and exponentialize cannot both be true at the same time.

这是一个使用 Maxima Online Calculator

的例子
(%i1) demoivre;
(%o1)                                false
(%i2) %e^(%i*w);
                                      %i w
(%o2)                               %e
(%i3) expr:%e^(%i*w);
                                      %i w
(%o3)                               %e
(%i4) demoivre(%e^(%i*w));
(%o4)                         %i sin(w) + cos(w)
(%i5) demoivre(expr);
(%o5)                         %i sin(w) + cos(w)
(%i6) %e^(%i*w),demoivre=true;
(%o6)                         %i sin(w) + cos(w)
(%i7) expr,demoivre=true;
(%o7)                         %i sin(w) + cos(w)
(%i8) %e^(%i*w);
                                      %i w
(%o8)                               %e
(%i9) demoivre:true;
(%o9)                                true
(%i10) %e^(%i*w);
(%o10)                        %i sin(w) + cos(w)
(%i11) expr;
                                      %i w
(%o11)                              %e
(%i12) expr,ev;
(%o12)                        %i sin(w) + cos(w)
(%i13)