1 страниц (10 вхождений)
Possible Bug in Cases Formalism - Calculation ignores the if ranges in cases - Сообщения
#1 Опубликовано: 26.02.2025 06:46:32
My long-time experience with MATHCAD is probably causing me problems here.
I have two different Cases construction for the E-field. Neither is correct. I have shown images of the MATHCAD construction. If you enable the orange Cases calculation, the answer is correct for E1,E2 and E3a, but not E3b. If you disable the orange calculation, you only get the correct answer for E1 and E2. The late time E3a and E3b make no sense.
HEMP E1 PLUS E2 PLUS E3a PLUS E3b.sm (149 КиБ) скачан 35 раз(а).
It works as expected in MATHCAD as shown in this graph. Also, MATHCAD allows for the maximum time = 1000 seconds or more. The maximum time in SMATH is limited to 100 because in the cases construction it apparently calculates all formulas for the entire time range, independent of the ranges defined inside the cases construction. This seems to be a bug to me.

Thanks
Reg
I have two different Cases construction for the E-field. Neither is correct. I have shown images of the MATHCAD construction. If you enable the orange Cases calculation, the answer is correct for E1,E2 and E3a, but not E3b. If you disable the orange calculation, you only get the correct answer for E1 and E2. The late time E3a and E3b make no sense.
HEMP E1 PLUS E2 PLUS E3a PLUS E3b.sm (149 КиБ) скачан 35 раз(а).
It works as expected in MATHCAD as shown in this graph. Also, MATHCAD allows for the maximum time = 1000 seconds or more. The maximum time in SMATH is limited to 100 because in the cases construction it apparently calculates all formulas for the entire time range, independent of the ranges defined inside the cases construction. This seems to be a bug to me.
Thanks
Reg
Reg Curry
Loveland, CO
#2 Опубликовано: 26.02.2025 16:00:35
There's for sure a problem here:
(0.01≤el(t,k)) Always returns 0 or 1 depending on the actual value of el(t,k), therefore the following comparison is always 1, suppressing any subsequent condition.
I guess you were trying to check if the variable was within a range. In that case you have to chain single boolean comparisons with AND and OR operators(# and #|#). You can also use ltlt(#,#,#) from Custom Functions plugin to display it like #≤#≤#.
(0.01≤el(t,k))≤20
(0.01≤el(t,k)) Always returns 0 or 1 depending on the actual value of el(t,k), therefore the following comparison is always 1, suppressing any subsequent condition.
I guess you were trying to check if the variable was within a range. In that case you have to chain single boolean comparisons with AND and OR operators(# and #|#). You can also use ltlt(#,#,#) from Custom Functions plugin to display it like #≤#≤#.
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#3 Опубликовано: 26.02.2025 16:02:11
Finally got it working. Cases does indeed ignore the if ranges until after the calculation. I still consider this a bug.
HEMP E1 PLUS E2 PLUS E3a PLUS E3b.sm (144 КиБ) скачан 40 раз(а).
HEMP E1 PLUS E2 PLUS E3a PLUS E3b.sm (144 КиБ) скачан 40 раз(а).
Reg Curry
Loveland, CO
#4 Опубликовано: 26.02.2025 16:07:31
Davide,
Could you kindly show me how with an example?
Thanks,
Reg
Could you kindly show me how with an example?
Thanks,
Reg
Reg Curry
Loveland, CO
#5 Опубликовано: 26.02.2025 16:10:11
Davide,
Would it have the same issue if I had used if-else construction?
Thanks,
Reg
Would it have the same issue if I had used if-else construction?
Thanks,
Reg
Reg Curry
Loveland, CO
#6 Опубликовано: 26.02.2025 16:57:41
Hi reg,
Yes
Here you go:
![2025-02-26 09_52_32-SMath Solver - [booleans.sm].png](/ru-RU/file/3VcZhC/2025-02-26-09_52_32-SMath-Solver---_booleans_sm__png)
booleans.sm (6 КиБ) скачан 33 раз(а).
It is a common mistake. Thet's why we have parenthesis surrounding booleans, the program itself doesn't require them, but users initially miss the underlying logic.
WroteDavide,
Would it have the same issue if I had used if-else construction?
Yes
WroteDavide,
Could you kindly show me how with an example?
Here you go:
booleans.sm (6 КиБ) скачан 33 раз(а).
It is a common mistake. Thet's why we have parenthesis surrounding booleans, the program itself doesn't require them, but users initially miss the underlying logic.
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#7 Опубликовано: 26.02.2025 17:09:51
Davide,
Thanks much.
MATHCAD bites me again.
Reg
Thanks much.
MATHCAD bites me again.

Reg
Reg Curry
Loveland, CO
#8 Опубликовано: 28.02.2025 17:20:09
WroteDavide,
Thanks much.
MATHCAD bites me again.![]()
Reg
I'd propose that the custom functions plugin adds the ternary operators to the boolean palette. And perhaps also other functions where appropriate. That would make the plugin more inclusive for non-handbook readers.
Martin Kraska
Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#9 Опубликовано: 11.03.2025 21:10:38
WroteI'd propose that the custom functions plugin adds the ternary operators to the boolean palette. And perhaps also other functions where appropriate. That would make the plugin more inclusive for non-handbook readers.
Done, a beta plugin is available in the gallery.
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
6 пользователям понравился этот пост
churichuro 11.03.2025 22:17:00, sergio 11.03.2025 22:29:00, francesco rapuano 12.03.2025 06:16:00, Martin Kraska 12.03.2025 22:52:00, Alvaro Diaz Falconi 13.03.2025 12:08:00, Oscar Campo 18.03.2025 03:29:00
#10 Опубликовано: 11.03.2025 23:23:22
👍👍
Reg Curry
Loveland, CO
1 страниц (10 вхождений)
-
Новые сообщения
-
Нет новых сообщений