Display of results with non-unit factor

Display of results with non-unit factor - Messages

#1 Posted: 8/10/2025 6:39:43 PM
Martin Kraska

Martin Kraska

1,255 likes in 2,182 posts.

Group: Moderator

I define an expression linear in an undefined non-unit variable. In previous versions of SMath I could use that variable in the unit placeholder to obtain a numeric result. Unfortunately, this is not possible any more.

image.png

image.png
Martin KraskaPre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#2 Posted: 8/13/2025 8:45:28 PM
⚜ Kenny Lemens, P.E. ᵂᴵ

⚜ Kenny Lemens, P.E. ᵂᴵ

80 likes in 175 posts.

Group: User

Greetings,

image.png

As a 'work-around', you could declare x to be a 'unit'; that seems to have the desired behavior you are after; I don't know if I would consider it a bug though...

I would rather "numeric" throw an error as it currently does, and that symbolic would allow a variety of display options, from fractions, to mixed fractions, to decimal, to explicit substitutions for an(or all) variables, etc.

"No matter where you go, there you are." -Buckaroo BanzaiHotkeys: https://en.smath.com/forum/resource.ashx?a=45771&b=2
#3 Posted: 8/14/2025 10:39:58 AM
Martin Kraska

Martin Kraska

1,255 likes in 2,182 posts.

Group: Moderator

The unit workaround is also useful to enable symbolic simplifications which require the variable to be a scalar (and not a matrix), e.g. determinants and cross products. Not making this assumption in SMath is a design decision, which was explicitly confirmed by Andrey Ivashov, who actually insisted on this behaviour. Another workaround is the use of Maxima, where variables are handled as scalars unless declared otherwise.

The unit camouflage of variables has disadvantages. If you want to establish equations with various variables you will get "units don't match". Also, FindRoot, solve() and roots() won't accept unit names as variable names.
So you need another workaround and your worksheet is becoming very obscure.


Yet while responding to the above post, It comes to my mind that one could try to convert variables to units (with safe names), perform simplification with the str2num-num2str workaround and then convert everything back to the original variable names. I will give this a try but it may get spoiled by non-matching units errors.

image.png

image.png

Here is an example of a worksheet with extensive usage of units for unknowns.

1-2-Maßeinheiten.sm (152 KiB) downloaded 41 time(s).
Edited 8/14/2025 10:47:01 AM
Martin KraskaPre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#4 Posted: 8/16/2025 3:47:00 AM
finnbentley

finnbentley

0 likes in 1 posts.

Group: User

Wrote

Greetings,

image.png io games

As a 'work-around', you could declare x to be a 'unit'; that seems to have the desired behavior you are after; I don't know if I would consider it a bug though...

I would rather "numeric" throw an error as it currently does, and that symbolic would allow a variety of display options, from fractions, to mixed fractions, to decimal, to explicit substitutions for an(or all) variables, etc.


Your idea of converting variables to units with safe names, performing simplifications, and then converting back is a creative approach. However, as you noted, this method may encounter issues with non-matching units, which could complicate the process further. The "unit camouflage" approach can complicate the establishment of equations. The "units don't match" error can be particularly frustrating when trying to solve equations involving different variables.
  • New Posts New Posts
  • No New Posts No New Posts