symbolic vs numeric optimisation

symbolic vs numeric optimisation - Ioan - Messages

#1 Posted: 9/16/2012 4:32:13 PM
Ioan

Ioan

1 likes in 26 posts.

Group: User

Hi Andrey,


Here attached I have an other case where the symbolic optimisation gives a completely false results.
Hoping to serve for yours futures improvements.


Best regards,


Ioan
rotsys.sm (22 KiB) downloaded 55 time(s).
#2 Posted: 9/17/2012 11:34:42 AM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

Hello

The function norme(v) is buggy (known issue in the forum). Use [MATH]sqrt(v^2)[/MATH] instead if v is a single column as in your example. Works with both numeric and symbolic optimization.

Best regards, Martin Kraska
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#3 Posted: 9/17/2012 1:18:38 PM
Ioan

Ioan

1 likes in 26 posts.

Group: User

Hello Martin,


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 (?).


Best regards,


Ioan

rotsys2.sm (27 KiB) downloaded 39 time(s).
#4 Posted: 9/17/2012 7:29:32 PM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

Wrote



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 [MATH]sin(θ)[/MATH] is symbolically evaluated to zero, whereas the correct value is [MATH]sqrt(2)/sqrt(3)[/MATH]. If you ask SMath to simplify [MATH]sin(acos(a))[/MATH] you get [MATH]sin(acos(a))=sqrt(1-a^2)[/MATH]. If you use that instead of [MATH]sin(θ)[/MATH] :

[MATH lang=ENG]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)))[/MATH]

then you get the correct symbolic result.

[MATH lang=ENG]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)[/MATH]

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

[MATH lang=ENG]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)}[/MATH]

which is not simplified although the following works:

[MATH lang=ENG]{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)[/MATH]


Also, if [MATH]sin(acos(a))=sqrt(1-a^2)[/MATH] then the following cannot be correct:

[MATH lang=ENG]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})[/MATH]

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 [MATH lang=ENG]el(transpose(v)*v,1)[/MATH]. We had such issues already with SMath assuming matrix multiplication to be commutative.


By the way, instead of your special function you could write [MATH lang=ENG]v.i†v.f=mat(1/sqrt(3),1/sqrt(3),0,3,1)[/MATH].

Best regards, Martin Kraska


Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#5 Posted: 9/18/2012 2:29:56 AM
Ioan

Ioan

1 likes in 26 posts.

Group: User

Hello Martin,


Thanks a lot for your useful analysis.


Best regards,


Ioan
#6 Posted: 10/20/2012 5:27:08 AM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

Hi,

here is one more example for incomplete symbolic simplification in trig context. SMath knows that sin(30° ) equals 1/2 but can't find out symbolically that cosec(30° )=1/sin(30° ) is 2.

Best regards, Martin Kraska
trig.sm (9 KiB) downloaded 37 time(s).
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#7 Posted: 10/22/2012 1:42:00 AM
Geraldinehenry

Geraldinehenry

0 likes in 1 posts.

Group: User

Wrote

Hi,

here is one more example for incomplete symbolic simplification in trig context. SMath knows that sin(30° ) equals 1/2 but can't find out symbolically that cosec(30° )=1/sin(30° ) is 2.

Best regards, Martin Kraska


Wow, so difficult to me
  • New Posts New Posts
  • No New Posts No New Posts