Cross product error with cases()

Cross product error with cases() - Limitation or Bug? - Mensajes

#1 Publicado: 18/5/2026 9:43:22
titus.nggm

titus.nggm

0 me gusta en 4 mensajes.

Grupo: User

Hello everyone,

I am working on a time-dependent FEM model in SMath and get the error “Cross product is only allowed for vectors with three components” when trying to symbolically evaluate or integrate expressions involving vectors defined via cases(). Numerical evaluation and plotting work correctly, but symbolic evaluation/integration fails although the vectors should always have dimension 3×1. I would like to understand whether this is a limitation/bug related to cases() and vector typing, and how to force purely numerical integration in such models.

I built a small FEM model in SMath consisting of springs, a rigid body, and fixed supports representing ball screw drives. The loads and motions are time-dependent, and the motion cycle is defined using `cases()`.

My problem is the following:

As soon as I try to symbolically evaluate an expression or use the built-in integral function together with my time-dependent load-vector, I get the error:

Citar

Cross product is only allowed for vectors with three components



image.png

Here is a simplified version of the relevant definitions:

image.png

image.png

image.png

image.png

Everything works correctly for specific time values:

image.png

This returns valid numerical values.

Plotting also works without any problems. The issue only appears when I try to integrate `F.a.global(t)` numerically to calculate an equivalent force.

My assumption is that the built-in integral function first tries to process the expression symbolically instead of evaluating it numerically point by point. Because of that, SMath seems to lose the information that the result of `cases()` is always a 3D vector.

From my point of view, the actual calculations are correct, since:


  • numerical evaluation at specific times works,
  • plotting works,
  • only symbolic evaluation/integration fails.


My questions are:

  1. Is this a known issue when using `cases()` with vectors?
  2. Is there a way to explicitly tell SMath that `D(t)` is always a 3×1 vector?
  3. Is there a clean way to force purely numerical integration in SMath point by point with the built-in int() function?

Thank you very much for any help!
Editado 18/5/2026 11:07:24
#2 Publicado: 19/5/2026 7:56:23
Martin Kraska

Martin Kraska

1.361 me gusta en 2.275 mensajes.

Grupo: Moderator

Try the simp() function in https://github.com/sn-code-inside/Technische-Mechanik-mit-SMath/blob/main/Auflage%201/4.2.sm. Without the worksheet, however, it is pure guessing what might help.

grafik.png
Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
#3 Publicado: 19/5/2026 11:55:45
titus.nggm

titus.nggm

0 me gusta en 4 mensajes.

Grupo: User

I tried to build a minimal working example. The simp() function did not help but thank you very much.

Crossproduct + integral error.sm (14,5 KiB) descargado 524 vez(es).
#4 Publicado: 19/5/2026 13:48:31
Davide Carpi

Davide Carpi

1.443 me gusta en 2.936 mensajes.

Grupo: Moderator

I don't think cases() has a role in this issue. More like integration and processing order probably (see the alternate definition of F(t) without cases() involved).

Crossproduct + integral error_01.sm (31,71 KiB) descargado 568 vez(es).
Editado 19/5/2026 13:49:58
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#5 Publicado: 19/5/2026 16:14:27
Alvaro

Alvaro

1.139 me gusta en 1.805 mensajes.

Grupo: User

Hi. One of the issues is with cross product. It must to "see" two explicit vectors as arguments. Martin deal with that in several ways somewhere in this forum.

Using the Davide approach, but modifying F(t) : vectorize( ... ).

Just another thing: XYPlot seems to have a bug evaluating inequalities. Counting squares, the first and last integrals looks good in the native SMath plot.

image.png

Crossproduct + integral error_02.sm (31,22 KiB) descargado 536 vez(es).

Best regards.
Alvaro.
#6 Publicado: 20/5/2026 6:09:16
titus.nggm

titus.nggm

0 me gusta en 4 mensajes.

Grupo: User

But by the definition of F(t), shouldn’t the force in the x-direction (the first component) switch from 0 to 1, then back to 0, then to −1, every 2 seconds?
image.png
So the XY plot would be correct, and the integral from 0 to 8 would be incorrect.

image.png
#7 Publicado: 20/5/2026 9:03:15
Alvaro

Alvaro

1.139 me gusta en 1.805 mensajes.

Grupo: User

Yes, you're right. I assumed that if there was a bug, it had to be in the plugin and not the program. But incredibly, XYPlot's calculation engine is the correct one, not SMath's. Here's a workaround: redefine the function "little than little equal", using "product" instead of "and".

image.png

Now plots and integrals are ok

image.png

Crossproduct + integral error_03.sm (31,05 KiB) descargado 555 vez(es).

Best regards.
Alvaro.
A 1 usuarios les gustó este mensaje
titus.nggm 26/5/2026 5:17:21
#8 Publicado: 27/5/2026 8:12:09
titus.nggm

titus.nggm

0 me gusta en 4 mensajes.

Grupo: User

ok thank you all <3 , this is some weird behaviour
  • Nuevos mensajes
  • Sin mensajes nuevos