Function with range results

Function with range results - Сообщения

#1 Опубликовано: 28.09.2023 11:52:31
S0lo

S0lo

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

Группа: User

Hi, Is there a reason why I'm getting those obviously wrong results?

wr.jpg
#2 Опубликовано: 28.09.2023 12:35:00
Alvaro Diaz Falconi

Alvaro Diaz Falconi

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

Группа: User

Hi. Looks like a bug in the "implicit scalar expansion" according to the expression in matlab for vectorization. Use explicit SMath's vectorize as workaround.

Clipboard01.png

Best regards.
Alvaro.
#3 Опубликовано: 28.09.2023 13:50:33
S0lo

S0lo

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

Группа: User

Thank you very much. At least there is a work around!
#4 Опубликовано: 28.09.2023 19:59:28
Alvaro Diaz Falconi

Alvaro Diaz Falconi

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

Группа: User

Wrote

Hi. Looks like a bug ...


Or not. It depends on how x^3 is interpreted. If the usual recursive definition is used, x^3 = (x^2)*x, then x^2 = x*x would be a dot product, while x^3 = (x*x) *x would be the product of a scalar times a vector, and the SMath result would be correct, although perhaps not the 'expected' one.

Clipboard01.png

Best regards.
Alvaro.
#5 Опубликовано: 29.09.2023 12:13:04
⚜ Kenny Lemens, P.E. ᵂᴵ

⚜ Kenny Lemens, P.E. ᵂᴵ

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

Группа: User

Greetings,

Just as a note of 'Good Programming'; don't use the same variable when defining your declaring your function as you are passing into said variable for evaluation.

For example:
  • instead of f(x):=x³ and x:=[0,1..3] and f(x)=▮;
  • declare f(_z):=_z³ and x:=[0,1..3] and f(x)=▮;


This way you can keep local and global variables separate and avoid confusion. I've had instances where local variables became global, and I accidently used a global variable locally. Else, you end up asking yourself "which x is being using? x as in the variable or x as in the parameter of the function?"


May this be of Good Help;
⚜ Kenny Lemens, P.E. ᵂᴵ
"No matter where you go, there you are." -Buckaroo BanzaiHotkeys: https://en.smath.com/forum/resource.ashx?a=45771&b=2
2 пользователям понравился этот пост
ioan92 29.09.2023 12:55:00, NDTM Amarasekera 29.09.2023 13:46:00
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений