Hi there, just a simple routine little question that's hopefully easy
to answer, but which keeps on popping up and being annoying:
basically, how do I force something on the right hand side of a
function definition to be evaluated during definition?
For example, suppose I want to define a polynomial that I get from
desired roots:
(C22) collectterms(expand( apply("*", map( lambda([n], (z-%e^(%i*%pi*n/6))*(z-%e^(-%i*%pi*n/6))), [3,4,5,6])) ), z);
8 7 6 5
(D22) z + (SQRT(3) + 3) z + (3 SQRT(3) + 6) z + (5 SQRT(3) + 9) z
4 3 2
+ (6 SQRT(3) + 10) z + (5 SQRT(3) + 9) z + (3 SQRT(3) + 6) z
+ (SQRT(3) + 3) z + 1
now, if I do
(C23) g(z) := collectterms(expand( apply("*", map( lambda([n], (z-%e^(%i*%pi*n/6))*(z-%e^(-%i*%pi*n/6))), [3,4,5,6])) ), z);
(D23) g(z) := COLLECTTERMS(EXPAND(APPLY("*",
%I %PI n (- %I) %PI n
-------- ------------
6 6
MAP(LAMBDA([n], (z - %E ) (z - %E )), [3, 4, 5, 6]))), z)
then (I presume) all this algebra is done every time g is evaluated!
And I can't do:
(C24) h(z) := d22;
(D24) h(z) := D22
since it leads to:
(C25) h(0);
8 7 6 5
(D25) z + (SQRT(3) + 3) z + (3 SQRT(3) + 6) z + (5 SQRT(3) + 9) z
4 3 2
+ (6 SQRT(3) + 10) z + (5 SQRT(3) + 9) z + (3 SQRT(3) + 6) z
+ (SQRT(3) + 3) z + 1
I just want to define a function from the expanded and collected form
of the polynomial! Similar problems arise when I try to compute
jacobians etc., so I finally just decided to ask. (I couldn't find
any hints on this issue in the info file on function definitions...)
Is there a way to do this? I know of the Evaluate[] function in
Math'a and thought EV might do the trick, but I couldn't seem to get
it to work.
Thanks,
Carl