algebra.ts
v0.3.1
Published
Build, display, and solve algebraic equations.
Downloads
6
Maintainers
Readme
algebra.ts
Copyright 2024 binary poetry gmbh
algebra.ts
lets you build, display and solve algebraic equations in TypeScript
and JavaScript.
It's a fork of algebra.js created by Nicole White and you can find the original copyright and license file in LICENSE_algebra-js.
Quick Start
This section gives a brief example on how to use the library. The library is assumed to be in the same directory as the HTML page containing the snippet. Alternatively you could load the library via a content delivery network (CDN), for example https://cdn.jsdelivr.net/npm/[email protected]/dist/algebra-0.3.0.umd.js.
Please refer to the full documentation for further information and live examples.
Using ES Modules
<script type="module">
import { Expression, Equation } from "algebra-x.y.z.esm.min.js"
const expr = new Expression("x")
expr = expr.subtract(3)
expr = expr.add("x")
console.log(String(expr)) // 2x - 3
const eq = new Equation(expr, 4)
console.log(String(eq)) // 2x - 3 = 4
const x = eq.solveFor("x")
console.log("x = " + String(x)) // x = 7/2
</script>
Using the UMD version
<script src="algebra-x.y.z.umd.min.js"></script>
<script>
const expr = new algebra.Expression("x")
expr = expr.subtract(3)
expr = expr.add("x")
console.log(String(expr)) // 2x - 3
const eq = new algebra.Equation(expr, 4)
console.log(String(eq)) // 2x - 3 = 4
const x = eq.solveFor("x")
console.log("x = " + String(x)) // x = 7/2
</script>
Contributing
Thanks for your interest in contributing! There are many ways to contribute to this project. Get started by having a look at CONTRIBUTING.md.
Funding
This project is powered by coffee, therefore I would appreciate if you could
thank you!