Magnitude of cross product
17 views (last 30 days)
Show older comments
I am trying to find the magnitude of the cross product C. I tried using norm but that didn't give me the write answer. Also, how would you simplify the k component, with trig dentities?
syms theta phi
r = [2.*sin(phi).*cos(theta) 2.*sin(phi).*sin(theta) 2.*cos(phi)]
P=diff(r,theta)
R=diff(r,phi)
C = cross(R,P)
0 Comments
Answers (1)
John D'Errico
on 19 Nov 2022
Edited: John D'Errico
on 19 Nov 2022
syms theta phi
r = [2.*sin(phi).*cos(theta) 2.*sin(phi).*sin(theta) 2.*cos(phi)];
P=diff(r,theta);
R=diff(r,phi);
C = cross(R,P)
Why not try simplify? It might work.
C = simplify(C)
So a simplify helped. Never assume that ALL computations end with a simplfy.
Norm can introduce some problems, because norm feels the need to introduce an absolute value in there.
norm(C)
But what is the 2-norm of a vector, but a sum of squares of elements, and then a sqrt?
normsquared = simplify(sum(C.^2))
And that is getting pretty close.
sqrt(normsquared)
And there is still a minor problem here, probably because MATLAB is not certain that sin(phi)^2 is a positive number. We can tell it that, by telling MATLAB that phi is itself real valued.
assume(phi,'real')
simplify(sqrt(normsquared))
That seems reasonable now. Symbolic tools just need a little gentle persuasion at times.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!