Rank: Advanced Member Groups: Registered
Joined: 15/04/2012(UTC) Posts: 1,988 Was thanked: 1126 time(s) in 723 post(s)
|
Originally Posted by: Ioan
Thanks for your answer. I replaced all norme(v) as you suggest (see attached file) and for case of symbolic optimisation the results are still wrongs (?).
Hello Ioan, ok, you are right. Replacing enorm is not sufficient to solve the problem. There is another one with trig operations. The problem is that sin(θ) is symbolically evaluated to zero, whereas the correct value is sqrt(2)/sqrt(3). If you ask SMath to simplify sin(acos(a)) you get sin(acos(a))=sqrt(1-a^2). If you use that instead of sin(θ) : Ridentity(3)+sqrt(1-({v.f*v.i}/{sqrt(v.f^2)*sqrt(v.i^2)})^2)*mat(0,-el(p,3),el(p,2),el(p,3),0,-el(p,1),-el(p,2),el(p,1),0,3,3)+(1-cos(θ))*(p*transpose(p)-identity(3)))then you get the correct symbolic result. R=mat(-{1-sqrt(3)}/{2*sqrt(3)},{1+sqrt(3)}/{2*sqrt(3)},1/sqrt(3),{1+sqrt(3)}/{2*sqrt(3)},-{1-sqrt(3)}/{2*sqrt(3)},-1/sqrt(3),-1/sqrt(3),1/sqrt(3),-1/sqrt(3),3,3)Symbolic evaluation seems to be not really reliable. Simplifications are not done even if SMath is well aware of that they could be done. An example is cos(θ)={mat(0,0,-1,3,1)*mat(1/sqrt(3),-1/sqrt(3),1/sqrt(3),3,1)}/{sqrt(mat(0,0,-1,3,1)^2)*sqrt(mat(1/sqrt(3),-1/sqrt(3),1/sqrt(3),3,1)^2)}which is not simplified although the following works: {mat(0,0,-1,3,1)*mat(1/sqrt(3),-1/sqrt(3),1/sqrt(3),3,1)}/{sqrt(mat(0,0,-1,3,1)^2)*sqrt(mat(1/sqrt(3),-1/sqrt(3),1/sqrt(3),3,1)^2)}=-1/sqrt(3)Also, if sin(acos(a))=sqrt(1-a^2) then the following cannot be correct: sin(θ)=sqrt({sqrt(mat(0,0,-1,3,1)^2)^2*sqrt(mat(1/sqrt(3),-1/sqrt(3),1/sqrt(3),3,1)^2)^2-1}/{sqrt(mat(0,0,-1,3,1)^2)^2*sqrt(mat(1/sqrt(3),-1/sqrt(3),1/sqrt(3),3,1)^2)^2})Here, perhaps the symbolic engine tries to apply the square to the dot product by applying the square to the factors individually. This yields 1 because both vectors are unit vectors. It might be correct for scalars but definitely not for vectors. BTW it does not help to use matrix formulation of the dot product el(transpose(v)*v,1). We had such issues already with SMath assuming matrix multiplication to be commutative. By the way, instead of your special function you could write v.i†v.f=mat(1/sqrt(3),1/sqrt(3),0,3,1). Best regards, Martin Kraska |