Simplifying by replacing expressions?



Okay, now I get a different error (which I also don't really understand).

(C47) constWalk( raw_org, P, E_S, E_AS, E_BS, E_Org );
Improper name or value in functional position:
E_AS j + E_Org
#0: cw(expr=(E_AS*j+E_Org)[q])
#1: cw(expr=(E_AS*j+E_Org)[q]-P[q])
#2: cw(expr=2*(E_S[3]^2+E_S[2]^2+E_S[1]^2)*((E_AS*j+E_Org)[q]-P[q]))
  -- an error.  Quitting.  To debug this try DEBUGMODE(TRUE);)

Also, how do I display the output of my expression in a non-formatted 
way (like the input way)?  Then I could cut-n-paste the entire 
expression here.


Albert Reiner wrote:
> [edA-qa mort-ora-y <eda-qa@disemia.com>, Sun, 26 Sep 2004 13:29:43 +0200]:
> 
>>Trying your code I get the following error (which at first glance has
>>nothing to do with what I'm trying to do, so I don't know if it is
>>your code that does it, or a Maxima problem in general):
>>
>>(C569) constWalk( sqrt(a-j^2) );
>>Wrong number of arguments to "^"
>>#0: cw(expr=SQRT(-j^2+(E_0[3]-P[3])^2+(E_0[2]-P[2])^2+(E_0[1]-P[1])^2))
>>#1:
>>constWalk(expr=SQRT(-j^2+(E_0[3]-P[3])^2+(E_0[2]-P[2])^2+(E_0[1]-P[1])^2),consts=[])
>>  -- an error.  Quitting.  To debug this try DEBUGMODE(TRUE);)
> 
> 
> The problem is applying INpart #0 to the ARGS.  You can either replace
> INPART by PART, or add INFLAG: TRUE to the block of constWalk, but not
> both.  So, e.g.,
> 
> constWalk(expr,[consts]) :=
>   block([found: [], nfound: 0],
>     [second(cw(expr)), found]) ;
> cw(expr) :=
>   if atom(expr)
>   then     if member(expr, consts)
>     then [true, expr]
>     else [false, expr]
>   else
>     block([foo : maplist(cw, args(expr))],
>         if apply("and", maplist(first, foo))
>         then block([sym : concat(const, nfound: nfound + 1)],
>                 found: cons([sym, expr], found),
>                 consts: cons(sym, consts),
>                 [ true, sym ])
>         else [ false, apply(part(expr,0), maplist(second, foo)) ]) ;
>                             ^^^^
> -----------------------------'
> 
> should work.
> 
> HTH,
> 
> Albert.
> 
> 
> 
> 


-- 
edA-qa mort-ora-y
Idea Architect
http://disemia.com/