Learn R Programming

TUGLab (version 0.0.1)

solvels: Solve linear system

Description

This function classifies and solves the given linear system.

Usage

solvels(A, tol = 100 * .Machine$double.eps)

Value

This function returns two outputs: solution and flag. If the introduced linear system is inconsistent: flag=-1 and solution=Inf. If it is consistent and has infinitely many solutions: flag=0 and solution returns one of the solutions, as a vector. If it is consistent and has a unique solution: flag=1 and solution returns the unique solution, as a vector.

Arguments

A

The augmented matrix of a linear system.

tol

A tolerance parameter, as a non-negative number.
By default, tol=100*.Machine$double.eps.

Examples

Run this code
# Consistent and determinate system:
solvels(matrix(c(1,1,1,6,2,-1,1,3,-1,-1,1,0), byrow=TRUE, nrow = 3, ncol = 4))
# Consistent and indeterminate system:
solvels(matrix(c(1,1,-3,0,2,-1,-3,3,4,1,-9,3), byrow=TRUE, nrow = 3, ncol = 4))
# Inconsistent system:
solvels(matrix(c(-2,1,1,1,1,-2,1,1,1,1,-2,1), byrow=TRUE, nrow = 3, ncol = 4))

Run the code above in your browser using DataLab