Is it my or SMath error?

Is it my or SMath error? - Mensajes

#1 Publicado: 28/4/2023 2:09:26
Valery Ochkov

Valery Ochkov

67 me gusta en 713 mensajes.

Grupo: 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) descargado 1404 vez(es).
Thanks!
#2 Publicado: 28/4/2023 9:57:46
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: User

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

Lamda.sm (147,74 KiB) descargado 1341 vez(es).
#3 Publicado: 28/4/2023 13:47:33
NotRetiredYet

NotRetiredYet

2 me gusta en 9 mensajes.

Grupo: 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 Publicado: 28/4/2023 14:22:58
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: 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 Publicado: 28/4/2023 15:06:24
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: 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 Publicado: 28/4/2023 15:50:53
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: User

Wrote

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


Here is an example.
Cheers ... Jean.

if_else_otherwise.sm (37,67 KiB) descargado 1370 vez(es).
  • Nuevos mensajes
  • Sin mensajes nuevos