Re: Create and use a set of values for variables
- To: mathgroup at smc.vnet.net
- Subject: [mg107522] Re: Create and use a set of values for variables
- From: Szabolcs Horvát <szhorvat at gmail.com>
- Date: Tue, 16 Feb 2010 03:50:39 -0500 (EST)
- References: <hlb8qt$rmi$1@smc.vnet.net>
On 2010.02.15. 11:49, Menl wrote: > Hi, > > I try to find a method of doing the following in Mathematica. > > I have some function y[x_]=a x^2 + b x + c > Now I want some list which hold values for a, b and c. that are dependend on some lower level values d, e and f. > > vars1=[{d=1, e=4, f=6},{b=d+e, c=2f, a = d^2}] > vars2=[{d=2, e=3, f=7},{b=d+e, c=2f, a = d^2}] > vars3=[{d=5, e=5, f=1},{b=d+e, c=2f, a = d^2}] > > and use these sets with the original function when I need it. > > This line will not work as intended of course but I hope it makes it clear what I try to do. The key is I would like to not evaluate these values outside this vars, so the original function stays unevaluated. > > Something like this I tried to do with either the functions Block or With, but both evaluate the values for a, b and c. I would like to make several such sets of variables without evaluating them so I can use them as desired, to plot the original function with several sets of vars. > Have you tried using replacement rules? y[x] /. {b -> d + e, c -> 2 f, a -> d^2} /. {d -> 1, e -> 4, f -> 6} or y[x] //. {b -> d + e, c -> 2 f, a -> d^2, d -> 1, e -> 4, f -> 6}