Not knowing what you are trying to do exactly, it is hard to say how to do
it.
But the program you display is a mess, mixing expressions that should be
evaluated
once, like declare, with others which you evaluate too many times.
nzfx(x,z):=freeof(x,z) and not(z=0);
matchdeclare(a,freeof(x));
matchdeclare(b,nzfx(x));
defrule(r1,dd(a*x+b),a*dd(x)+b);
You may also need to do something different to get dd(a*x) to a*dd(x), like
(not1(z):=not(is( z=1)),
matchdeclare(c,not1),
defrule(r2,dd(c*x),c*dd(x)))
> -----Original Message-----
> From: maxima-bounces at math.utexas.edu
> [mailto:maxima-bounces at math.utexas.edu] On Behalf Of Robert Marik
> Sent: Monday, March 03, 2008 12:05 AM
> To: maxima at math.utexas.edu
> Subject: Re: [Maxima] 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
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>