Is it my or SMath error?

Is it my or SMath error? - 消息

#1 已发布: 2023/4/28 02:09:26
Valery Ochkov

Valery Ochkov

67个赞,共716个帖子。

组: User

x:= 20 y(x):= x^2= Is it my or SMath error?

See please the attach (with WaterSteamPro - but no problem - you can use CoolProp here too)
5-18-DeltaP-Error.sm (27.93 KiB)已下载 1418 次。
Thanks!
#2 已发布: 2023/4/28 09:57:46
Jean Giraud

Jean Giraud

983个赞,共6,866个帖子。

组: User

Sorry Valery, I don't understand your formulation.
Cheers ... Jean.

Lamda.sm (147.74 KiB)已下载 1357 次。
#3 已发布: 2023/4/28 13:47:33
NotRetiredYet

NotRetiredYet

2个赞,共9个帖子。

组: User

Having all of the math in one line makes this difficult to read. I think you have:

x:=20
y(x):=x^2=


The problem with the second line is that you can't do an in-line evaluation of a function. This is because the x in the function is local to the function and thus the function doesn't know about the previous definition of x. (BTW, I don't have SM on my work computer, so I tested this using Mathcad Prime 5.0. I am pretty sure both programs handle this the same way.)

The way to handle your math as written is this way:

x:=20
y(x):=x^2
y(x)=400


However, I think it's far better to use generic variables in a function (e.g., x) and specific variables for the definition (e.g. x1). So, I would rewrite your formulation this way:

x1:=20
y(x):=x^2
y(x1)=400


This approach makes is much easier to read and debug worksheets.
#4 已发布: 2023/4/28 14:22:58
Jean Giraud

Jean Giraud

983个赞,共6,866个帖子。

组: User

Wrote

Having all of the math in one line makes this difficult to read.


Agreed. MCD line 'if' was largely used as convenient single 'if'
Two pages Smath 'if' is lot more difficult than two cols 'if'.
#5 已发布: 2023/4/28 15:06:24
Jean Giraud

Jean Giraud

983个赞,共6,866个帖子。

组: User

Wrote

Having all of the math in one line makes this difficult to read.


'if/otherwise' is always my first preference.
However,some Smath project(s) accept only 'if/else'

if_otherwise.PNG
#6 已发布: 2023/4/28 15:50:53
Jean Giraud

Jean Giraud

983个赞,共6,866个帖子。

组: User

Wrote

However,some Smath project(s) accept only 'if/else'


Here is an example.
Cheers ... Jean.

if_else_otherwise.sm (37.67 KiB)已下载 1386 次。
  • 有新帖
  • 无新帖