Magnitude of cross product

19 visualizzazioni (ultimi 30 giorni)
Amanda
Amanda il 18 Nov 2022
Modificato: John D'Errico il 19 Nov 2022
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)]
r = 
P=diff(r,theta)
P = 
R=diff(r,phi)
R = 
C = cross(R,P)
C = 

Risposte (1)

John D'Errico
John D'Errico il 19 Nov 2022
Modificato: John D'Errico il 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)
C = 
Why not try simplify? It might work.
C = simplify(C)
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)
ans = 
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))
normsquared = 
And that is getting pretty close.
sqrt(normsquared)
ans = 
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))
ans = 
That seems reasonable now. Symbolic tools just need a little gentle persuasion at times.

Community Treasure Hunt

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

Start Hunting!

Translated by