subexpr - Rewrite symbolic expression in terms of common subexpressions
Syntax
[Y, SIGMA] = subexpr(X, SIGMA)
[Y, SIGMA] = subexpr(X, 'SIGMA')
Description
[Y, SIGMA] = subexpr(X, SIGMA) or [Y, SIGMA] = subexpr(X, 'SIGMA') rewrites
the symbolic expression X in terms of its common
subexpressions.
Examples
The statements
h = solve('a*x^3+b*x^2+c*x+d = 0');
[r,s] = subexpr(h,'s')return the rewritten expression for t in r in
terms of a common subexpression, which is returned in s:
r =
s^(1/3) - b/(3*a) - (c/(3*a) - b^2/(9*a^2))/s^(1/3)
(c/(3*a) - b^2/(9*a^2))/(2*s^(1/3)) - s^(1/3)/2 - b/(3*a) - (3^(1/2)*i*(s^(1/3) + ...
(c/(3*a) - b^2/(9*a^2))/s^(1/3)))/2
(c/(3*a) - b^2/(9*a^2))/(2*s^(1/3)) - s^(1/3)/2 - b/(3*a) + (3^(1/2)*i*(s^(1/3) + ...
(c/(3*a) - b^2/(9*a^2))/s^(1/3)))/2
s =
((d/(2*a) + b^3/(27*a^3) - (b*c)/(6*a^2))^2 + (c/(3*a) - b^2/(9*a^2))^3)^(1/2) - ...
b^3/(27*a^3) - d/(2*a) + (b*c)/(6*a^2)
See Also
pretty, simple, subs
 | sort (sym) | | subs (sym) |  |
Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
Get the Interactive Kit