[Date Index]
[Thread Index]
[Author Index]
RE: using a previous result
*To*: mathgroup at smc.vnet.net
*Subject*: [mg67355] RE: [mg67324] using a previous result
*From*: "David Park" <djmp at earthlink.net>
*Date*: Mon, 19 Jun 2006 00:01:29 -0400 (EDT)
*Sender*: owner-wri-mathgroup at wolfram.com
David,
Just save the result under some name. Since there is only a single set of
solutions I take the first part to get rid of the extra curly brackets.
q1 = a + b p1 + g p2; q2 = c + d p2 + e p1; profit1 = p1 q1; profit2 = p2
q2;
psols = First@
FullSimplify[Solve[{D[profit1, p1] == 0, D[profit2, p2] == 0}, {p1,
p2}]]
{p1 -> (-2*a*d + c*g)/(4*b*d - e*g),
p2 -> (-2*b*c + a*e)/(4*b*d - e*g)}
Then you can use the solutions to substitute in any expression. For
example...
p1 + 3p2 /. psols // Simplify
(-6*b*c - 2*a*d + 3*a*e + c*g)/(4*b*d - e*g)
Or you might want to define some expression of the p's as a function. You
could do it this way...
f[a_, b_, c_, d_, e_, g_] = p1 + 3p2 /. psols // Simplify
(-6*b*c - 2*a*d + 3*a*e + c*g)/(4*b*d - e*g)
Then you can just evaluate the function using the abc... variables.
f[a, 1, 3, d, e, 5]
(-3 - 2*a*d + 3*a*e)/(4*d - 5*e)
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/
From: ridley_david at yahoo.com [mailto:ridley_david at yahoo.com]
To: mathgroup at smc.vnet.net
Once I've solved a system of equations, I would like to use the
previous results in future equations. If my output is {{p1->x,p2->y}}
how do I assign those values as p1star and p2star so I can reuse them?
Thank you,
David
For example:
q1=a+b p1 +g p2;q2 = c+d p2 + e p1;profit1=p1 q1;profit2=p2 q2;
FullSimplify[Solve[{D[profit1,p1]==0,D[profit2,p2]==0},{p1,p2}]]
Prev by Date:
**Re: Re: Package writing**
Next by Date:
**Re: matrix substitution--> Gell-Mann su(3) as a real 6by6 matrix group by substitution**
Previous by thread:
**Re: using a previous result**
Next by thread:
**Re: using a previous result**
| |