Back to functions

solveEquations


solveEquations

Solves a system of linear equations. Has limited ability to solve system of nonlinear equations. With nonlinear equations, the first set of solutions which satisfies the constraints will be returned. Also keep in mind that there may be some floating point errors.

Usage: nerdamer("nerdamer.solveEquations(expression_or_array, variables)")


Parameters

Expression expressions_or_array An array of expression
String variables The variables to solve for.

Returns

Symbol[]

EXAMPLES:
var sol = nerdamer.solveEquations(['x+y=1', '2*x=6', '4*z+y=6']);
console.log(sol.toString());
sol = nerdamer.solveEquations('cos(x)+cos(3*x)=1','x');
console.log(sol.toString());
sol = nerdamer.solveEquations('x^2+8+y=x+6','x');
console.log(sol.toString());
nerdamer.set('SOLUTIONS_AS_OBJECT', true);
sol = nerdamer.solveEquations(['2*x-y=8', '10*x+7*y-z=53', '4*z+y=6']);
console.log(sol)
nerdamer.set('SOLUTIONS_AS_OBJECT', true)
// Linear solutions can be solved symbolically. Just pass in the variables to solve for
var solutions = nerdamer.solveEquations(['2*x-b*y=1', 'x+y=4'], ['x', 'y']);
console.log(JSON.stringify(solutions, null, 4))
// nerdamer also has some ability to solve some nonlinear equations
nerdamer.set('SOLUTIONS_AS_OBJECT', false);
sol = nerdamer('solveEquations([2*x^2*z-y=-59, 0.5*y^3-z=65.5, x^2+y^3-5*z^2=89])');
console.log(sol.toString());
OUTPUT:
Back to functions