JMathLabTutorial:Equations (Linear Systems)

From jWork.ORG
Jump to: navigation, search
Limitted access. Reguest membership or login to this link first if you are already a member

Systems of Linear Equations

Solving systems of linear equations is accomplished by either the function linsolve(A,b), or linsolve2(A,b) (LAPACK). 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 $A\cdot z = b$ and we solve for $z$.

A=[2 3 1; 4 4 5; 2 9 3];
% a=linsolve2(A,b) % for JLAPAC
% printf('%f\n',a)

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] 
b = [1 -2  3  2  4 ];
a=trigrat( linsolve( rat(A), b) )