Collecting terms / factoring out multiplied terms

3 views (last 30 days)
Zuzanna
Zuzanna on 30 Sep 2019
Commented: Zuzanna on 30 Sep 2019
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
John D'Errico on 30 Sep 2019
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.
  1 Comment
Zuzanna
Zuzanna on 30 Sep 2019
It's not my choice, it's an assignment. I've done it by pencil already. I'm looking for help, that's all.

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!