1 страниц (10 вхождений)
Possible Bug in Cases Formalism - Calculation ignores the if ranges in cases - Сообщения
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 КиБ) скачан 202 раз(а).
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 КиБ) скачан 202 раз(а).
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 CurryLoveland, CO
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
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 КиБ) скачан 205 раз(а).
HEMP E1 PLUS E2 PLUS E3a PLUS E3b.sm (144 КиБ) скачан 205 раз(а).
Reg CurryLoveland, CO
Davide,
Could you kindly show me how with an example?
Thanks,
Reg
Could you kindly show me how with an example?
Thanks,
Reg
Reg CurryLoveland, CO
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 CurryLoveland, CO
Hi reg,
Yes
Here you go:
![2025-02-26 09_52_32-SMath Solver - [booleans.sm].png](/ru-RU/files/Download/3VcZhC/2025-02-26-09_52_32-SMath-Solver---[booleans.sm].png)
booleans.sm (6 КиБ) скачан 221 раз(а).
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:
![2025-02-26 09_52_32-SMath Solver - [booleans.sm].png](/ru-RU/files/Download/3VcZhC/2025-02-26-09_52_32-SMath-Solver---[booleans.sm].png)
booleans.sm (6 КиБ) скачан 221 раз(а).
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
Davide,
Thanks much.
MATHCAD bites me again.
Reg
Thanks much.
MATHCAD bites me again.

Reg
Reg CurryLoveland, CO
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
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
👍👍
Reg CurryLoveland, CO
1 страниц (10 вхождений)
-
Новые сообщения
-
Нет новых сообщений