jcclaser
Industrial
- Jan 29, 2010
- 1
Hi,
In a Mathcad program, I noticed that a function is recalculated while it does not need to be. Here is an example:
f(x):= x^2 + 1
g(x,y):= f(x) + y
y:= 0,1 .. 10
[graph of g(x,y) vs. y]
Normally, when y is varied, f(x) should not be recalculated, it should be calculated only for the first value of y. But I noticed that f(x) is calculated for each value of y.
Is there a way to force the program to calculate f(x) only once for all?
Thanks a lot,
JC
In a Mathcad program, I noticed that a function is recalculated while it does not need to be. Here is an example:
f(x):= x^2 + 1
g(x,y):= f(x) + y
y:= 0,1 .. 10
[graph of g(x,y) vs. y]
Normally, when y is varied, f(x) should not be recalculated, it should be calculated only for the first value of y. But I noticed that f(x) is calculated for each value of y.
Is there a way to force the program to calculate f(x) only once for all?
Thanks a lot,
JC