villiami
- 27
- 0
I have already declared some variable values as (for example):
a = 2
b = 3
Now I want to declare a function like:
f(x) = x + a - b
I will be optimizing w.r.t. x later, so I don't want to enter it as f(x,a,b)
(or is it possible to oiptimise w.r.t. just one of the variables?)
I tried
f = inline('x+a-b','x')
but then when I tried to evaluate it, it didn't have values for a and b (even though they were declared before!), so caused an error.
Any ideas? (other than defining the function with a and b replaced by value, because this won't allow me to change a and b later)
a = 2
b = 3
Now I want to declare a function like:
f(x) = x + a - b
I will be optimizing w.r.t. x later, so I don't want to enter it as f(x,a,b)
(or is it possible to oiptimise w.r.t. just one of the variables?)
I tried
f = inline('x+a-b','x')
but then when I tried to evaluate it, it didn't have values for a and b (even though they were declared before!), so caused an error.
Any ideas? (other than defining the function with a and b replaced by value, because this won't allow me to change a and b later)