hi Dan
you wrote
>Arrays created with array work differently, but they are created in the
> global name space so,
> if there is a variable z globally, array(z,2) works, but depends(z,t)
> doesnt.
> Also apply_nouns does not seem to function in the windows
> implementation, which I tried to
> use first. I am aware that 'z[i] is not evaluated but if it isnt
> quoted, sum of course returns 0.
> Is it possible to keep a array created with array out of the global name
> space?
> I need to work with arrays so that each element can be treated as a
> symbol. Is there a different
> idiom that I need to use?
this is OK.
My answer is
(C1) display2d:false;
(D1) FALSE
(C2)
(D2) f():=BLOCK([t,z,zz],z:MAKE_ARRAY('ANY,2),
PRINT(SUM('DIFF('z[i],t),i,0,1)),
zz:RATSUBST(COS(t),'z[0],SUM('DIFF('z[i],t),i,0,1)),PRINT(zz),
EV(zz,DIFF))
(C3) f();
'DIFF('z[1],t,1)+'DIFF('z[0],t,1)
'DIFF(COS(t),t,1)+'DIFF('z[1],t,1)
(D3) -SIN(t)
(C4) arrays;
(D4) []
(C5) values;
(D5) []
OK.
But your problem is not easy to explain.
I translate your source,s3.mc to lisp.(nouns->diff)
(C10) translate_file("s3.mc");
So I look at s3.LISP,find that $RATSUBST at $EV is not expand.
This is a point that $RATSUBST must be expand to MFUNCTION-CALL
$RATSUBST,like as at first $print correctly. So I intend to use
local variable zz.
There is a difference between maxima-5.5 and maxima-5.6 at lisp level $EV.
According to manual,Ev is Definitions for Command Line.
This means that args is not evaled befor handling.
In Command Line this done by displa.
We need to know lisp level maxima for understanding this way.
For instance,
[a,b] is translated to ((MLIST SIMP) |$a| |$b|).
but you get error at command line,:lisp ((MLIST SIMP) |$a| |$b|);
(displa '((MLIST SIMP) |$a| |$b|)) is OK
(D12) f():=BLOCK([t,z:MAKE_ARRAY('ANY,2)],PRINT(SUM('DIFF('z[i],t),i,0,1)),
PRINT(RATSUBST(COS(t),'z[0],SUM('DIFF('z[i],t),i,0,1))))
(C13) f();
'DIFF('z[1],t,1)+'DIFF('z[0],t,1)
'DIFF(COS(t),t,1)+'DIFF('z[1],t,1)
(D13) 'DIFF(COS(t),t,1)+'DIFF('z[1],t,1)
(C14) Ev(%,diff);
(D14) -SIN(t)
(C15) to_lisp();
MAXIMA>(trace DISPLA)
MAXIMA>(run)
(C16) D13;
1> (DISPLA ((MLABLE) $D16
((MPLUS SIMP)
((%DERIVATIVE SIMP) ((|%z| SIMP ARRAY) 1) |$t| 1)
((%DERIVATIVE SIMP) ((%COS SIMP) |$t|) |$t| 1))))
(D16) 'DIFF(COS(t),t,1)+'DIFF('z[1],t,1)
<1 (DISPLA NIL)
At this point in command line ratsubst done,but at translate_file("s3.mc")
(SIMPLIFY
(MFUNCTION-CALL $PRINT
(SIMPLIFY
(MFUNCTION-CALL $RATSUBST
(SIMPLIFY (LIST '(%COS) |$t|))
(MAREF (TRD-MSYMEVAL |%z| '|%z|) 0)
((LAMBDA (|0| N)
(COND
((NOT (< N |0|))
(DO ((|$i| |0| (F1+ |$i|))
(#:|'DIFF('z[1],t,1)1168| 0
(ADD* #:|'DIFF('z[1],t,1)1168|
(SIMPLIFY
(LIST '(%DERIVATIVE)
(MAREF
(TRD-MSYMEVAL |%z| '|%z|)
|$i|)
|$t|)))))
((< N |$i|)
#:|'DIFF('z[1],t,1)1168|)))
((= N (F1- |0|)) 0)
(T (INTERVAL-ERROR '$SUM |0| N))))
0 1)))))
at first time expand is done. but at $Ev clase expand is not done.
(SIMPLIFY
(MFUNCTION-CALL $PRINT
(MEVAL '(($EV)
(($RATSUBST) ((%COS) |$t|) ((|%z| ARRAY) 0)
(($SUM)
((%DERIVATIVE) ((|%z| ARRAY) |$i|) |$t|)
|$i| 0 1))
$DIFF)))))
translated my answer ,by maxima5.5
at same point,
(SETQ |$zz|
(SIMPLIFY
(MFUNCTION-CALL $RATSUBST
(SIMPLIFY (LIST '(%COS) |$t|))
(MAREF (TRD-MSYMEVAL |%z| '|%z|) 0)
((LAMBDA (|0| N)
(COND
((NOT (< N |0|))
(DO ((|$i| |0| (F1+ |$i|))
(#:|COS(t)1152| 0
(ADD* #:|COS(t)1152|
(SIMPLIFY
(LIST '(%DERIVATIVE)
(MAREF
(TRD-MSYMEVAL |%z| '|%z|)
|$i|)
|$t|)))))
((< N |$i|) #:|COS(t)1152|)))
((= N (F1- |0|)) 0)
(T (INTERVAL-ERROR '$SUM |0| N))))
0 1))))
(SIMPLIFY (MFUNCTION-CALL $PRINT |$zz|))
(MEVAL '(($EV) |$zz| $DIFF)))
By this substitution after evaluate $RATSUBST,
$Ev works well,outside Command line.
maxima-5.6 more mysterious ,but work.
(SIMPLIFY (MFUNCTION-CALL $PRINT |$zz|))
(MEVAL '(($EV (5 "s3.mc" SRC)) |$zz| $DIFF)
I prefer maxima-5.5 at this point.
thanks
Gosei Furuya (go_furuya@infoseek.jp)