Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

share|improve this question
    
NSolve instead of nslove - capitalization matters. –  Vitaliy Kaurov Oct 4 '12 at 7:13
    
no difference. I think Mathematica corrects the input even if it's in plain english –  whynot Oct 4 '12 at 7:15
    
don't get why the -1. –  whynot Oct 4 '12 at 7:18
    
…No difference? Don't tell me that you always press "Ctrl+=" before you write the code. –  xzczd Oct 4 '12 at 7:19
1  
囧, 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? –  xzczd Oct 4 '12 at 7:31
show 10 more comments

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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