Computor.Solver
This module will contain code for 2nd Degree equation resolution
val convert : Ast.polynome -> Ast.monome list
convert ast
takes the polynome represented as a recursive type and converts it to a type (coefficient:float, (variable:string * power:int) option) list
val ast_to_lists :
(Ast.polynome * Ast.polynome) ->
Ast.monome list * Ast.monome list
ast_to_lists (p1, p2)
takes a type (polynome * polynome)
and calls convert ast
on each polynome to return a (monome list * monome list)
to facilitate manipulation
sqrt x
is a reimplementation of classic sqrt function, it's presence is justified by the specifications of the ComputorV1 42 subject
val solve :
Stdlib.Format.formatter ->
(Ast.monome list * Ast.monome list) ->
unit
solve e
takes both monome lists and does all necessary operations that lead to solution. Invert all monomes of the righthand side polynome and concatenate to lefthand side one. Check for more than one variable, exit if so. Create a Hashtable of (key:power, value:coefficient)
. Check for a degree > 2, exit if so. Simplify list by combining same power monomes. Proceed to calculate delta and pretty-print the reduced form along with polynomial degree and solution(s).