A numerical solver for non-linear systems of equations, utilizing the n-dimensional Newton-Raphson method.
npm install fsolve-js
Here is a simple example to help you get started with fsolve-js
:
import { Matrix, matrix, zeros } from "mathjs";
import { Differentiator } from "./differentiator";
import { Solver } from "./solver";
let slvr = new Solver(1e-3, 1e10, Infinity, 1e-6);
let diff = new Differentiator();
let x0 = matrix([[20], [-2]]);
let f = (x: Matrix) => matrix([
[Math.pow(x.get([0, 0]), 2) + Math.pow(x.get([1, 0]), 2) - 10],
[Math.cos(x.get([0,0])) - x.get([1,0])]
]);
console.log(slvr.solve(f, x0));
Juan Esteban Arboleda Restrepo
Github: j-arb
Email: juanesteban.arboledagc@gmail.com
Copyright (C) Juan Arboleda <juanesteban.arboledagc@gmail.com>
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <https://www.gnu.org/licenses/>.