How can I write my own factorization rules?

1 view (last 30 days)
Hello!
To start with, I am very new to Matlab. In fact, I have just started learning basics so please excuse my question. What I am trying to do is to study the way how simplification works in MuPAD using following code as an example:
myfact := funcenv(myfact):
myfact::type := "myfact":
FactorizationRules := newDomain("FactorizationRules"):
FactorizationRules::myfact := [
Rule( hold(myfact(x^2 - y^2)), myfact((x - y)*(x + y)) )
]
f1 := hold( (a^2 - b^2) )
Simplify(myfact(f1), RuleBase = FactorizationRules, OutputType = "Proof")
Input was myfact(a^2 - b^2) Applying the rule myfact(x^2 - y^2) -> (x + y)*(x - y) gives (a + b)*(a - b) END OF PROOF
f2 := hold( 1/(a^2 - b^2) )
Simplify(myfact(f2), RuleBase = FactorizationRules, OutputType = "Proof")
Input was myfact(1/(a^2 - b^2)) END OF PROOF
As you can see, there is no intention to apply any rule to the second polynomial (f2) even though the first one (f1) is successfully simplified. The only difference between these two polynomials, in my opinion, is that the expression that I want to be simplified ((a^2 - b^2)) goes from the numerator to the denominator.
I expected something like this:
f2 := hold( 1/(a^2 - b^2) )
Simplify(myfact(f2), RuleBase = FactorizationRules, OutputType = "Proof")
Input was myfact(1/(a^2 - b^2)) Applying the rule myfact(x^2 - y^2) -> (x + y)*(x - y) gives 1 / (x + y)*(x - y)
Help me please to modify my rules in order to being able to simplify the second polynomial (f2).
Thank you.

Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!