How to always reference symbolically a parametric expression?

How to always reference symbolically a parametric expression? - Parametric expressions defined after their parameters do not change values when parameters change - Сообщения

#1 Опубликовано: 19.10.2021 11:21:50
Stefano

Stefano

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

Группа: User

Hello,

I discovered that if I define the parameter of an expression before the expression itself, then value of the expression won't change if I change the parameter afterwards.

Here a quick example:
2021-10-19 15_42_48-SMath Solver - [order_of_definitiom.sm].png
order_of_definitiom.sm (7 КиБ) скачан 24 раз(а).

To my understanding in the second case SS has evaluated numerically the expression "x+y" and assigned the resulting value to "z": "z" is actually referencing the numerical value "3", and not the expression "x+y", therefore further change to "x" and "y" won't matter.

I was not expecting this behavior. I would have expected that "z" would be symbolically equal to "x+y", and evaluated numerically each time it is needed, like in the first example where the expression "a:=b+c" is defined before the parameters, and thus evaluate each time with current values of the parameters.

Is there a way to force an expression to behave like the first case, to be symbolically "referenced" and evaluated numerically each time it is called? Or what is the best practice in this case?

I would like to avoid the obvious choice of writing instead a function because it is not always feasible or "nice looking": for example if I write a parametric function of a parabola, I would prefer to write like "f(x)=a x^2 + b x + c" than like this "f(x,a,b,c)=...".

I could just be careful and always write expressions before parameters, but I fear that in a long and complex document, I could mistakenly define a parameter beforehand (maybe needed for calculating results of a previous expression) and then getting wrong results without even noticing.

#2 Опубликовано: 19.10.2021 11:34:31
overlord

overlord

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

Группа: Moderator

Wrote

Is there a way to force an expression to behave like the first case, to be symbolically "referenced" and evaluated numerically each time it is called? Or what is the best practice in this case?


Here comes the line() again.

2021-10-19_17-33.png
#3 Опубликовано: 19.10.2021 12:41:02
Stefano

Stefano

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

Группа: User

OK, from now and on, I will assume that line() is the answer to the question, whatever the question!

thanks
#4 Опубликовано: 19.10.2021 13:48:32
Jean Giraud

Jean Giraud

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

Группа: User

Wrote

OK, from now and on, I will assume that line() is the answer to the question, whatever the question!


Make it infinite demand from Smath.
Deconfuse yourself: as explained before local definition.
often needed for sum(#,#,#,#)
As well in more demanding maths.

Maths Infix QUICK.sm (6 КиБ) скачан 27 раз(а).
Spline De Boor [Colibri].sm (34 КиБ) скачан 29 раз(а).
#5 Опубликовано: 19.10.2021 16:05:11
Jean Giraud

Jean Giraud

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

Группа: User

Wrote

OK, from now and on, I will assume that local definition is the answer to the question, whatever the question!


Not whatever the question. Numerical maths don't do by Big-Bang-Bingo.
Whatever the error message is the question/answer.
And whatever the SS version is another answer.
1. Run the attached as given
2. Run don't put f(n,a,x) in local definition
It may create an error message to de-code wrt your SS version.
Don't miss inspecting De Boor previously attached.

Maths Maple coeffs NumDen.sm (33 КиБ) скачан 32 раз(а).

#6 Опубликовано: 19.10.2021 16:11:48
overlord

overlord

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

Группа: Moderator

Wrote

OK, from now and on, I will assume that line() is the answer to the question, whatever the question!

thanks




When a function supposed to work but whatever you do how you debugged it doesn't, yeah the issue is probably line().
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений