Skip to content

Instantly share code, notes, and snippets.

@mauriciopoppe
Created April 1, 2016 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mauriciopoppe/ea0165640e82a7a230520648b63589e3 to your computer and use it in GitHub Desktop.
Save mauriciopoppe/ea0165640e82a7a230520648b63589e3 to your computer and use it in GitHub Desktop.
esnextbin sketch
<!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>
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)))
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"interval-arithmetic": "0.6.3"
}
}
'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