Magnitude of cross product

22 次查看(过去 30 天)
Amanda
Amanda 2022-11-18
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 = 

回答(1 个)

John D'Errico
John D'Errico 2022-11-19
编辑:John D'Errico 2022-11-19
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.

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by