View source: R/make_system_of_equations.R
make_system_of_equations | R 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.
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 )
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? |
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
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.