If I start with the following symbolic expression:
a^2 + 2*a*b + b^2
Then run simplify
(or factor
), I get the expected result:
>> simplify(a^2 + 2*a*b + b^2)
(a + b)^2
Now when I run the same example, but adding another term, no factorisation occurs:
>> simplify(a^2 + 2*a*b + b^2 + 1)
a^2 + 2*a*b + b^2 + 1
How can I get these functions to return the more practical version of this expression ((a + b)^2 + 1
)? I have tried all of the obvious options with these functions (like 'Steps'
, 'IgnoreAnalyticConstraints'
, etc.) but to no avail.
Context: I have the expression ax^2 - 2*ax*bx + bx^2 + ay^2 - 2*ay*by + by^2
which I need to convert back into (ax - bx)^2 + (ay - by)^2
so it can then be treated correctly as r^2
. I know I could use some blunt substitution rules, but for something so simple I feel like I'm missing an obvious 'non-hack' solution.
R
and useRyacas
. I haven't found any tool to callyacas
from Matlab. – Cyanogen