Collecting terms / factoring out multiplied terms
Show older comments
I'm trying to convert a cartesian line element to spherical polar line element.
I'm stuck at collecting/factoring out multiplied terms from a big equation; here's what I have so far;
LineElement = collect((dx) + (dy) + (dz), [dr,dtheta*r,r * sin(theta)*dphi]); (I have all of these defined in syms accordingly);
output: (cos(theta) + cos(phi)*sin(theta) + sin(phi)*sin(theta))*dr + dtheta*r*cos(phi)*cos(theta) - dphi*r*sin(phi)*sin(theta) - dtheta*r*sin(theta) + dphi*r*cos(phi)*sin(theta) + dtheta*r*cos(theta)*sin(phi)
dr is factored out nicely, but I want the same to happen with r*dtheta and r*sin(theta)dphi
Please help as I have no idea what I'm doing.
Answers (1)
John D'Errico
on 30 Sep 2019
0 votes
Be serious. That is not big. There are some things (this is one of them) that are far simpler to do by pencil and paper than to use a computer.
Categories
Find more on Mathematics in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!