Muscat

GitHub GitHub last commit Hex.pm

A simple pure elixir equation solver by augmented matrix.

Installation

def deps do
  [
    {:muscat, "~> 0.2"}
  ]
end

Usage

Very simple ! For example, To solve this equation:

pic

  1. Create a augmented matrix by:
coefficient_matrix_parameter = [[1, 2, 3], [3, 4, 7], [6, 5, 9]]
constant_column = [0, 2, 11]

Muscat.new(coefficient_matrix_parameter, constant_column)

Or

augmented_matrix_parameter = [[1, 2, 3, 0], [3, 4, 7, 2], [6, 5, 9, 11]]

Muscat.new(augmented_matrix_parameter)
  1. Run rref/1 or rref/2 to solve the equation:
Muscat.rref(augmented_matrix)
#=> {:ok, [4, 1, -2]}

Fraction

Muscat.new/1 and Muscat.new/2 support fraction value in parameters:

Muscat.new([{1, 2}, 1])

{1, 2} means 1/2, the first element in tuple is numerator and the second one is denominator.

Muscat.Fraction also provides some simple fraction calculation rules. See more details in the module doc.

Targets

  • [x] a unique solution
  • [ ] infinite solutions
  • [ ] approximate solutions