-
-
Notifications
You must be signed in to change notification settings - Fork 30
Algebra
Arthur Guiot edited this page May 14, 2018
·
7 revisions
In order to create a function, you'll need to use the f function like that:
const f = t.f("x", "2*x+1") // => TheoremJS function objectYou can "run" these functions using run:
t.run(f, 5) // = 11You can create polynomials using polynomial like that:
const poly1 = t.polynomial(2, 1) // f(x) = 2x + 1 => TheoremJS polynomial object
const poly2 = t.polynomial(3, 2, 1) // f(x) = 3x^2 + 2x + 1 => TheoremJS polynomial objectThis will only work for polynomials
You can find the roots of a polynomial using findRoots. It will return an array of Strings that you can parse using eval() in JavaScript to get the solution as a number.
Example:
t.findRoots(t.polynomial(1, -1, -1)) // => ['(1 + Math.sqrt(5)) / 2', '(1 - Math.sqrt(5)) / 2']Any questions? Don't hesitate to create an issue and tell me about your problem 😊.
Copyright © 2017-2018 Arthur Guiot