Showing substitutions in a formula - Сообщения
#1 Опубликовано: 22.02.2023 06:24:11
3 пользователям понравился этот пост
Oscar Campo 22.02.2023 11:19:00, Вячеслав Мезенцев 22.02.2023 06:33:00, Davide Carpi 23.02.2023 10:06:00
#2 Опубликовано: 22.02.2023 18:14:35
Greetings,
I just wanted to let people know that the Alvaro's 「Evals()」 function does not work numerically; it only works as a symbolic evaluation (ie., Optimization = ☑ Symbolic). As such, it cannot be used for numerical evaluations down the line.
Regardless of the limitations, I am quite impressed by this bit of handiwork.
- Kenny Lemens, P.E. ᵂᴵ
I just wanted to let people know that the Alvaro's 「Evals()」 function does not work numerically; it only works as a symbolic evaluation (ie., Optimization = ☑ Symbolic). As such, it cannot be used for numerical evaluations down the line.
Regardless of the limitations, I am quite impressed by this bit of handiwork.
- 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
1 пользователям понравился этот пост
Alvaro Diaz Falconi 22.02.2023 19:11:00
#3 Опубликовано: 22.02.2023 19:14:48
Hi Kenny, thanks. It is absolutely true, I completely forgot that the purpose is necessarily not only to show the calculation, but to use it later. Well, though, at least it's not a 3-order-of-magnitude error, like the one I recently had.
This version saves in the first argument the numerical value of the evaluated formula. The rest of the code and the behavior stays the same.

Evals v2.sm (65 КиБ) скачан 123 раз(а).
Evals v2.pdf (147 КиБ) скачан 97 раз(а).
Best regards.
Alvaro.
This version saves in the first argument the numerical value of the evaluated formula. The rest of the code and the behavior stays the same.
Evals v2.sm (65 КиБ) скачан 123 раз(а).
Evals v2.pdf (147 КиБ) скачан 97 раз(а).
Best regards.
Alvaro.
2 пользователям понравился этот пост
#4 Опубликовано: 29.03.2023 20:33:24
Version with uncertainties calculations added.

EvalsWithErr.sm (90 КиБ) скачан 104 раз(а).
EvalsWithErr.pdf (215 КиБ) скачан 87 раз(а).
Best regards.
Alvaro.
EvalsWithErr.sm (90 КиБ) скачан 104 раз(а).
EvalsWithErr.pdf (215 КиБ) скачан 87 раз(а).
Best regards.
Alvaro.
2 пользователям понравился этот пост
#5 Опубликовано: 03.07.2023 15:40:06
Hi Alvaro,
Great work with this.
From an engineering calculation point of view, I think the additional intermediate steps are a little much. When checking a traditional SMath calculation, the biggest complaint is that the reviewer has to always flip back, or look back at the definitions of variables to see what values are being used in the given formula. Makes the checking process a bit tedious.
What has always been missing from SMath was simply showing the substituted values as defined before the final result. (Only one step)
As others have already posted, there are some tricks with optimization, but these quickly fall apart with units other than default units, and decimal values.
Any way to modify your function to do something like this?:
![2023-07-03 14_26_52-SMath Solver 1.0.8348 - [Evals v2.sm_].png](/ru-RU/file/TzKcLU/2023-07-03-14_26_52-SMath-Solver-1_0_8348---_Evals-v2_sm___png)
The function can of course be hidden in a table for a cleaner look. I also only showed the variable defined as an example. There would be no need to show this result again.
I honestly think the black units in the calculations is great, as it helps separate defined units from calculated units.
Would also be great to use definitions that are outside of the "Evals" function. This way variables can still be defined in one place, and values don't need to be re-entered.
Let me know what you think.
Great work with this.
From an engineering calculation point of view, I think the additional intermediate steps are a little much. When checking a traditional SMath calculation, the biggest complaint is that the reviewer has to always flip back, or look back at the definitions of variables to see what values are being used in the given formula. Makes the checking process a bit tedious.
What has always been missing from SMath was simply showing the substituted values as defined before the final result. (Only one step)
As others have already posted, there are some tricks with optimization, but these quickly fall apart with units other than default units, and decimal values.
Any way to modify your function to do something like this?:
The function can of course be hidden in a table for a cleaner look. I also only showed the variable defined as an example. There would be no need to show this result again.
I honestly think the black units in the calculations is great, as it helps separate defined units from calculated units.
Would also be great to use definitions that are outside of the "Evals" function. This way variables can still be defined in one place, and values don't need to be re-entered.
Let me know what you think.
#6 Опубликовано: 03.07.2023 21:17:42
Hi. This could be a first approach.

EvalsWithErr with modifications.sm (100 КиБ) скачан 105 раз(а).
EvalsWithErr with modifications.pdf (283 КиБ) скачан 93 раз(а).
Best regards.
Alvaro
EvalsWithErr with modifications.sm (100 КиБ) скачан 105 раз(а).
EvalsWithErr with modifications.pdf (283 КиБ) скачан 93 раз(а).
Best regards.
Alvaro
1 пользователям понравился этот пост
churichuro 04.07.2023 14:57:00
#7 Опубликовано: 04.07.2023 14:56:54
awesome!
1 пользователям понравился этот пост
Alvaro Diaz Falconi 04.07.2023 18:59:00
#8 Опубликовано: 06.07.2023 12:37:08
So I honestly think the original input was fine. Defining variables in a mathcad window is a bit annoying.
The only change I think is needed, but seems to be very hard or impossible, it to define the variables, used in the formula, outside of the evals function.
The best I can come up with requires you to define a second time what units are used for each variable used.
As you can see the variables are defined as any other variable in a calculation sheet and can be used in other formulas.
There is a vector that lists the units for each variable again. This is used to remove the unit when used in the Evals() function.
It seems like there is no way to do this without manually specifying the unit because there is no way to convert the variable exactly as defined into a string, you need to divide out the unit to keep the same numerical value. So there is no way to take the b:=17.3 lb and convert that definition into a string exactly as I show it. It would be nice if this was automatic, but I don't this is possible with how SMath is programed.
A note is that the first step in the substitution seems to reduce the units automatically. It would be nice to just show the initial substitution without any simplification or elimination of units in this first step.
I also changed the way the final unit is shown, so that it matches the blue color of other units.
![2023-07-05 19_06_54-SMath Solver 1.0.8348 - [Evals v2-N.sm].png](/ru-RU/file/dzXkE4/2023-07-05-19_06_54-SMath-Solver-1_0_8348---_Evals-v2-N_sm__png)
Since in a table region you can display units in blue using "S:'" before the unit text.
Evals v2-N.sm (28 КиБ) скачан 76 раз(а).
The only change I think is needed, but seems to be very hard or impossible, it to define the variables, used in the formula, outside of the evals function.
The best I can come up with requires you to define a second time what units are used for each variable used.
As you can see the variables are defined as any other variable in a calculation sheet and can be used in other formulas.
There is a vector that lists the units for each variable again. This is used to remove the unit when used in the Evals() function.
It seems like there is no way to do this without manually specifying the unit because there is no way to convert the variable exactly as defined into a string, you need to divide out the unit to keep the same numerical value. So there is no way to take the b:=17.3 lb and convert that definition into a string exactly as I show it. It would be nice if this was automatic, but I don't this is possible with how SMath is programed.
A note is that the first step in the substitution seems to reduce the units automatically. It would be nice to just show the initial substitution without any simplification or elimination of units in this first step.
I also changed the way the final unit is shown, so that it matches the blue color of other units.
Since in a table region you can display units in blue using "S:'" before the unit text.
Evals v2-N.sm (28 КиБ) скачан 76 раз(а).
#9 Опубликовано: 06.07.2023 14:39:15
Wrote... Defining variables in a mathcad window is a bit annoying....
Hi. Yes, it is. But is the only way that I know to 'hold' an expression. Like in Mathematica Hold[x] or maple 'x'. I ask for that function here.
Best regards.
Alvaro.
#10 Опубликовано: 23.05.2024 23:24:55
Hi Alvaro,
I've been looking into this concept again and I was hoping you could help me with some ideas/issues.
As it seems, the equation written within the Evals() function has to be with a,b,c.. or m1,m2,m3.. so alphabetical or numerical order, and this order matches the order of the listed values within Evals() as well.
![2024-05-23 11_45_40-SMath Solver - [EvalsWithErr with modifications.sm_].png](/ru-RU/file/p3xYbh/2024-05-23-11_45_40-SMath-Solver---_EvalsWithErr-with-modifications_sm___png)
There seems to a couple of issues with the order in which values are shown in the original equation vs. the later substitution steps, as well as how the units are shown for the substitution.
So here is what I envision as working well.
We can list variables as we normally do, and they can have any variable name, not just a,b,c or m1,m2,m3.
The Evals() function will require to specify the formula with the same variables you previously listed. Maybe listing the formula and the variables is enough and we don't need to list the variables again?
Then you need to specify how many decimal places you need, but it would be nice to not have trailing zeros so that substituted values look the same as previously listed.
Then we can specify the final unit we want for the result.
We don't need to show any steps and the substitution can be only a visual, the evaluation can be done like normal in the background and simply assigned to the variable listed.
![2024-05-23 12_17_11-SMath Solver - [EvalsWithErr with modifications.sm_].png](/ru-RU/file/zPhTZe/2024-05-23-12_17_11-SMath-Solver---_EvalsWithErr-with-modifications_sm___png)
Do you think something like this can be possible?
I've been looking into this concept again and I was hoping you could help me with some ideas/issues.
As it seems, the equation written within the Evals() function has to be with a,b,c.. or m1,m2,m3.. so alphabetical or numerical order, and this order matches the order of the listed values within Evals() as well.
There seems to a couple of issues with the order in which values are shown in the original equation vs. the later substitution steps, as well as how the units are shown for the substitution.
So here is what I envision as working well.
We can list variables as we normally do, and they can have any variable name, not just a,b,c or m1,m2,m3.
The Evals() function will require to specify the formula with the same variables you previously listed. Maybe listing the formula and the variables is enough and we don't need to list the variables again?
Then you need to specify how many decimal places you need, but it would be nice to not have trailing zeros so that substituted values look the same as previously listed.
Then we can specify the final unit we want for the result.
We don't need to show any steps and the substitution can be only a visual, the evaluation can be done like normal in the background and simply assigned to the variable listed.
Do you think something like this can be possible?
#11 Опубликовано: 24.05.2024 08:27:22
Hi. Something like this? (Examples at the end)
EvalsWithErr with modifications - examples.sm (109 КиБ) скачан 76 раз(а).

Best regards.
Alvaro.
EvalsWithErr with modifications - examples.sm (109 КиБ) скачан 76 раз(а).
Best regards.
Alvaro.
#12 Опубликовано: 24.05.2024 09:57:12
Hi Alvaro,
That is a start, but I still have some questions/clarifications.
Is there no way to define the variables outside of the MathCAD region?
In the original Evals(), both the question and the output unit were defined within the Evals() function, this is fine.
Any way to just show the unit after each value instead of showing the units grouped together?
In ne we have lb outside parenthesis, and in the other it is showing m^2 instead of two m units.
Also, is the order not controllable? We specified 2c+b+a, but get b+a+2c.
That is a start, but I still have some questions/clarifications.
Is there no way to define the variables outside of the MathCAD region?
In the original Evals(), both the question and the output unit were defined within the Evals() function, this is fine.
Any way to just show the unit after each value instead of showing the units grouped together?
In ne we have lb outside parenthesis, and in the other it is showing m^2 instead of two m units.
Also, is the order not controllable? We specified 2c+b+a, but get b+a+2c.
#13 Опубликовано: 24.05.2024 11:25:44
Hi. Mathcad solve block is the only way that I know about preventing evaluation. I don't see how do anything else, without something like the Mathematica's Hold or maple's uneval functions:
From https://www.maplesoft.com/support/help/maple/view.aspx?path=uneval

From https://reference.wolfram.com/language/ref/HoldForm.html

Best regards.
Alvaro.
From https://www.maplesoft.com/support/help/maple/view.aspx?path=uneval
From https://reference.wolfram.com/language/ref/HoldForm.html
Best regards.
Alvaro.
#14 Опубликовано: 24.05.2024 11:40:52
Sadly, this is the main issue.
Everything is fine for default units, but if anything is not in default, it is immediately converted, and the value as displayed is lost.
![2024-05-24 00_32_39-SMath Solver - [Worksheet1_].png](/ru-RU/file/BgSNYY/2024-05-24-00_32_39-SMath-Solver---_Worksheet1___png)
There seems to be no way other than the MathCAD region to do this at the moment.
By the way, I made a new post showing a manual way to achieve this that is probably as much if not less work that what is already required for your Evals(s) function.
For now, I think that the manual method is as good as it gets until there is a change within SMath.
Andrey said he was going to try and prioritize it, but that was a while back.
I think there are a lot of people who want this and are willing to contribute financially to make this happen. Maybe we need to do a crowd funding round?
Everything is fine for default units, but if anything is not in default, it is immediately converted, and the value as displayed is lost.
There seems to be no way other than the MathCAD region to do this at the moment.
By the way, I made a new post showing a manual way to achieve this that is probably as much if not less work that what is already required for your Evals(s) function.
For now, I think that the manual method is as good as it gets until there is a change within SMath.
Andrey said he was going to try and prioritize it, but that was a while back.
I think there are a lot of people who want this and are willing to contribute financially to make this happen. Maybe we need to do a crowd funding round?
#15 Опубликовано: 25.05.2024 16:37:45
Another option (Version 3)

Evals v3.sm (62 КиБ) скачан 84 раз(а).
Evals v3.pdf (159 КиБ) скачан 73 раз(а).
Best regards.
Alvaro.
Evals v3.sm (62 КиБ) скачан 84 раз(а).
Evals v3.pdf (159 КиБ) скачан 73 раз(а).
Best regards.
Alvaro.
2 пользователям понравился этот пост
#16 Опубликовано: 26.05.2024 12:33:39
This is better, actually not bad at all.
Can you make it so that the formula is input directly into Ev() along with the output unit?
That way eq only contains the variables, since this part won't be hidden.
The Ev() function will be hidden in a table region to clean it up nice.
![2024-05-26 01_29_17-SMath Solver - [Evals v3.sm_].png](/ru-RU/file/yBTbcS/2024-05-26-01_29_17-SMath-Solver---_Evals-v3_sm___png)
Also, any way to get 500 up on top next to unit?
Can you make it so that the formula is input directly into Ev() along with the output unit?
That way eq only contains the variables, since this part won't be hidden.
The Ev() function will be hidden in a table region to clean it up nice.
Also, any way to get 500 up on top next to unit?
#17 Опубликовано: 27.05.2024 08:35:03
1 пользователям понравился этот пост
Alvaro Diaz Falconi 29.05.2024 22:27:00
#18 Опубликовано: 29.05.2024 22:42:01
#19 Опубликовано: 29.05.2024 22:46:59
I’m confused because on your original Evals() function everything was input into the Evals() function. We can’t have the variables listed in the MathCAD block and the rest like it was before?
#20 Опубликовано: 29.05.2024 22:51:03
-
Новые сообщения
-
Нет новых сообщений