-
Notifications
You must be signed in to change notification settings - Fork 5
Equations
firepick1 (localhost) edited this page Mar 30, 2017
·
4 revisions
Equations is a mathjs extension for working with a collection of named expressions. Optimized for computation performance, the Equations class computes derivatives quickly and lets you compile() a Javascript function that evaluates all of the expressions for a given scope.
Create a Javscript line() function that evaluates and updates a scope object:
var eq = new Equations();
eq.set("y", "slope*x + intercept");
var line = eq.compile();
var scope = {
x:2,
slope:3,
intercept:10
};
line(scope).y.should.equal(16);Find the derivative expression of y:
eq.derivative("y","x").should.equal("y_dx");
var dy = eq.get("y_dx");
dy.should.equal("slope");