failing evaluation under vectorize()

failing evaluation under vectorize() - Mensajes

#1 Publicado: 22/11/2023 1:22:45
Martin Kraska

Martin Kraska

1.361 me gusta en 2.275 mensajes.

Grupo: Moderator

Why does the vectorize operation fail while it seems to be safe to use an explicit loop?

6-2-Bug.sm (27,78 KiB) descargado 1660 vez(es).
2023-11-21 18_18_50-SMath Solver - [6-2-Bug.sm_].png
Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
#2 Publicado: 22/11/2023 2:41:12
Alvaro

Alvaro

1.139 me gusta en 1.805 mensajes.

Grupo: User

Wrote

Why does the vectorize operation fail while it seems to be safe to use an explicit loop?


Hi Martin. Because you have just only one function which can't be vectorized: the norme or dot product of vectors.

vec.png

Best regards.
Alvaro
A 3 usuarios les gustó este mensaje
sergio 22/11/2023 4:05:00, Martin Kraska 22/11/2023 4:36:00, ioan92 22/11/2023 4:58:00
#3 Publicado: 22/11/2023 4:35:34
Martin Kraska

Martin Kraska

1.361 me gusta en 2.275 mensajes.

Grupo: Moderator

Is that just by observation or is there a fundamental obstacle?
Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
#4 Publicado: 22/11/2023 6:57:58
Alvaro

Alvaro

1.139 me gusta en 1.805 mensajes.

Grupo: User

Wrote

Is that just by observation or is there a fundamental obstacle?



Hi. I guess that it is fundamental.

Some notes about how other CAS handle this issue.

Pretty old matlab version, from its symbolic toolbox

v1.png

The help page from the newest version

v2.png

So, it looks like they have some issues with automatic vectorization.

With maple it is very uncomfortable, you need to use map even for simple cases

map.png

Wolfram's solution is very practical: Function with attribute 'Listable' expands over lists

math.png

But for make a table you actually need a loop or the Mathematica's Map function.

Best regards.
Alvaro.
A 2 usuarios les gustó este mensaje
ioan92 23/11/2023 19:35:00, Martin Kraska 25/11/2023 23:04:00
#5 Publicado: 25/11/2023 20:15:21
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: User

Wrote

Why does the vectorize operation fail while it seems to be safe to use an explicit loop ?


Set the demand in local definition mode ...
new(t):=|a(t)
vectorize and equate


6-2-Bug Doctored.sm (29,54 KiB) descargado 1695 vez(es).
A 1 usuarios les gustó este mensaje
Martin Kraska 25/11/2023 23:04:00
#6 Publicado: 25/11/2023 23:17:47
Martin Kraska

Martin Kraska

1.361 me gusta en 2.275 mensajes.

Grupo: Moderator

Thanks Alvaro and Jean. Here is a reduced working example.

When a scalar function involves scalar products then it must be defined in a line()-block in order to be vectorize()able.

Worksheet13.png
Worksheet13.sm (5,9 KiB) descargado 1762 vez(es).
Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
A 1 usuarios les gustó este mensaje
Oscar Campo 26/11/2023 18:21:00
  • Nuevos mensajes
  • Sin mensajes nuevos