Re: Create and use a set of values for variables
- To: mathgroup at smc.vnet.net
- Subject: [mg107532] Re: [mg107519] Create and use a set of values for variables
- From: "David Park" <djmpark at comcast.net>
- Date: Tue, 16 Feb 2010 03:52:27 -0500 (EST)
- References: <9300874.1266231914378.JavaMail.root@n11>
I'm not certain if I understand your question but you could use SubValues to enter the parameters d,e,f and calculate a,b,c. y[d_, e_, f_][x_] := With[{a = d^2, b = d + e, c = 2 f}, a x^2 + b x + c] Then y[d, e, f][x] 2 f + (d + e) x + d^2 x^2 With numbers: y[5, 5, 1][x] 2 + 10 x + 25 x^2 You can even easily compute the derivative (in case you want that). y[5, 5, 1]'[x] 10 + 50 x And plot both of them: Plot[{y[5, 5, 1][x], y[5, 5, 1]'[x]}, {x, -5, 5}] David Park djmpark at comcast.net http://home.comcast.net/~djmpark/ From: Menl [mailto:szegersnl at gmail.com] 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.