Reputation: 111
I want to define a rule for a symbol, say "a", such as: $a^3=ba^2+ca+d$ and force maple to symplify all my expressions containing $a$ to an expression containing powers of $a$ only up to the square. I have tried "applyrule" but even for $a^4$ maple seems not able to do it. Is there a way to force such simplification rule?
Upvotes: 1
Views: 496
Reputation: 7246
You can accomplish this using simplification with side-relations, which means using the simplify
command with the rule appearing in a particular form of optional argument.
For example,
restart;
rule:=a^3=b*a^2+c*a+d:
simplify(a^2, {rule});
2
a
simplify(a^3, {rule});
2
a b + a c + d
simplify(a^4, {rule});
2 2
(b + c) a + (b c + d) a + b d
We can demonstrate the correctness of the previous result using algsubs
. Note that algsubs
may be applied more than once, to accomplish that.
algsubs(rule, a^4);
3 2
a b + a c + a d
algsubs(rule, %);
2 2
(b + c) a + (b c + d) a + b d
ans1 := simplify(a^7, {rule}):
ans2 := algsubs(rule, algsubs(rule, algsubs(rule, algsubs(rule, a^7)))):
normal(ans1 - ans2);
0
Note that the simplification with side-relations can also work for expressions which are not just polynomials (in which case it would be even harder to utilize algsubs
to get the same effect).
expr := sin(a^4) + a^3 + sqrt(a^7);
4 3 7 1/2
expr := sin(a ) + a + (a )
simplify(expr, {rule}):
lprint(%);
b*a^2+c*a+d+sin((b^2+c)*a^2+(b*c+d)*a+b*d)+
((b^5+4*b^3*c+3*b^2*d+3*b*c^2+2*c*d)*a^2+
(b^4*c+b^3*d+3*b^2*c^2+4*b*c*d+c^3+d^2)*
a+d*(b^4+3*b^2*c+2*b*d+c^2))^(1/2)
Upvotes: 1
Reputation: 1471
simplify(a^4, {a^3 = b*a^2+c*a+d});
This is called "simplify with side relations." The curly braces around the second argument are essential.
Upvotes: 0