MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: using a previous result

  • To: mathgroup at
  • Subject: [mg67355] RE: [mg67324] using a previous result
  • From: "David Park" <djmp at>
  • Date: Mon, 19 Jun 2006 00:01:29 -0400 (EDT)
  • Sender: owner-wri-mathgroup at


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

psols = First@
    FullSimplify[Solve[{D[profit1, p1] == 0, D[profit2, p2] == 0}, {p1,
{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

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

From: ridley_david at [mailto:ridley_david at]
To: mathgroup at

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,

For example:
q1=a+b p1 +g p2;q2 = c+d p2 + e p1;profit1=p1 q1;profit2=p2 q2;

  • 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