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.

When I tried to solve the equation below, I got the $4$ errors. Since I am pretty new on Mathematica, I don't know what I did wrong.

$24x_1+20x_2+16x_3=4$
$20x_1+20x_2+19x_3=36$
$16x_1+19x_2+38x_3=19$

This system is set to solve in Jacobi method after $40$ iterations. Initial approximation is $x_1(0)=0, x_2(0)=0, x_3(0)=0$. I would appreciate it if someone could recommend other methods that I can use for this system!

share|improve this question

migrated from math.stackexchange.com Jan 24 at 14:48

This question came from our site for people studying math at any level and professionals in related fields.

    
Please post your (eventually non working) code –  belisarius Jan 24 at 14:51
    
Rewrite it in matrix form and use LinearSolve. –  bill s Jan 24 at 15:20
    
Not going to work with Jacobi iterations. The inverse diagonal matrix times coeff matrix - diagonal matrix has two singular values larger than 1. So you don't get convergence. –  Daniel Lichtblau Jan 24 at 16:42

2 Answers 2

Your system is easily solved with Solve. Note the double equal (==), a single equal (=) wont work because it denotes assignment in Mathematica.

Solve[{
  24 x1 + 20 x2 + 16 x3 == 40,
  20 x1 + 20 x2 + 19 x3 == 36,
  16 x1 + 19 x2 + 38 x3 == 19}, 
  {x1, x2, x3}]
{{x1 -> 57/118, x2 -> 349/177, x3 -> -(122/177)}}
share|improve this answer
    
The first equation in Solve does not exactly match the OP's equation (40-->4), so the posted result is not correct. –  David Skulsky Jan 24 at 22:22

And if you like to use LinearSolve

eqs={24 x1 +20 x2 + 16 x3 == 4,20 x1 + 20 x2 + 19 x3 == 36,16 x1 + 19 x2 + 38 x3 == 19};
vars = {x1, x2, x3};
mat = CoefficientArrays[eqs, vars];
sol = LinearSolve[mat[[2]], -mat[[1]]]

(* {-(570/59), 2401/177, -(392/177)} *)
share|improve this answer

Your Answer

 
discard

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