Solve a System of Linear Equations
# S3 method for caracas_symbol
solve(a, b, ...)
caracas_symbol
If provided, either a caracas_symbol (if not, as_sym()
is called on the object)
Not used
if (has_sympy()) {
A <- matrix_sym(2, 2, "a")
b <- vector_sym(2, "b")
# Inverse of A:
solve(A)
inv(A)
solve(A) %*% A |> simplify()
# Find x in Ax = b
x <- solve(A, b)
A %*% x |> simplify()
solve(A, c(2, 1)) |> simplify()
}
#> c: ⎡ -a₁₂ + 2⋅a₂₂ a₁₁ - 2⋅a₂₁ ⎤
#> ⎢───────────────── ─────────────────⎥
#> ⎣a₁₁⋅a₂₂ - a₁₂⋅a₂₁ a₁₁⋅a₂₂ - a₁₂⋅a₂₁⎦ᵀ