made with esnextbin
Created
April 1, 2016 17:34
-
-
Save mauriciopoppe/ea0165640e82a7a230520648b63589e3 to your computer and use it in GitHub Desktop.
esnextbin sketch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>ESNextbin Sketch</title> | |
<!-- put additional styles and scripts here --> | |
</head> | |
<body> | |
<!-- put markup and other contents here --> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Interval from 'interval-arithmetic' | |
// represents x^2 + 5x | |
function fn(x) { | |
var op = Interval.add( | |
Interval.pow(x, 2), | |
Interval.mul(Interval(5),x) | |
) | |
return Interval.width(op) | |
} | |
console.log(fn(Interval(-5.01, -5.00))) | |
console.log(fn(Interval(-2.51, -2.50))) | |
console.log(fn(Interval(0.00, 0.01))) | |
console.log(fn(Interval(2.50, 2.51))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "esnextbin-sketch", | |
"version": "0.0.0", | |
"dependencies": { | |
"interval-arithmetic": "0.6.3" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var _intervalArithmetic = require('interval-arithmetic'); | |
var _intervalArithmetic2 = _interopRequireDefault(_intervalArithmetic); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
// represents x^2 + 5x | |
function fn(x) { | |
var op = _intervalArithmetic2.default.add(_intervalArithmetic2.default.pow(x, 2), _intervalArithmetic2.default.mul((0, _intervalArithmetic2.default)(5), x)); | |
return _intervalArithmetic2.default.width(op); | |
} | |
console.log(fn((0, _intervalArithmetic2.default)(-5.01, -5.00))); | |
console.log(fn((0, _intervalArithmetic2.default)(-2.51, -2.50))); | |
console.log(fn((0, _intervalArithmetic2.default)(0.00, 0.01))); | |
console.log(fn((0, _intervalArithmetic2.default)(2.50, 2.51))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment