maxima - rules and patterns



Robert Marik wrote:

> I have one another (but closely related) question: I wish to define a 
> function trylinear(expr) which expands all subexpressions of expr of the 
> type derivace(a*x+b) into a*derivace(x)+b and keeps for example 
> derivace(x^2) intact. I tried the following code
> 
> trylinear(expr):=
> (declare(derivace,linear),expr:''expr, remove(derivace,linear),expr)
> 
> with several modifications (define instead of :=, '' on various places, 
> block and ev command) but I was not able to get expected results. Is 
> there any way to define the function trylinear to get required behavior?
> 


It after more attempts, the following code seems to work

trylinear(expr):=(ev(ev(exprlin:expr,declare(derivace,linear)), 
remove(derivace,linear)),remove(derivace,linear),exprlin)

Robert Marik