Is it my or SMath error?

Is it my or SMath error? - Сообщения

#1 Опубликовано: 28.04.2023 02:09:26
Valery Ochkov

Valery Ochkov

55 сообщений из 633 понравились пользователям.

Группа: 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 КиБ) скачан 35 раз(а).
Thanks!
#2 Опубликовано: 28.04.2023 09:57:46
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

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

Lamda.sm (147 КиБ) скачан 28 раз(а).
#3 Опубликовано: 28.04.2023 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 Опубликовано: 28.04.2023 14:22:58
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: 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 Опубликовано: 28.04.2023 15:06:24
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: 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 Опубликовано: 28.04.2023 15:50:53
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

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


Here is an example.
Cheers ... Jean.

if_else_otherwise.sm (37 КиБ) скачан 31 раз(а).
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений