symbolic vs numeric optimisation

symbolic vs numeric optimisation - Ioan - Сообщения

#1 Опубликовано: 16.09.2012 16:32:13
Ioan

Ioan

1 сообщений из 26 понравились пользователям.

Группа: 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 КиБ) скачан 55 раз(а).
#2 Опубликовано: 17.09.2012 11:34:42
Martin Kraska

Martin Kraska

1222 сообщений из 2150 понравились пользователям.

Группа: 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 Опубликовано: 17.09.2012 13:18:38
Ioan

Ioan

1 сообщений из 26 понравились пользователям.

Группа: 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 КиБ) скачан 39 раз(а).
#4 Опубликовано: 17.09.2012 19:29:32
Martin Kraska

Martin Kraska

1222 сообщений из 2150 понравились пользователям.

Группа: 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 Опубликовано: 18.09.2012 02:29:56
Ioan

Ioan

1 сообщений из 26 понравились пользователям.

Группа: User

Hello Martin,


Thanks a lot for your useful analysis.


Best regards,


Ioan
#6 Опубликовано: 20.10.2012 05:27:08
Martin Kraska

Martin Kraska

1222 сообщений из 2150 понравились пользователям.

Группа: 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 КиБ) скачан 37 раз(а).
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#7 Опубликовано: 22.10.2012 01:42:00
Geraldinehenry

Geraldinehenry

0 сообщений из 1 понравились пользователям.

Группа: 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
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений