So I started writing tests for calculus.
Here's an example:
var assert = require('assert');
var numeric = require('../index.js');
var calculus = numeric.calculus;
suite('numeric', function() {
test('pointDiff should return the derivative at a point, provided function', function(done) {
var func = function(x) {
return 2 * x + 2;
};
assert.equal(2, calculus.pointDiff(func, 5));
done();
});
});
Now, the point derivative of 2x + 2 at any value is 2. The method returns the following: 1.9999999999242843
This is "basically" 2, but it won't pass tests. So I've considered two options:
- Handle this decimal stuff
- Set an error bound, which the user passes along when including numeric.
I like two more, although it certainly is going to be a hassle to set up. But this way we can have an "acceptable" error bound, which is sustainable and acceptable for the browser, and has minimal effect in performance or large scale operations.
So I started writing tests for calculus.
Here's an example:
Now, the point derivative of 2x + 2 at any value is 2. The method returns the following: 1.9999999999242843
This is "basically" 2, but it won't pass tests. So I've considered two options:
I like two more, although it certainly is going to be a hassle to set up. But this way we can have an "acceptable" error bound, which is sustainable and acceptable for the browser, and has minimal effect in performance or large scale operations.