solving equation within a range and integral

solving equation within a range and integral - Сообщения

#1 Опубликовано: 09.09.2025 13:11:55
mule

mule

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

Группа: User

Good day!

I was a Mathcad Prime user but I am currently trying to learn SMath and importing my calculations in it. It was easier in Mathcad but somehow I'm stuck when doing this part regarding solving equation that involves units, a range, and integral, and graphing the plots

I would really appreciate if someone could help me with my problem


image.png

solver.sm (10,71 КиБ) скачан 26 раз(а).
#2 Опубликовано: 09.09.2025 14:44:56
StvMath

StvMath

40 сообщений из 64 понравились и 1 не понравились пользователям.

Группа: User

Plot a graph and you can see that Tsh never gets anywhere near Ts:

Tsh_vs_z.png
#3 Опубликовано: 09.09.2025 15:09:08
mule

mule

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

Группа: User

I'm sorry but your conversion of T_s from Celsius to Kelvin is wrong. T_s = 617.95 K

Wrote

Plot a graph and you can see that Tsh never gets anywhere near Ts:

Tsh_vs_z.png

#4 Опубликовано: 09.09.2025 15:34:41
Alvaro Diaz Falconi

Alvaro Diaz Falconi

1 052 сообщений из 1 718 понравились пользователям.

Группа: User

Hi. You can try using some ad-hoc Newton-Raphson method.

solver_mule.sm (17,92 КиБ) скачан 21 раз(а).

image.png

Best regards.
Alvaro.
1 пользователям понравился этот пост
mule 10.09.2025 12:11:35
#5 Опубликовано: 09.09.2025 15:36:27
StvMath

StvMath

40 сообщений из 64 понравились и 1 не понравились пользователям.

Группа: User

@mule You are right! It's what SMath returned, and I didn't do a sanity check! Of course, SMath understands units - I'm obviously half asleep today!!
I simply wrote a simple Newton-Raphson solution in the attached.

solver_b.sm (18,29 КиБ) скачан 21 раз(а).
Отредактировано 09.09.2025 16:18:54
2 пользователям понравился этот пост
mule 13.09.2025 01:51:49, Alvaro Diaz Falconi 09.09.2025 22:23:34
#6 Опубликовано: 09.09.2025 20:05:51
Martin Kraska

Martin Kraska

1 277 сообщений из 2 201 понравились пользователям.

Группа: Moderator

Sometimes just sampling and interpolating the function helps.

image.png
solver_b_Kr.sm (21,06 КиБ) скачан 23 раз(а).
Martin KraskaPre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
3 пользователям понравился этот пост
Вячеслав Мезенцев 09.09.2025 20:25:08, mule 13.09.2025 01:51:50, Alvaro Diaz Falconi 09.09.2025 22:23:39
#7 Опубликовано: 09.09.2025 20:28:06
Вячеслав Мезенцев

Вячеслав Мезенцев

1 511 сообщений из 1 817 понравились пользователям.

Группа: Moderator

Funny workaround. Other solvers are now available.

solver_b_Kr_uni.sm (23,2 КиБ) скачан 25 раз(а).

image.png
Russia ☭ forever, Viacheslav N. Mezentsev
3 пользователям понравился этот пост
NDTM Amarasekera 10.09.2025 14:09:23, mule 10.09.2025 12:11:30, Alvaro Diaz Falconi 09.09.2025 22:23:44
#8 Опубликовано: 10.09.2025 06:33:48
Martin Kraska

Martin Kraska

1 277 сообщений из 2 201 понравились пользователям.

Группа: Moderator

Is anyone able to explain, why the function can be evaluated in the context of pspline but not in the context of a solver? Looks like a really big problem under the hood, otherwise could have been fixed long ago.

Edit: Part of the problem is throwing pointless error messages. The unknown variable MUST be undefined in solver calls.

image.png
Отредактировано 10.09.2025 07:41:00
Martin KraskaPre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#9 Опубликовано: 10.09.2025 08:13:30
Вячеслав Мезенцев

Вячеслав Мезенцев

1 511 сообщений из 1 817 понравились пользователям.

Группа: Moderator

I can make an assumption that the integral with a parameter in the upper limit works only for numerical calculations, and is not supported for symbolic transformations.
Russia ☭ forever, Viacheslav N. Mezentsev
#10 Опубликовано: 10.09.2025 10:27:08
Martin Kraska

Martin Kraska

1 277 сообщений из 2 201 понравились пользователям.

Группа: Moderator

As far as I understand, all solvers are numeric procedures, except roots(), where I suspect that it tries to determine the gradient symbolically. Even the gradient-free Bisection() fails. Here I can't understand why any symbolic evaluation should be required.

image.png
Martin KraskaPre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#11 Опубликовано: 10.09.2025 10:54:31
Вячеслав Мезенцев

Вячеслав Мезенцев

1 511 сообщений из 1 817 понравились пользователям.

Группа: Moderator

In fact, when implementing a function in a plugin, you have the opportunity to do preliminary transformations before the actual numerical calculations begin.
Very rarely is the implementation of a function purely numerical. Moreover, for any functions that accept expressions, the implementation always contains symbolic transformations.

Look at how the pspline function is implemented

public bool TryEvaluateExpression( Entry value, Store context, ref Entry result ) => false;

It is a completely numerical function, since it works with scalars. It does not perform symbolic transformations and when it is necessary to calculate an integral, it becomes defined with specific limits in the form of numbers. The equation solver sees an unfamiliar function and simply assumes that it works.
Отредактировано 10.09.2025 11:06:08
Russia ☭ forever, Viacheslav N. Mezentsev
1 пользователям понравился этот пост
Martin Kraska 10.09.2025 20:56:36
#12 Опубликовано: 10.09.2025 12:13:29
mule

mule

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

Группа: User

WOW! it's exactly as what I did with Mathcad Prime. Thank you very much for this tip. I'm definitely using SMath from now on

Wrote

Funny workaround. Other solvers are now available.

solver_b_Kr_uni.sm (23,2 КиБ) скачан 25 раз(а).

image.png

#13 Опубликовано: 10.09.2025 18:56:50
Alvaro Diaz Falconi

Alvaro Diaz Falconi

1 052 сообщений из 1 718 понравились пользователям.

Группа: User

Wrote

As far as I understand, all solvers are numeric procedures, except roots(), where I suspect that it tries to determine the gradient symbolically. Even the gradient-free Bisection() fails ...



Hi Martin. The "symbolic" part in all the solvers in the NonLinearSolvers plugin is Unknowns. You can see from Bisection's syntax that it has to use it to determine which is the independent variable. In other words, if Unknowns fails, the solver fails too.

image.png

Best regards.
Alvaro.
1 пользователям понравился этот пост
Martin Kraska 10.09.2025 20:56:28
#14 Опубликовано: 10.09.2025 20:56:22
Martin Kraska

Martin Kraska

1 277 сообщений из 2 201 понравились пользователям.

Группа: Moderator

Alvaro, I see that Unknowns() just is not smart enough. Yet, this does not apply to the solvers which do not need to guess the names of the variables,

Viatcheslav, you pointing to the scalar nature of the argument (the third one) of pspline() brought an argument to my mind that I once had with Andrey. I complained that SMath doesn't perform some symbolic simplifications (see screenshot below) and the essence of that discussion was that Maxima assumes unknown variables to be scalars, while SMath doesn't do that. Andrey insisted in not making the scalarity assumption by default.

Yet, there is a way in SMath to declare a variable as scalar: you have to tag it as unit.

And indeed, this trick does the job for solve() and roots() and find(). Yet I consider this rather being a hack than a solution.
First, you frequently have naming conflicts with pre-defined units.
Second, I can't explain to the reader, why a solver which anyways can't handle anything except scalars (like solve()) doesn't make that assumption by default.

find() seems to have the best unit handling. The unknowns are allowed to have units and be tagged as units. Yet, having the scalarity assumption in it by default, would be a dream.

image.png

image.png

image.png



Martin KraskaPre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
1 пользователям понравился этот пост
#15 Опубликовано: 10.09.2025 21:10:04
Martin Kraska

Martin Kraska

1 277 сообщений из 2 201 понравились пользователям.

Группа: Moderator

Still the original problem is not solved:

image.png
Martin KraskaPre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#16 Опубликовано: 13.09.2025 01:49:07
mule

mule

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

Группа: User

Hello again

I am having this error about the number of rows and columns not matching. Where is this error coming from?

image.png
Отредактировано 13.09.2025 01:50:02
  • Новые сообщения
  • Нет новых сообщений