make_system_of_equations: Simulate a system of equations Ax = b Simulate a systemt of...

View source: R/make_system_of_equations.R

make_system_of_equationsR Documentation

Simulate a system of equations Ax = b Simulate a systemt of equations Ax = b that is (usually) easy to solve using RREF without needing many complicated fractions.

Description

Simulate a system of equations Ax = b Simulate a systemt of equations Ax = b that is (usually) easy to solve using RREF without needing many complicated fractions.

Usage

make_system_of_equations(
  n_equations,
  n_variables,
  dim_col = min(n_equations, n_variables),
  dim_null = n_variables - dim_col,
  is_consistent = ifelse(dim_col == n_equations, TRUE, sample(c(TRUE, FALSE), 1)),
  is_homogeneous = FALSE
)

Arguments

n_equations

The number of equations in the system (the number of rows for the matrix A).

n_variables

The number of variables in the system (the number of columns for the matrix A).

dim_col

The dimension of the column space. Must be between 1 and the minimum of the number of n_equations and n_variables.

dim_null

The dimension of the column space. Must be between 1 and the minimum of the number of n_equations and n_variables.

is_consistent

Is the system of equations Ax = b consistent (Is there a solution)?

is_homogeneous

Is the vector b equal to the 0 vector?

Value

A list that contains the matrix A and the vector b. If the system of equations is not homogeneous or consistent, the list will also contain the solution vector x

Examples

n_equations <- 7
n_variables <- 5
dim_col = min(n_equations, n_variables)
dim_null = n_variables - dim_col
eq <- make_system_of_equations(n_equations, n_variables, dim_col = 2, is_consistent = TRUE)
str(eq)
rref(cbind(eq$A, eq$b))
if(eq$is_consistent)
  all.equal(eq$A %*% eq$x, eq$b)

jtipton25/dasc2594 documentation built on Oct. 7, 2022, 3:46 p.m.