0
$\begingroup$

Trying to solve diff.eq.has led me to:

{a, b} = {6, 7}
Do[With[{solve = 
      NSolve[{0.8 p (y^0.2/x^0.2) + x (x - 2 a)/(x - a)^2 == 0, 
        0.2 p (x^0.8/y^0.8) + y (y - 2 b)/(y - b)^2 == 0, 
        p^-2 == x^0.8 y^0.2, 0 <= x <= a, 0 <= y <= b}, {p, x, y}]}, 
    k = Extract[solve, {1}]; l = Extract[solve, {2}]]
   a = a + 0.001 (k + l) a;
 b = b + 0.001 b k l, {100}]
{a, b}

but don't understand, why it fails?

$\endgroup$
  • 2
    $\begingroup$ When you have a problem like this, try to construct a minimal example that shows the problem. Break the code into pieces and check what each piece gives separately. You will likely find the problem on your own. This example is far from minimal; as a start, do only one iteration instead of 100 and check the values of all your variables. $\endgroup$ – Szabolcs Aug 11 '15 at 17:53
  • $\begingroup$ Your expression l = Extract[solve, {2}] does not work: there is no second part to the solution that is returned by NSolve. You also have syntax errors in the code you posted: you probably need a ; after the closing square bracket for With. $\endgroup$ – MarcoB Aug 11 '15 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.