2
$\begingroup$

Trying to solve a systems of equations. Here's the code:

alphaIndoor=1.46172*10^6
alphaOutdoor=1.61956*10^7
priceTap=977.554
alphaField=2.41546*10^7
alphaVeg=547723.


FindInstance[(qIndoor/alphaIndoor)^(-1/0.3) - (qOutdoor/alphaOutdoor)^(-1/0.75) == 0 &&
   (qOutdoor/alphaOutdoor)^(-1/0.75) - priceTap - (qField/alphaField)^(-1/1.5) + 30 == 0 && 
   (qField/alphaField)^(-1/1.5) - (qVeg/alphaVeg)^(-1/0.5) == 0 &&
   qIndoor + qOutdoor + qField + qVeg == 400000, 
   {qIndoor, qOutdoor, qField, qVeg}, Reals]

I've already given values to everything except the variables I'm asking it to solve for {qIndoor, qOutdoor, qField, qVeg}.

The program doesn't solve the problem, but just runs forever. Any help would be much appreciated!

$\endgroup$
3
  • $\begingroup$ the value of priceTap is not provided in your post. $\endgroup$
    – kglr
    Oct 19, 2014 at 23:13
  • $\begingroup$ Yea just added it. Thanks for the keen eye! $\endgroup$
    – Mike
    Oct 19, 2014 at 23:17
  • 1
    $\begingroup$ Do you have any additional constraints you could add, such as qIndoor > 0, qOutdoor > 0, etc? Also, try solving the first equation to get qOutdoor as a function of qIndoor, and substitute into the second equation, etc. This piecemeal solution may work better. $\endgroup$
    – user1722
    Oct 19, 2014 at 23:48

2 Answers 2

2
$\begingroup$

Since qIndoor + qOutdoor + qField + qVeg == 400000 there are only three independent variables

alphaIndoor = 1.46172*10^6;
alphaOutdoor = 1.61956*10^7;
priceTap = 977.554;
alphaField = 2.41546*10^7;
alphaVeg = 547723;

eqns = {(qIndoor/alphaIndoor)^(-10/3) -
      (qOutdoor/alphaOutdoor)^(-4/3) == 0,
    (qOutdoor/alphaOutdoor)^(-4/3) - priceTap -
      (qField/alphaField)^(-2/3) + 30 == 0,
    (qField/alphaField)^(-2/3) -
      (qVeg/alphaVeg)^-2 == 0} /.
   qVeg -> 400000 - (qIndoor + qOutdoor + qField);

sol = Join[fr = FindRoot[eqns,
    {{qIndoor, 18*^4}, {qOutdoor, 9*^4}, {qField, 55*^3}}],
  {qVeg -> (400000 - (qIndoor + qOutdoor + qField) /. fr)}]

{qIndoor -> 183688., qOutdoor -> 90664.9, qField -> 54019.7, qVeg -> 71627.3}

Show[
 ContourPlot3D[Evaluate[eqns],
  {qIndoor, 0, 4*^5}, {qOutdoor, 0, 4*^5}, {qField, 0, 4*^5},
  RegionFunction -> ((#1 + #2 + #3) < 4*^5 &),
  ContourStyle -> Opacity[.5],
  AxesLabel -> (Style[#, 14, Bold] & /@
     {qIndoor, qOutdoor, qField}),
  PlotPoints -> 25],
 Graphics3D[{Red, AbsolutePointSize[8],
   Point[{qIndoor, qOutdoor, qField} /. sol]}]]

enter image description here

$\endgroup$
1
$\begingroup$
FindRoot[{(qIndoor/alphaIndoor)^(-1/0.3) - (qOutdoor/
   alphaOutdoor)^(-1/0.75) == 0, (qOutdoor/alphaOutdoor)^(-1/0.75) - 
priceTap - (qField/alphaField)^(-1/1.5) + 30 == 0,
(qField/alphaField)^(-1/1.5) - (qVeg/alphaVeg)^(-1/0.5) == 0, 
qIndoor + qOutdoor + qField + qVeg == 400000}, {{qIndoor,100},
{qOutdoor, 100}, {qField, 100}, {qVeg, 100}}]
{qIndoor -> 183688., qOutdoor -> 90664.9, qField -> 54019.7, 
qVeg -> 71627.3}
(*{qIndoor -> 183688., qOutdoor -> 90664.9, qField -> 54019.7, qVeg -> 71627.3}*)
$\endgroup$
1
  • $\begingroup$ This is a better approach than using NSolve...which did not produce an outcome $\endgroup$
    – thils
    Oct 20, 2014 at 0:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.