I have a list of parameters that will be used in different functions. I don't want to give them a global value so I thought on creating a list of parameters that I can call locally.
As an example, I would like to not have to type the {a = 1, b = 0.5, c = 0.75}
part of the Block each time, just call my list of parameters:
f[x_, a_, b_, c_] := a*x + b + b*c;
g[y_, a_, b_, c_] := b*y + c + a*c;
h[z_, a_, b_, c_] := c*z + a + b*c;
Block[{a = 1, b = 0.5, c = 0.75}, Solve[f[x, a, b, c] == 0, x]]
Block[{a = 1, b = 0.5, c = 0.75}, Solve[g[y, a, b, c] == 0, y]]
Block[{a = 1, b = 0.5, c = 0.75}, Solve[h[z, a, b, c] == 0, z]]
Any ideas?
f[x, a, b, c]
->f[x,1,.5,.75]
? $\endgroup$ – Kuba♦ Sep 13 '17 at 16:06f[x_, a_:1, b_:0.5, c_:0.75] := (* stuff *)
then? $\endgroup$ – J. M.'s ennui♦ Sep 13 '17 at 16:10f[x_, a_, b_, c_] := a*x + b + b*c; list = {1, .5, .75}; Solve[f[x, ##] == 0, x] & @@ list
$\endgroup$ – Kuba♦ Sep 13 '17 at 18:55pars= Sequence[1,.5,.75]
then you could just use:Solve[f[x,pars]==0,x]
$\endgroup$ – mmeent Sep 13 '17 at 19:53list={a->1,b->0.5,c->0.75};f[x,a,b,c]/.list
$\endgroup$ – sebhofer Sep 14 '17 at 7:52