Cross product error with cases()

Cross product error with cases() - Limitation or Bug? - Сообщения

#1 Опубликовано: 18.05.2026 09:43:22
titus.nggm

titus.nggm

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

Группа: 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:

Цитата

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!
Отредактировано 18.05.2026 11:07:24
#2 Опубликовано: 19.05.2026 07:56:23
Martin Kraska

Martin Kraska

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

Группа: 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 Опубликовано: 19.05.2026 11:55:45
titus.nggm

titus.nggm

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

Группа: 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 КиБ) скачан 7 раз(а).
#4 Опубликовано: 19.05.2026 13:48:31
Davide Carpi

Davide Carpi

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

Группа: 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 КиБ) скачан 11 раз(а).
Отредактировано 19.05.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 Опубликовано: 19.05.2026 16:14:27
Alvaro

Alvaro

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

Группа: 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 КиБ) скачан 8 раз(а).

Best regards.
Alvaro.
#6 Опубликовано: 20.05.2026 06:09:16
titus.nggm

titus.nggm

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

Группа: 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 Опубликовано: 20.05.2026 09:03:15
Alvaro

Alvaro

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

Группа: 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 КиБ) скачан 3 раз(а).

Best regards.
Alvaro.
  • Новые сообщения
  • Нет новых сообщений