0
$\begingroup$

I think this should be easy to numerically solve in Mathematica, but for some reason I'm not finding the correct way to do it.

I basically want to solve these simyltaneous equiations:

NSolve[
{
-(0.7)*w + (0.3)*y + (0.4)*z == 0,
-(0.6)*x + (0.2)*y + (0.1)*z == 0,
(0.5)*w + (0.3)*x - y == 0,
(0.2)*w + (0.3)*x + (0.5)*y - (0.5)*z == 0,                                \
w + x + y + z == 1
}, 
{z , w , x , y}]

This is what i see:

image

$\endgroup$
  • $\begingroup$ NSolve instead of nslove - capitalization matters. $\endgroup$ – Vitaliy Kaurov Oct 4 '12 at 7:13
  • $\begingroup$ no difference. I think Mathematica corrects the input even if it's in plain english $\endgroup$ – whynot Oct 4 '12 at 7:15
  • $\begingroup$ don't get why the -1. $\endgroup$ – whynot Oct 4 '12 at 7:18
  • $\begingroup$ …No difference? Don't tell me that you always press "Ctrl+=" before you write the code. $\endgroup$ – xzczd Oct 4 '12 at 7:19
  • 1
    $\begingroup$ 囧, you don't press "Ctrl+=" but "="……then you're not calculate with mma, you're calculate with Wolfram|Alpha, a site like google… in fact even with "=" we can get the answer, but, you write a "\" after the 4th equation, see? $\endgroup$ – xzczd Oct 4 '12 at 7:31
2
$\begingroup$

Try this:

Clear[x, y, z, w];
eq1 = -0.7*w + 0.3*y + 0.4*z == 0;
eq2 = -0.6*x + 0.2*y + 0.1*z == 0;
eq3 = 0.5*w + 0.3*x - y == 0;
eq4 = 0.2*w + 0.3*x + 0.5*y - 0.5*z == 0;
eq5 = w + x + y + z == 1;
Solve[{eq1, eq2, eq3, eq4, eq5}, {z, w, x, y}]

The result is

{{z -> 0.384513, w -> 0.300401, x -> 0.126836, y -> 0.188251}}

I removed unnecessary parentheses. It seems that they were misleading for Mathematica.

The solution of 5 equation with 4 variables is possible, since the determinant of first 4 equations is zero:

  m = {{-0.7, 0, 0.3, 0.4}, {0, -0.6, 0.2, 0.1}, {0.5, 0.3, -1, 
    0}, {0.2, 0.3, 0.5, -0.5}, {1, 1, 1, 1}};
m[[1 ;; 4]] // Det // Chop

0

You could have skip one of them.

| improve this answer | |
$\endgroup$

Your Answer

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

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