Display of results with non-unit factor

Display of results with non-unit factor - 消息

#1 已发布: 2025/8/10 18:39:43
Martin Kraska

Martin Kraska

1,362个赞,共2,276个帖子。

组: 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
Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
#2 已发布: 2025/8/13 20:45:28
⚜ Kenny Lemens, P.E. ᵂᴵ

⚜ Kenny Lemens, P.E. ᵂᴵ

85个赞,共181个帖子。

组: 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 已发布: 2025/8/14 10:39:58
Martin Kraska

Martin Kraska

1,362个赞,共2,276个帖子。

组: 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.28 KiB)已下载 1448 次。
已编辑 2025/8/14 10:47:01
Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
#4 已发布: 2025/8/16 03:47:00
finnbentley

finnbentley

0个赞,共1个帖子。

组: 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.
  • 有新帖
  • 无新帖