Next: Nonlinear Equations Up: Equations Previous: Equations

### Systems of Linear Equations

Solving systems of linear equations is accomplished by either the function
linsolve(A,b) (all versions of Jasymca), or linsolve2(A,b) (LAPACK, not in applet and midlet). In both cases A is the quadratic matrix of the system of equations, and b a (row or column) vector representing the right-hand-side of the equations. The equations may be written as and we solve for .
>> A=[2 3 1; 4 4 5; 2 9 3];
>> b=[0;3;1];
>> linsolve(A,b)
ans =
-0.25
-0.13636
0.90909
>> linsolve2(A,b) % not Applet or Midlet
ans =
-0.25
-0.13636
0.90909

For large numeric matrices one should use the LAPACK-version if available. The Jasymca version can also handle matrices containing exact or symbolic elements. To avoid rounding errors in these cases it is advisable to work with exact numbers if possible:
>> syms x,y
>> A=[x,1,-2,-2,0;1 2 3*y 4 5;1 2 2 0 1;9 1 6 0 -1;0 0 1 0]
A =
x    1    -2   -2   0   % symbolic element
1    2    3*y  4    5   % symbolic element
1    2    2    0    1
9    1    6    0    -1
0    0    1    0    0
>> b = [1 -2  3  2  4 ];
>> trigrat( linsolve( rat(A), b) )

ans =
(-6*y-13/2)/(x+8)
(20*y+(-9*x-151/3))/(x+8)
4
((-3*x+10)*y+(-49/4*x-367/6))/(x+8)
(-34*y+(13*x+403/6))/(x+8)


Helmut Dersch
2009-03-15