HTBasic Help
×
Menu
Index
Solve
Solve a system of linear equations.
 
Loading        LOADSUB ALL FROM "SOLVE.HTS"
or LOADSUB FROM "MATHLIB.HTS"
or LOADSUB Solve FROM "MATHLIB.HTS"
 
Usage                REAL A(*),B(*)
CALL Solve(A(*),B(*))
 
Description                
Solve finds the solution to the system of linear equations represented by A and B and returns the solution in B. A must be square, that is, it must have the same number of rows as columns. B must have the same number of rows as A and usually is a one-dimensional array (a vector). If A represents the matrix whose entries are stored in A and b represents the vector whose entries are stored in B, Solve finds the solution vector, x, for the matrix equation
 
Ax = b
 
 
and returns the solution in B, replacing the former contents of B. The contents of the array A are also destroyed by Solve.
 
The array B may be two-dimensional. In this case, after solve is called, each column in B contains the solution vector for the case when the input values in that column were used as b in the above equation.
 
Solve is equivalent to the BASIC lines
 
MAT Temp=INV(A)
MAT X=Temp*B
MAT B=X
 
except that the arrays Temp and X are not needed; the intermediate results overwrite some of the elements of A. Solve is faster than the above BASIC fragment, because the matrix inversion is not needed.
 
Errors                
Solve causes an HTBasic error if its arguments are both REAL arrays, if A is not square, if B doesn't have the same number of rows as A, or if A is singular.
 
See Also
Csolve