solveeqs
Solves linear, nonlinear, symbolic, and supported non-polynomial systems and returns solution assignments.
System solving goes well beyond square linear systems. Nerdamer can preserve free variables in underdetermined linear systems, accept consistent overdetermined systems, solve supported nonlinear polynomial systems exactly, retain irrational and complex solutions, and fall back to numerical multivariate solving for supported systems containing functions such as trigonometric expressions.
Nerdamer Notation uses solveeqs(...). The JavaScript / TypeScript API uses solveSystem(...) and can additionally receive an explicit variable order, which is useful when other symbols should be treated as parameters rather than unknowns.
Solutions are returned as dictionaries inside a Vector. Nonlinear solving can return several isolated assignments, while underdetermined linear systems express pivot variables in terms of the remaining free variables.
Examples
These examples use Nerdamer Notation.
Solve an underdetermined linear system and retain z as a free variable.
solveeqs([x+y+z=6,x-y=2])
// → [{x => 4+(-1/2)*z, y => 2+(-1/2)*z, z => z}]Find both exact intersections of a parabola and a line: (-1,1) and (2,4).
solveeqs([y=x^2,y=x+2])
// → [{x => 2, y => 4}, {x => -1, y => 1}]Solve a nonlinear geometric system exactly, preserving the two irrational circle-line intersections.
solveeqs([x^2+y^2=1,y=x])
// → [{x => (1/2)*2^(1/2), y => (1/2)*2^(1/2)}, {x => (-1/2)*2^(1/2), y => (-1/2)*2^(1/2)}]Solve a nonlinear three-variable system with six isolated solutions.
solveeqs([x*y*z=6,x+y+z=6,x^2+y^2+z^2=14])
// → [{x => 2, y => 3, z => 1}, {x => 3, y => 2, z => 1}, {x => 1, y => 3, z => 2}, {x => 3, y => 1, z => 2}, {x => 1, y => 2, z => 3}, {x => 2, y => 1, z => 3}]Use numerical multivariate solving for a mixed trigonometric-polynomial system; the real solutions are approximately x=±2.68259128682539 and y=-0.196296012151496.
solveeqs([cos(x)^2-y-1=0,x^2+y-7=0])
// → [{x => -2.6825912868253889607, y => -0.19629601215149626377}, {x => 2.6825912868253889607, y => -0.19629601215149626377}]Solve a linear system whose coefficients and solutions are complex.
solveeqs([2*X1-4*X2+2*i=3,-5*X1+8*X2*i-4*i*X1=2])
// → [{X1 => -6/5+(-6/5)*i, X2 => (-1/10)*(27/2+i)}]Accept a consistent overdetermined system instead of requiring exactly one equation per unknown.
solveeqs([x+y=1,2*x=6,4*z+y=6,y=-z])
// → [{x => 3, y => -2, z => 2}]Clear a rational denominator while preserving the valid exact system solution.
solveeqs([x=5,3/5=1-x/(10+y)])
// → [{x => 5, y => 5/2}]Solve a system containing a transcendental function numerically rather than rejecting it as non-polynomial.
solveeqs([sin(x)=0,y=1])
// → [{x => -9.4247779607686356079, y => 1}, {x => 0, y => 1}, {x => 9.4247779607693797154, y => 1}]Interfaces
The same operation is available through the interfaces below.
Nerdamer Notation
Use this form inside input passed to nerdamer(...).
solveeqs(arg1)
nerdamer.solveSystem
Call the operation through the default nerdamer import.
nerdamer.solveSystem(equations: Vector | Equation | ExpressionInput[], variables?: string[]): Vector
Parameters
| Name | Type | Description |
|---|---|---|
equations | Vector | Equation | ExpressionInput[] | Vector or array of equations and zero-valued expressions. |
variables | string[] | Optional variable order. When omitted, variables are collected from the normalized expressions. |
Returns
Vector — A Vector of solution dictionaries keyed by variable name.
Direct JavaScript / TypeScript API
Import the operation directly from its package entry point.
import { solveSystem } from 'nerdamer/solve';
solveSystem(equations: Vector | Equation | ExpressionInput[], variables?: string[]): Vector
Parameters
| Name | Type | Description |
|---|---|---|
equations | Vector | Equation | ExpressionInput[] | Vector or array of equations and zero-valued expressions. |
variables | string[] | Optional variable order. When omitted, variables are collected from the normalized expressions. |
Returns
Vector — A Vector of solution dictionaries keyed by variable name.
Notes
- Underdetermined linear systems are parameterized using their free variables. Nonlinear systems with a non-isolated infinite solution set are not currently represented this way and can throw an UnsupportedOperationError.
- Numerical multivariate solving returns roots found within the solver's search strategy; it does not turn a periodic function such as sin(x)=0 into an infinite symbolic family. Use solve(...) for symbolic periodic families when solving a single equation.
- Use solveSystem(equations, variables) in JavaScript / TypeScript when the unknown-variable list must be supplied explicitly.
Related API names
solveSystem
