Some bugs calling composite functions with if() or cases()

Some bugs calling composite functions with if() or cases() - Сообщения

#1 Опубликовано: 18.11.2020 14:25:14
Alvaro Diaz Falconi

Alvaro Diaz Falconi

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

Группа: User

Hi. I don't know if this is a know one. I guess they are related to the fact that functions with if can neither be derived nor integrated. Notice that seems that there are a bug in cases() too.

FunctionBug.sm (13 КиБ) скачан 29 раз(а).
FunctionBug.pdf (48 КиБ) скачан 27 раз(а).

Best regards.
Alvaro.
1 пользователям понравился этот пост
sergio 18.11.2020 15:27:00
#2 Опубликовано: 18.11.2020 16:21:23
Alvaro Diaz Falconi

Alvaro Diaz Falconi

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

Группа: User

... and issues in composite functions with loops.

FunctionBug2.sm (17 КиБ) скачан 29 раз(а).
FunctionBug2.pdf (76 КиБ) скачан 30 раз(а).

Best regards.
Alvaro.



1 пользователям понравился этот пост
sergio 18.11.2020 16:45:00
#3 Опубликовано: 18.11.2020 16:47:05
Alvaro Diaz Falconi

Alvaro Diaz Falconi

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

Группа: User

Wrote

... and issues in composite functions with loops.

FunctionBug2.sm (17 КиБ) скачан 29 раз(а).
FunctionBug2.pdf (76 КиБ) скачан 30 раз(а).

Best regards.
Alvaro.





Debugging with trace(), what I see is that when calling g, f takes phi=1, (this is the first phi=1 in the output window) but don't do the loop. Calling f isolated shows another phi=1 and subsequent values for phi.

Clipboard01.jpg

With for(3) gives an error, so I can't debug that. Additionally, calling with for(4) seems to have the same behavior than while.

Clipboard02.jpg
#4 Опубликовано: 18.11.2020 17:48:24
Jean Giraud

Jean Giraud

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

Группа: User

Wrote

I don't know if this is a know one. I guess they are related to the fact that functions with if can neither be derived nor integrated. Notice that seems that there are a bug in cases() too.


1. You must assign "cases" like in your last example.
2. Before Davide introduced "cases" it was a damned job integrate
unless from discrete finite differences like in the old days.
The min(x) style [undocumented] is quite smart, mostly OK Simpson.

Cheers ... Jean

Integrate Discontinuous [min(x)].sm (16 КиБ) скачан 27 раз(а).

#5 Опубликовано: 19.11.2020 08:30:09
Davide Carpi

Davide Carpi

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

Группа: Moderator

As I've already mentioned here and there, assignments shouldn't be made inside cases() arguments, because:

Wrote

Please be careful however, since a symbolic evaluation to show the function content or a failed evaluation with an error triggered on the conditions leads to the evalution of all the options.
In general currently is better to use cases to host just dead content (numbers, strings, variables).



This is a downside that currently can't be prevented. As you can see making the assignment outside cases() works as expected.
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений