algebra.js
algebra.js copied to clipboard
Solver can't solve to fractions with variables.
The solver can't solve to fractions with variables. For example the speed formula: s = a/t. So the solver can solve for 'a' -> a = st, but not for 't' -> undefined. Probably because Fraction can't handle variables in the numerator or denominator. This is a serious issue.
let expr = new Expression('s');
expr = expr.multiply('t');
const eq = new Equation(expr, new Expression('a'));
const aAnswer = eq.solveFor('a');
const tAnswer = eq.solveFor('t');
console.log(`a = ${aAnswer}`); // this works: a = st
console.log(`t = ${tAnswer}`); // this fails: t = undefined
I agree, this is a large problem. It prevents many simple things from being done. For example, simply doing new algebra.Expression("a").divide("b") causes an Uncaught TypeError: Invalid Argument (b): Divisor must be of type Fraction or Integer.