MATLAB simplify complex expressions
28 views (last 30 days)
Show older comments
Dear MATLAB experts, I have one problem: i have huge expressions with the members like
... - 2*L1*nz*nx^2 - 2*L1*nz*ny^2 - 2*L1*nz*nz^2 ...
or
... - Cb*L3*Sb^2*ax*nx- Cb*L3*Sb^2*ay*ny- Cb*L3*Sb^2*az*nz ...
and I know that nx^2+ny^2+nz^2 = 1; or ax*nx+ay*ny+az*nz = 0;
but how I can explain this to MATLAB in order to simplify expressions Thanks for any help!
0 Comments
Answers (2)
Roger Stafford
on 9 Jan 2014
You can try the following. The two identities which you require,
nx^2+ny^2+nz^2 = 1 and ax*nx+ay*ny+az*nz = 0
reduce the number of degrees of freedom in nx, ny, nz, ax, ay, and az from six to four. Therefore make the following parametric substitutions for them in terms of the four parameters p, q, r, and t:
nx = cos(p)*sin(q)
ny = sin(p)*sin(q)
nz = cos(q)
ax = t*(sin(p)*cos(r)+cos(p)*cos(q)*sin(r))
ay = t*(-cos(p)*cos(r)+sin(p)*cos(q)*sin(r))
az = -t*sin(q)*sin(r)
It is easy to check that these must satisfy your two equations identically. Then attempt to simplify these expressions in terms of the four variables, p, q, r, and t.
Your final simplified form may still contain some or all of these four parameters. I think it is quite possible in the problem you pose that a simplified form of your original expressions will probably have to be in a parametric form such as this in view of your identity requirements.
See Also
Categories
Find more on Lighting, Transparency, and Shading in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!