Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Offline wb.c  
#1 Posted : 10 months ago
wb.c


Rank: Advanced Member

Groups: Registered
Joined: 02/04/2018(UTC)
Posts: 155
United States

Was thanked: 26 time(s) in 22 post(s)
This is a feature I really hope can be automated as part of SMath. (One day...)
The goal is to show the values of the variables in an equation as they are shown in their last definition.
Only a display as a means to simplify the checking and review of "hand calculations". (We all know how annoying it is to dig back and find the values for all the variables used in an equation...)

What I have done is create a simple snippet (SubstitutionTemplate) that can be saved in the snippet manager folder (user/AppData/Local/Programs/SMath Studio/snippets) or wherever you have your snippet folder...

When working on a calculation, you define variables as you normally do.

2024-05-23 23_41_47-SMath Solver - [Substitution Example.sm_].png

Then you go to the snippet manager and select the snippet you added (Substitution Template) and insert it (uncheck inset inside area).

2024-05-23 23_42_49-Clipboard.png

2024-05-24 00_01_36-SMath Solver - [Worksheet1].png

2024-05-23 23_44_18-SMath Solver - [Substitution Example.sm_].png

This snippet is just a few formula regions inside a text region, so everything looks nice.

Highlight v# and replace it with the variable you wish to define.
Highlight eq# and write the formula that defines the variable.
Highlight eqs# and write the formula again, but this time manually input the values of the variables with units, so it looks nice and neat.
Lastly, highlight vr# and type the variable you are defining, and press "=", then right click over the variable and deselect "Display Input Data"

2024-05-23 23_49_38-SMath Solver - [Substitution Example.sm_].png

The final result looks like this:

2024-05-23 23_51_17-SMath Solver - [Substitution Example.sm_].png

The variable is assigned the value the same way as a standard calculation (because it is just a regular calculation inside a text region), you can change the display unit if you want.

2024-05-23 23_53_20-SMath Solver - [Substitution Example.sm_].png

The only thing snippet does is optimize the manual work.
Yes, it is annoying to manually type in the values and units you want to display as substitutions, but this is not more work than any other solution.
It would be amazing if someone could come up with a way to automate this substitution on the basis of the equation and the defined variables used in that equation.
As far as I can see, this sort of thing requires coding changes within SMath and will not be possible with the tools available now.

So, in the meantime, this is the best we have.

Substitution Example.sm (8kb) downloaded 32 time(s).
SubstitutionTemplate.sm (4kb) downloaded 32 time(s).
thanks 2 users thanked wb.c for this useful post.
on 24/05/2024(UTC),  on 24/05/2024(UTC)
Offline OchkovVF  
#2 Posted : 10 months ago
OchkovVF


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 06/04/2023(UTC)
Posts: 441
Man
Russian Federation

Was thanked: 50 time(s) in 43 post(s)
Showing numbers in formulas is a technology of the last century, when calculations were done on slide rules and calculators. In companies and design bureaus there were departments where girls (boys - see below) sat and stupidly checked the accuracy of the calculations. It was for these girls that they made the calculation by substituting numbers in the formulas. Nowadays you won’t find any errors using this method, but at my university the old teachers still demand substitution and check the calculations in SMath or Mathcad themselves on the calculator.
We can do so
c:=a+b=4
where
a=1
b=3
etc
No woman or colored!
SlideRule.gif

Edited by user 10 months ago  | Reason: Not specified

Offline wb.c  
#3 Posted : 10 months ago
wb.c


Rank: Advanced Member

Groups: Registered
Joined: 02/04/2018(UTC)
Posts: 155
United States

Was thanked: 26 time(s) in 22 post(s)
So I think it is quite obvious you don’t work in the engineering world. Even programs that are used require proof calculations to validate outputs. SMath is often used for hand calculations that are not done in a standard program like Risa or SAP2000 or STAD Pro. When hand calculations are done, they must be checked.
For engineers, this feature is the most requested of SMath and MathCAD.
As good as SMath is, or even MathCAD, people still check calculations, not only for arithmetic error, but for logical mistakes.
Offline mkraska  
#4 Posted : 10 months ago
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 2,048
Germany

Was thanked: 1177 time(s) in 752 post(s)
So the essential feature for displaying substituted values in definitions is the access to the verbatim definition of that values without simplification before storage.

The Mathcad block seems to be able to pave the way. In the screenshot below, the variable eq contains all information which is required to display the expression for c as expression and with substituted values.

Plus, it shows a proof of concept, how to build a string for display in a table region (a formatted label also works).

All the definitions are actually active and can be used as usual, without restrictions and without typing anything twice.

2024-05-24 21_01_33-SMath Solver - [Worksheet17_].png

Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath%20with%20Plugins.ashx
Offline mkraska  
#5 Posted : 10 months ago
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 2,048
Germany

Was thanked: 1177 time(s) in 752 post(s)
IMHO these could be a possible implementation:

- Create a function, which takes the name of the variable whose calculation is to be documented for manual check, possibly in string form if the verbatime name is spoiled by preprocessing.
- The function borrows the sheet scanning capability from Mathcad region (this is a possible show stopper, I am not sure if this works)
- This function creates a string for display in a formatted label, containing everything wb.c was asking for
- Put the function call in the formatted label and switch off border and input data.

That should be pretty close to your dreams.

Here is a version with a table region.

2024-05-24 21_45_35-SMath Solver - [Worksheet17_].png

Edited by user 10 months ago  | Reason: Not specified

Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath%20with%20Plugins.ashx
Offline wb.c  
#6 Posted : 10 months ago
wb.c


Rank: Advanced Member

Groups: Registered
Joined: 02/04/2018(UTC)
Posts: 155
United States

Was thanked: 26 time(s) in 22 post(s)
Originally Posted by: mkraska Go to Quoted Post
So the essential feature for displaying substituted values in definitions is the access to the verbatim definition of that values without simplification before storage.

The Mathcad block seems to be able to pave the way. In the screenshot below, the variable eq contains all information which is required to display the expression for c as expression and with substituted values.

Plus, it shows a proof of concept, how to build a string for display in a table region (a formatted label also works).

All the definitions are actually active and can be used as usual, without restrictions and without typing anything twice.




This seems to only work with nice round numbers. num2str(1) seems to force the output in exact form.

2024-05-24 21_38_03-SMath Solver - [Worksheet1_].png
Offline OchkovVF  
#7 Posted : 10 months ago
OchkovVF


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 06/04/2023(UTC)
Posts: 441
Man
Russian Federation

Was thanked: 50 time(s) in 43 post(s)
Originally Posted by: wb.c Go to Quoted Post
So I think it is quite obvious you don’t work in the engineering world...


I have been involved in similar disputes many times. My last argument was this: show me an example where the use of this technique allowed us to identify an error.
It is enough to write like this
a:=b+c=5
where
b=1 and c=4
But not for some verification - for some illustration

Edited by user 10 months ago  | Reason: Not specified

Offline mkraska  
#8 Posted : 10 months ago
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 2,048
Germany

Was thanked: 1177 time(s) in 752 post(s)
Originally Posted by: wb.c Go to Quoted Post



This seems to only work with nice round numbers. num2str(1) seems to force the output in exact form.

2024-05-24 21_38_03-SMath Solver - [Worksheet1_].png


The information on the original units and the original precision is still there and can be extracted from the string. It is not as easy as in the integer case but it is possible to implement in a display function.

There is another problem: num2str() fails to convert expressions like K:3*l=0.0096*'m@# (a definition with integrated display and default unit).
Note that this doesn't happen if the display unit has been specified explicitly.

Possible mitigation:
- fix num2str() to handle this case.
- if a variable to be substituted isn't found in the list of successfully converted expressions from eq, then use it's value from the context. This doesn't harm as using the default unit will be just right.

I don't say that writing the display function is trivial. Yet the fundamental problem of loosing input information upon storage in the context isn't a show stopper any more.

2024-05-25 10_06_49-SMath Solver - [Worksheet17_].png
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath%20with%20Plugins.ashx
Offline mkraska  
#9 Posted : 10 months ago
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 2,048
Germany

Was thanked: 1177 time(s) in 752 post(s)
Originally Posted by: OchkovVF Go to Quoted Post
Originally Posted by: wb.c Go to Quoted Post
So I think it is quite obvious you don’t work in the engineering world...


I have been involved in similar disputes many times. My last argument was this: show me an example where the use of this technique allowed us to identify an error.
It is enough to write like this
a:=b+c=5
where
b=1 and c=4
But not for some verification - for some illustration


In the case of unitless integer quantities this is straightforward. Yet if you want or have to document the substituted values using their original precision and unit, you have to specify unit and display precision manually

BTW I wonder what the check reader expects for intermediate result. Does he expect to substitute such values as displayed (possibly with rounding) in subsequent calculations?
That would enforce accumulation of round-off errors. Displaying rounded values in the substitution and actually using the full mantissa would be sort of inconsistent though, because the proof reader might come to a different result if evaluating the equation with the displayed substitutions.
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath%20with%20Plugins.ashx
Offline overlord  
#10 Posted : 10 months ago
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,198
Turkey

Was thanked: 548 time(s) in 368 post(s)
Originally Posted by: OchkovVF Go to Quoted Post
No woman or colored!

Funny part is, routine repetitive figuring was mostly done by women.
Not just for defense, it is known civilian companies accounts were calculated by women also.
I speak for American part of course, don't know Soviet aspect.

https://www.history.com/news/human-computers-women-at-nasa
Offline wb.c  
#11 Posted : 10 months ago
wb.c


Rank: Advanced Member

Groups: Registered
Joined: 02/04/2018(UTC)
Posts: 155
United States

Was thanked: 26 time(s) in 22 post(s)
Originally Posted by: mkraska Go to Quoted Post

BTW I wonder what the check reader expects for intermediate result. Does he expect to substitute such values as displayed (possibly with rounding) in subsequent calculations?


I honestly don’t think rounding errors are typically an issue with most engineering calculations. This is for engineering calcs, not a math PhD proving a theorem.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.