You have not said how you declared f,A,B,C.
You seem to be defining the same rule twice, but maybe that's just your
example.
An alternative to the first rule is likely to be
declare(f,linear).
............
Matching sums by a pattern like A+B in Maxima is generally a bad idea,
although a pattern like A*x^2+B*x+C can make sense.
Given the pattern f(A+B) , is it supposed to match f(x+y), f(x+y+z), f(x)?
The answer is, it matches all of them, assuming matchdeclare([A,B],true).
Unfortunately the matches look like this A=0, B=x+y; A=0, B=x+y+z; A=0,
B=x;
I doubt that you had that in mind, although in each case the answer is
mathematically consistent.
If you have a more complete idea of what you want to accomplish, you can
write a program to do what you want. For example, you could write a program
that matches exactly and only the sum of two items, and use that. E.g.
sum2(x):=is (not(atom(x)) and inpart(x,0)= "+" and 2 =length(x));
matchdeclare(APLUSB, sum2)
then you have a chance of winning. Though I think that you might want to
do something more sophisticated, like sum_2_or_more ...
RJF
-----Original Message-----
From: maxima-admin at math.utexas.edu [mailto:maxima-admin at math.utexas.edu] On
Behalf Of bantone at web.de
Sent: Sunday, June 18, 2006 10:31 AM
To: maxima at math.utexas.edu
Subject: sums in defrule (partitions sum)
Hi,
If I want to define a rule to rewrite an expression
which contains a sum like in this examples:
defrule(myr1, f(A+B), f(A)+g(B));
defrule(myr1, sin(A+B)*sin(A-B), cos(A)^2-cos(C)^2);
I get the warning:
B + (- A 1) partitions `sum'
and applying the rule does not work.
What is the problem with rules like that?
How could those rewriting rules be defined in maxima?
gr.
Anton
_______________________________________________
Maxima mailing list
Maxima at math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima