symbolic vs numeric optimisation

symbolic vs numeric optimisation - Ioan - Messaggi

#1 Pubblicato: 16/09/2012 16:32:13
Ioan

Ioan

1 apprezzamenti in 26 post.

Gruppo: 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,78 KiB) scaricato 1435 volta(e).
#2 Pubblicato: 17/09/2012 11:34:42
Martin Kraska

Martin Kraska

1.361 apprezzamenti in 2.275 post.

Gruppo: 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
Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
#3 Pubblicato: 17/09/2012 13:18:38
Ioan

Ioan

1 apprezzamenti in 26 post.

Gruppo: 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,08 KiB) scaricato 1400 volta(e).
#4 Pubblicato: 17/09/2012 19:29:32
Martin Kraska

Martin Kraska

1.361 apprezzamenti in 2.275 post.

Gruppo: 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


Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
#5 Pubblicato: 18/09/2012 02:29:56
Ioan

Ioan

1 apprezzamenti in 26 post.

Gruppo: User

Hello Martin,


Thanks a lot for your useful analysis.


Best regards,


Ioan
#6 Pubblicato: 20/10/2012 05:27:08
Martin Kraska

Martin Kraska

1.361 apprezzamenti in 2.275 post.

Gruppo: 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,29 KiB) scaricato 1409 volta(e).
Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
#7 Pubblicato: 22/10/2012 01:42:00
Geraldinehenry

Geraldinehenry

0 apprezzamenti in 1 post.

Gruppo: 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
  • Nuovi post
  • Nessun nuovo post