Problems with sum(1)

Problems with sum(1) - Сообщения

#1 Опубликовано: 30.06.2021 06:46:50
Martin Kraska

Martin Kraska

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

Группа: Moderator

What is wrong with the innocent use of sum(1)? I expected to get the sum of all elements.

Also, the complaint of "a not defined" doesn't make sense, when the numeric value after dividing the result by the unit is pure numeric.

sum1.png
sum1.sm (8 КиБ) скачан 54 раз(а).
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#2 Опубликовано: 30.06.2021 08:51:40
Jean Giraud

Jean Giraud

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

Группа: User

Wrote

What is wrong with the innocent use of sum(1)?



Sum.PNG

#3 Опубликовано: 30.06.2021 10:17:51
Alvaro Diaz Falconi

Alvaro Diaz Falconi

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

Группа: User

Hi Martin. "a" is not assumed as complex, like in maple, thus don't populate across dot products. (I remember some comment from Andrey about that somewhere). You need to use vectorize.

Clipboard01.jpg

But ... (always there are one but)

Clipboard02.jpg

Finally, units are assumed as reals, even it could be remains undefined:

Clipboard03.jpg

sum1.sm (14 КиБ) скачан 47 раз(а).

Best regards.
Alvaro.
1 пользователям понравился этот пост
sergio 30.06.2021 13:45:00
#4 Опубликовано: 30.06.2021 14:48:44
Jean Giraud

Jean Giraud

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

Группа: User

BigBug.PNG

In the switch from MCD 2000 => MCD 11,
Tom had similar observation in dot product behavior.
#5 Опубликовано: 30.06.2021 16:53:15
Martin Kraska

Martin Kraska

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

Группа: Moderator

Wrote

Hi Martin. "a" is not assumed as complex, like in maple, thus don't populate across dot products. (I remember some comment from Andrey about that somewhere). You need to use vectorize.



At times I forget the survival rule "don't trust symbolic evaluation"... Too bad that it is the default.

If undefined variables were assumed to be non-scalar, then simplifying (a*b ) *c to a*b*c would be illegal.

I am aware of using units as an enabler of universal happiness. Yet,usually they are pre-occupied in an un-clearable way with some content, which makes it awkward to use them as symbolic variables. That's why I use 'a.0 instead of just 'a in the above example.

It is a pain to explain these things to students.

Worksheet3.png
Worksheet3.sm (9 КиБ) скачан 56 раз(а).
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
1 пользователям понравился этот пост
sergio 30.06.2021 17:11:00
#6 Опубликовано: 01.07.2021 00:04:29
Alvaro Diaz Falconi

Alvaro Diaz Falconi

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

Группа: User

Wrote


At times I forget the survival rule "don't trust symbolic evaluation"... Too bad that it is the default.



Good rule, annotated.

Wrote


I am aware of using units as an enabler of universal happiness.



I agree that the existence theorem for that statement is true, but I sincerely hope that the uniqueness theorem is not.

Here a workaround:

Clipboard01.jpg

As explanation for your students try to show that in other languages you need to introduce another operator for vectorial (or matricial and tensorial) products: https://reference.wolfram.com/language/ref/Dot.html . In mathematica Dot operator is {a}.{b}, not {a}*{b}. Also in old maple versions, whith linalg, you need to call evalm (eval for matrices) for actually do matrix operations.

Best regards.
Alvaro.
1 пользователям понравился этот пост
sergio 01.07.2021 04:49:00
#7 Опубликовано: 01.07.2021 04:27:45
Martin Kraska

Martin Kraska

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

Группа: Moderator

Wrote


As explanation for your students try to show that in other languages you need to introduce another operator for vectorial (or matricial and tensorial) products: https://reference.wolfram.com/language/ref/Dot.html . In mathematica Dot operator is {a}.{b}, not {a}*{b}. Also in old maple versions, whith linalg, you need to call evalm (eval for matrices) for actually do matrix operations.

Best regards.
Alvaro.



Are you aware of any programming language which produces the same rubbish (the above (a*b)*c example) without warning?

I present SMath Studio to the students as a means for performing and documenting engineering calculations. I try to avoid problems which I would not have without SMath Studio.

Yet, some problems can't be avoided, as they are related to physical understanding, just like the units of temperature and change of temperature or the difference between angular velocity and frequency.





Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#8 Опубликовано: 01.07.2021 05:10:15
Alvaro Diaz Falconi

Alvaro Diaz Falconi

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

Группа: User

Wrote


Are you aware of any programming language which produces the same rubbish (the above (a*b)*c example) without warning?



Nope.

Wrote


I present SMath Studio to the students as a means for performing and documenting engineering calculations. I try to avoid problems which I would not have without SMath Studio.

Yet, some problems can't be avoided, as they are related to physical understanding, just like the units of temperature and change of temperature or the difference between angular velocity and frequency.



Me too. It's I was pointing out how matrix and vector products handle mathematics and maple just to indicate that it is probably not possible to implement them without introducing a different notation than the one used for the product between two scalars, real or complex. And point that out to the students. And I think I did not explain very well why I pointed out why I made those notes.

It is incredible how many errors can be seen in experienced engineers (let alone students) because they have done some simple calculations in excel or some other software, including matlab and mathematica (maple seems to be more reluctant to allow very silly errors) just for mixing unconverted units, getting mixed up with parentheses in simple but long expressions, making a mistake in some sign or many other causes. Well, I must confess that I include myself among those who do not trust the calculations I have done in Excel ... well, add matlab. Mathematica is complicated enough to prevent me from making silly mistakes, it just lets me make less noticeable mistakes.

And you are absolutely right to point out that it is really a shame that SMath has such errors.

I also use the rule: Don't trust linear algebra calculations in SMath (numeric or symbolic):

Clipboard01.jpg

It is sometimes difficult to justify using a program that miscalculates the rank of a matrix only filled with ones and zeros.

Best regards.
Alvaro.
#9 Опубликовано: 01.07.2021 07:38:14
Jean Giraud

Jean Giraud

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

Группа: User

Wrote

What is wrong with the innocent use of sum(1) ?
I expected to get the sum of all elements.


Sanity code Greville Pseudo-Centroid.

PseudoCentroid.PNG
#10 Опубликовано: 01.07.2021 08:39:27
overlord

overlord

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

Группа: Moderator

Putting variable into a matrix is also usable.

Regards

2021-07-01_14-37.png
#11 Опубликовано: 01.07.2021 10:15:55
Martin Kraska

Martin Kraska

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

Группа: Moderator

Wrote

Putting variable into a matrix is also usable.

Regards

2021-07-01_14-37.png



yes, this is another workaround just like using units or the vectorize function. Unfortunately, all not obvious for unexperienced users.



Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#12 Опубликовано: 01.07.2021 10:20:21
Jean Giraud

Jean Giraud

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

Группа: User

On the other hand of the discussion ...
the algebra of the project may not be commutative.
2D rotation, 3D rotation, Cholesky polyfit ...

Poly 0 Read First Edu.sm (37 КиБ) скачан 56 раз(а).
#13 Опубликовано: 01.07.2021 10:31:12
Jean Giraud

Jean Giraud

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

Группа: User

Wrote

the algebra of the project may not be commutative.



NotCommutative.PNG
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений