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 - Messages

#1 Posted: 10/19/2021 11:21:50 AM
Stefano

Stefano

0 likes in 22 posts.

Group: 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 KiB) downloaded 24 time(s).

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 Posted: 10/19/2021 11:34:31 AM
overlord

overlord

552 likes in 1332 posts.

Group: 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 Posted: 10/19/2021 12:41:02 PM
Stefano

Stefano

0 likes in 22 posts.

Group: User

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

thanks
#4 Posted: 10/19/2021 1:48:32 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: 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 KiB) downloaded 27 time(s).
Spline De Boor [Colibri].sm (34 KiB) downloaded 29 time(s).
#5 Posted: 10/19/2021 4:05:11 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: 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 KiB) downloaded 32 time(s).

#6 Posted: 10/19/2021 4:11:48 PM
overlord

overlord

552 likes in 1332 posts.

Group: 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().
  • New Posts New Posts
  • No New Posts No New Posts