Learn R Programming

matlib (version 0.6.0)

gaussianElimination: Gaussian Elimination

Description

gaussianElimination demonstrates the algorithm of row reduction used for solving systems of linear equations of the form $A x = B$. Optional arguments verbose and fractions may be used to see how the algorithm works.

Usage

gaussianElimination(A, B, tol = sqrt(.Machine$double.eps), verbose = FALSE,
  fractions = FALSE)

Arguments

A
coefficient matrix
B
right-hand side vector or matrix. If B is a matrix, the result gives solutions for each column as the right-hand side of the equations with coefficients in A.
tol
tolerance for checking for 0 pivot
verbose
logical; if TRUE, print intermediate steps
fractions
logical; if TRUE, try to express nonintegers as rational numbers

Value

  • If B is absent, returns the reduced row-echelon form of A. If B is present, returns the reduced row-echelon form of A, with the same operations applied to B.

Examples

Run this code
A <- matrix(c(2, 1, -1,
               -3, -1, 2,
               -2,  1, 2), 3, 3, byrow=TRUE)
  b <- c(8, -11, -3)
  gaussianElimination(A, b)
  gaussianElimination(A, b, verbose=TRUE, fractions=TRUE)

Run the code above in your browser using DataLab