-
-
Notifications
You must be signed in to change notification settings - Fork 30
API
Arthur Guiot edited this page Jan 28, 2018
·
3 revisions
This a temporary document.
const t = require("theorems.js")
/* List of functions */
/* Array Manipulation */
// Flatten
t.flatten([
[1, 2],
[3, 4], 5
]) // => [1, 2, 3, 4, 5]
// Linspace
t.linspace(0, 100, 10) // => [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
// Range
t.range(10) // => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
// Reshape
t.reshape(t.range(10), 2) /* => [
[0, 1],
[2, 3],
[4, 5],
[6, 7],
[8, 9],
[10]
]) */
/* Math */
/* Algebra */
// Function
t.f("x", "2*x+1") // => TheoremJS function object
// Run
t.run(f, x) // = f(x)
// Polynomial
t.polynomial(2, 1) // f(x) = 2x + 1
t.polynomial(3, 2, 1) // f(x) = 3x^2 + 2x + 1
// Find Roots
t.findRoots(t.polynomial(1, -1, -1)) // => ['(1 + Math.sqrt(5)) / 2', '(1 - Math.sqrt(5)) / 2']
// Numeral Solve
t.numeralSolve(t.f("x", "2*x+1"), 0) // => ['-0.5', 0] , Returns -0.5 with 0 error rate
// Y-Intercept
t.y_intercept(t.f("x", "2*x+1")) // => 1
/* Math Basic functions */
// Factorial (returns a BigNumber object)
t.factorial(5).toNumber() // => 120
// Pow (returns a BigNumber object)
t.pow(2, 8).toNumber() // => 256
// Root (returns a BigNumber object)
t.root(256, 8).toNumber() // => 2
// Sqrt (returns a BigNumber object)
t.sqrt(4).toNumber() // => 2
// Sigmoid (returns a BigNumber object)
t.sigmoid(0).toNumber() // => 0.5Any questions? Don't hesitate to create an issue and tell me about your problem 😊.
Copyright © 2017-2018 Arthur Guiot