From 274647998fb9a1cdec2d71df0a266be9a98e8248 Mon Sep 17 00:00:00 2001 From: Mauricio Poppe Date: Sat, 29 Oct 2016 16:09:41 -0700 Subject: [PATCH] Build: chore release --- CHANGELOG.md | 479 +++++++++++++++++++++++++++++++++++++++ dist/function-plot.js | 10 +- site/js/function-plot.js | 10 +- 3 files changed, 489 insertions(+), 10 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..289d33a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,479 @@ + +# [1.17.0](https://github.com/maurizzzio/function-plot/compare/v1.16.5...v1.17.0) (2016-07-01) + + +### New + +* xAxis,yAxis invert option ([d73e78f86e566301f4619be942e1da4de457203d](https://github.com/maurizzzio/function-plot/commit/d73e78f86e566301f4619be942e1da4de457203d)), closes [#69](https://github.com/maurizzzio/function-plot/issues/69) + + + + +## [1.16.5](https://github.com/maurizzzio/function-plot/compare/v1.16.4...v1.16.5) (2016-04-24) + + + + + +## [1.16.4](https://github.com/maurizzzio/function-plot/compare/v1.16.3...v1.16.4) (2016-03-23) + + + + + +## [1.16.3](https://github.com/maurizzzio/function-plot/compare/v1.16.2...v1.16.3) (2016-02-06) + + + + + +## [1.16.2](https://github.com/maurizzzio/function-plot/compare/v1.16.1...v1.16.2) (2015-12-31) + + +### Fix + +* whenever there's a zoom operation the translate/scale properties are dispatched instead of the scales ([28c90691c0f8a5e4147e7df0e1527e57925acfc8](https://github.com/maurizzzio/function-plot/commit/28c90691c0f8a5e4147e7df0e1527e57925acfc8)), closes [#50](https://github.com/maurizzzio/function-plot/issues/50) + + + + +## [1.16.1](https://github.com/maurizzzio/function-plot/compare/v1.16.0...v1.16.1) (2015-12-23) + + + + + +# [1.16.0](https://github.com/maurizzzio/function-plot/compare/v1.15.0...v1.16.0) (2015-12-23) + + +### New + +* logarithmic axes ([50b9271bd0a298cbe301127764d5b7a622448e77](https://github.com/maurizzzio/function-plot/commit/50b9271bd0a298cbe301127764d5b7a622448e77)) + + + + +# [1.15.0](https://github.com/maurizzzio/function-plot/compare/v1.12.4...v1.15.0) (2015-12-10) + + +### Fix + +* playground script updated ([bf2164945dd9236ea876974295c1b5dc79678425](https://github.com/maurizzzio/function-plot/commit/bf2164945dd9236ea876974295c1b5dc79678425)) +* vector now uses offset instead of displacement ([83f7dce2cd9ac939de35c7e64476465ae471c481](https://github.com/maurizzzio/function-plot/commit/83f7dce2cd9ac939de35c7e64476465ae471c481)) + +### New + +* graphOptions is now flattened into each datum ([e0108c906273f6c7a03fcbdedacafea6949ece3a](https://github.com/maurizzzio/function-plot/commit/e0108c906273f6c7a03fcbdedacafea6949ece3a)) + + + + +## [1.12.4](https://github.com/maurizzzio/function-plot/compare/v1.12.3...v1.12.4) (2015-10-12) + + +### Docs + +* style selectors ([0e6c0688ade8d6468d17382070adc06a0e952971](https://github.com/maurizzzio/function-plot/commit/0e6c0688ade8d6468d17382070adc06a0e952971)) +* style selectors ([c99d722db69a955c8ac5d7e90e5b9678b887e4e9](https://github.com/maurizzzio/function-plot/commit/c99d722db69a955c8ac5d7e90e5b9678b887e4e9)) +* style selectors ([c69f46e818d78872ef408e78ab66ef3ba26e95de](https://github.com/maurizzzio/function-plot/commit/c69f46e818d78872ef408e78ab66ef3ba26e95de)) + +### Fix + +* standard check ([7365a0a23982efaf6700bfd7c443fbde526e4762](https://github.com/maurizzzio/function-plot/commit/7365a0a23982efaf6700bfd7c443fbde526e4762)) +* top margin modification because of the title computed before calculating the width/height of the graph ([f1f62670852ccdaa832b9ca10081910b4cc5b687](https://github.com/maurizzzio/function-plot/commit/f1f62670852ccdaa832b9ca10081910b4cc5b687)), closes [#41](https://github.com/maurizzzio/function-plot/issues/41) + + + + +## [1.12.3](https://github.com/maurizzzio/function-plot/compare/v1.12.2...v1.12.3) (2015-10-02) + + +### Fix + +* path d attribute clamped to the viewport dimensions ([9ed5711d77160027a546b41f3caa3e75877443b3](https://github.com/maurizzzio/function-plot/commit/9ed5711d77160027a546b41f3caa3e75877443b3)) + + + + +## [1.12.2](https://github.com/maurizzzio/function-plot/compare/v1.12.1...v1.12.2) (2015-09-07) + + +### Fix + +* vector graphOptions are now correctly populated ([555dc4ea2c88edfc8363e881c8a80fe945b22986](https://github.com/maurizzzio/function-plot/commit/555dc4ea2c88edfc8363e881c8a80fe945b22986)) + + + + +## [1.12.1](https://github.com/maurizzzio/function-plot/compare/v1.12.0...v1.12.1) (2015-09-07) + + +### New + +* vector no longer needs the graphOptions configuration options ([7a2f09e4a9a4b2bd46a2e48cacc783944c541d0a](https://github.com/maurizzzio/function-plot/commit/7a2f09e4a9a4b2bd46a2e48cacc783944c541d0a)) + + + + +# [1.12.0](https://github.com/maurizzzio/function-plot/compare/v1.11.2...v1.12.0) (2015-09-06) + + +### Docs + +* added tickFormat recipe ([e622df80dc9317c3a04cb6a82898bb50d60a2f98](https://github.com/maurizzzio/function-plot/commit/e622df80dc9317c3a04cb6a82898bb50d60a2f98)) + +### New + +* 2d vector plot ([78c503b49c4335ec84329d4f4c606550deb8a729](https://github.com/maurizzzio/function-plot/commit/78c503b49c4335ec84329d4f4c606550deb8a729)) + + + + +## [1.11.2](https://github.com/maurizzzio/function-plot/compare/v1.11.1...v1.11.2) (2015-09-05) + + +### Build + +* dist files generated ([b4a64420b82d550eb1fb8cecfb9145932810970a](https://github.com/maurizzzio/function-plot/commit/b4a64420b82d550eb1fb8cecfb9145932810970a)) + +### Fix + +* Custom format the ticks based on the value ([0a6941e70c5237f8219cd68771e54b52f9166b3c](https://github.com/maurizzzio/function-plot/commit/0a6941e70c5237f8219cd68771e54b52f9166b3c)), closes [#38](https://github.com/maurizzzio/function-plot/issues/38) + + + + +## [1.11.1](https://github.com/maurizzzio/function-plot/compare/v1.11.0...v1.11.1) (2015-09-05) + + +### Fix + +* Content is drawn before the tips ([487f1221a02faf32d7cc734970d4f7c91d750491](https://github.com/maurizzzio/function-plot/commit/487f1221a02faf32d7cc734970d4f7c91d750491)), closes [#37](https://github.com/maurizzzio/function-plot/issues/37) +* tip color now matches data[i].color ([867c31ff2a16e23a8b6e981d27bb81d39a99b9dd](https://github.com/maurizzzio/function-plot/commit/867c31ff2a16e23a8b6e981d27bb81d39a99b9dd)), closes [#36](https://github.com/maurizzzio/function-plot/issues/36) + + + + +# [1.11.0](https://github.com/maurizzzio/function-plot/compare/v1.10.1...v1.11.0) (2015-09-04) + + +### Breaking + +* `functionPlot.constants` renamed to `functionPlot.globals` ([5c23552d582c565eae537080678f64a9a9b2c72d](https://github.com/maurizzzio/function-plot/commit/5c23552d582c565eae537080678f64a9a9b2c72d)) + +### Docs + +* added option `grid` ([353d4c2e0f38d27721b6f3243369d171639ff954](https://github.com/maurizzzio/function-plot/commit/353d4c2e0f38d27721b6f3243369d171639ff954)) + +### Fix + +* color retrieval function moved from index.js to lib/utils.js ([fa530477a4ad9921192c6f8e5718a69dbaf0b24e](https://github.com/maurizzzio/function-plot/commit/fa530477a4ad9921192c6f8e5718a69dbaf0b24e)) + + + + +## [1.10.1](https://github.com/maurizzzio/function-plot/compare/v1.10.0...v1.10.1) (2015-09-04) + + +### Breaking + +* `instance.update` replaced with `instance.build` ([15f94f4ef9d1d89a94ee376229f2b2a2f90414bf](https://github.com/maurizzzio/function-plot/commit/15f94f4ef9d1d89a94ee376229f2b2a2f90414bf)) + + + + +# [1.10.0](https://github.com/maurizzzio/function-plot/compare/v1.9.5...v1.10.0) (2015-09-03) + + +### New + +* Added the option grid ([71bcf950e3c68ab180ff464abb114118a4f870bf](https://github.com/maurizzzio/function-plot/commit/71bcf950e3c68ab180ff464abb114118a4f870bf)) + + + + +## [1.9.5](https://github.com/maurizzzio/function-plot/compare/v1.9.4...v1.9.5) (2015-09-03) + + +### Fix + +* Graph colors are now updated in selection.update instead of selection.enter ([4f7b7c9572d0165d273d1d07750edc94627aa042](https://github.com/maurizzzio/function-plot/commit/4f7b7c9572d0165d273d1d07750edc94627aa042)), closes [#34](https://github.com/maurizzzio/function-plot/issues/34) + + + + +## [1.9.4](https://github.com/maurizzzio/function-plot/compare/v1.9.3...v1.9.4) (2015-08-25) + + + + + +## [1.9.3](https://github.com/maurizzzio/function-plot/compare/v1.9.2...v1.9.3) (2015-08-22) + + + + + +## [1.9.2](https://github.com/maurizzzio/function-plot/compare/v1.9.1...v1.9.2) (2015-08-12) + + + + + +## [1.9.1](https://github.com/maurizzzio/function-plot/compare/v1.9.0...v1.9.1) (2015-08-11) + + + + + +# [1.9.0](https://github.com/maurizzzio/function-plot/compare/v1.8.0...v1.9.0) (2015-08-11) + + + + + +# [1.8.0](https://github.com/maurizzzio/function-plot/compare/v1.7.0...v1.8.0) (2015-08-02) + + + + + +# [1.7.0](https://github.com/maurizzzio/function-plot/compare/v1.6.2...v1.7.0) (2015-07-27) + + + + + +## [1.6.2](https://github.com/maurizzzio/function-plot/compare/v1.6.1...v1.6.2) (2015-07-25) + + + + + +## [1.6.1](https://github.com/maurizzzio/function-plot/compare/v1.6.0...v1.6.1) (2015-07-24) + + + + + +# [1.6.0](https://github.com/maurizzzio/function-plot/compare/v1.5.0...v1.6.0) (2015-07-23) + + + + + +# [1.5.0](https://github.com/maurizzzio/function-plot/compare/v1.4.8...v1.5.0) (2015-07-23) + + + + + +## [1.4.8](https://github.com/maurizzzio/function-plot/compare/v1.4.7...v1.4.8) (2015-07-23) + + + + + +## [1.4.7](https://github.com/maurizzzio/function-plot/compare/v1.4.6...v1.4.7) (2015-07-23) + + + + + +## [1.4.6](https://github.com/maurizzzio/function-plot/compare/v1.4.5...v1.4.6) (2015-07-23) + + + + + +## [1.4.5](https://github.com/maurizzzio/function-plot/compare/v1.4.4...v1.4.5) (2015-07-23) + + + + + +## [1.4.4](https://github.com/maurizzzio/function-plot/compare/v1.4.3...v1.4.4) (2015-07-23) + + + + + +## [1.4.3](https://github.com/maurizzzio/function-plot/compare/v1.4.2...v1.4.3) (2015-07-23) + + + + + +## [1.4.2](https://github.com/maurizzzio/function-plot/compare/v1.4.1...v1.4.2) (2015-07-22) + + + + + +## [1.4.1](https://github.com/maurizzzio/function-plot/compare/v1.4.0...v1.4.1) (2015-07-22) + + + + + +# [1.4.0](https://github.com/maurizzzio/function-plot/compare/v1.3.0...v1.4.0) (2015-07-22) + + + + + +# [1.3.0](https://github.com/maurizzzio/function-plot/compare/v1.2.0...v1.3.0) (2015-05-20) + + + + + +# [1.2.0](https://github.com/maurizzzio/function-plot/compare/v1.1.1...v1.2.0) (2015-05-20) + + + + + +## [1.1.1](https://github.com/maurizzzio/function-plot/compare/v1.1.0...v1.1.1) (2015-05-19) + + + + + +# [1.1.0](https://github.com/maurizzzio/function-plot/compare/v1.0.3...v1.1.0) (2015-05-19) + + + + + +## [1.0.3](https://github.com/maurizzzio/function-plot/compare/v1.0.2...v1.0.3) (2015-05-19) + + + + + +## [1.0.2](https://github.com/maurizzzio/function-plot/compare/v1.0.1...v1.0.2) (2015-05-19) + + + + + +## [1.0.1](https://github.com/maurizzzio/function-plot/compare/v1.0.0...v1.0.1) (2015-05-19) + + + + + +# [1.0.0](https://github.com/maurizzzio/function-plot/compare/v0.6.0...v1.0.0) (2015-05-18) + + + + + +# [0.6.0](https://github.com/maurizzzio/function-plot/compare/v0.5.3...v0.6.0) (2015-04-24) + + + + + +## [0.5.3](https://github.com/maurizzzio/function-plot/compare/v0.5.2...v0.5.3) (2015-04-23) + + + + + +## [0.5.2](https://github.com/maurizzzio/function-plot/compare/v0.5.1...v0.5.2) (2015-04-23) + + + + + +## [0.5.1](https://github.com/maurizzzio/function-plot/compare/v0.5.0...v0.5.1) (2015-04-23) + + + + + +# [0.5.0](https://github.com/maurizzzio/function-plot/compare/v0.4.1...v0.5.0) (2015-04-23) + + + + + +## [0.4.1](https://github.com/maurizzzio/function-plot/compare/v0.4.0...v0.4.1) (2015-04-18) + + + + + +# [0.4.0](https://github.com/maurizzzio/function-plot/compare/v0.3.3...v0.4.0) (2015-04-15) + + + + + +## [0.3.3](https://github.com/maurizzzio/function-plot/compare/v0.3.2...v0.3.3) (2015-04-05) + + + + + +## [0.3.2](https://github.com/maurizzzio/function-plot/compare/v0.3.1...v0.3.2) (2015-04-05) + + + + + +## [0.3.1](https://github.com/maurizzzio/function-plot/compare/v0.3.0...v0.3.1) (2015-04-05) + + + + + +# [0.3.0](https://github.com/maurizzzio/function-plot/compare/v0.2.5...v0.3.0) (2015-04-05) + + + + + +## [0.2.5](https://github.com/maurizzzio/function-plot/compare/v0.2.4...v0.2.5) (2015-04-03) + + + + + +## [0.2.4](https://github.com/maurizzzio/function-plot/compare/v0.2.3...v0.2.4) (2015-04-02) + + + + + +## [0.2.3](https://github.com/maurizzzio/function-plot/compare/v0.2.2...v0.2.3) (2015-04-02) + + + + + +## [0.2.2](https://github.com/maurizzzio/function-plot/compare/v0.2.1...v0.2.2) (2015-03-31) + + + + + +## [0.2.1](https://github.com/maurizzzio/function-plot/compare/v0.2.0...v0.2.1) (2015-03-31) + + + + + +# [0.2.0](https://github.com/maurizzzio/function-plot/compare/v0.1.0...v0.2.0) (2015-03-31) + + + + + +# 0.1.0 (2015-03-31) + + + + diff --git a/dist/function-plot.js b/dist/function-plot.js index cd82d8d..d231ee4 100644 --- a/dist/function-plot.js +++ b/dist/function-plot.js @@ -1,5 +1,5 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.functionPlot=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;ogHi){var t=gLo;gLo=gHi;gHi=t}var hi=Math.min(vHi,gHi);var lo=Math.max(vLo,gLo);if(lo>hi){return[-minWidthHeight,0]}return[lo,hi]}var line=function(points,closed){var path="";var range=yScale.range();var minY=Math.min.apply(Math,range);var maxY=Math.max.apply(Math,range);for(var i=0,length=points.length;i path.line").data(evaluatedData);minWidthHeight=Math.max(evaluatedData[0].scaledDx,1);innerSelection.enter().append("path").attr("class","line line-"+index).attr("fill","none");innerSelection.attr("stroke-width",minWidthHeight).attr("stroke",utils.color(d,index)).attr("opacity",closed?.5:1).attr("d",function(d){return line(d,closed)}).attr(d.attr);innerSelection.exit().remove()})}return plotLine}},{"../evaluate":3,"../utils":22}],7:[function(require,module,exports){"use strict";var d3=window.d3;var evaluate=require("../evaluate");var utils=require("../utils");module.exports=function(chart){var xScale=chart.meta.xScale;var yScale=chart.meta.yScale;var line=d3.svg.line().interpolate("linear").x(function(d){return xScale(d[0])}).y(function(d){return yScale(d[1])});var area=d3.svg.area().x(function(d){return xScale(d[0])}).y0(yScale(0)).y1(function(d){return yScale(d[1])});function plotLine(selection){selection.each(function(d){var el=plotLine.el=d3.select(this);var index=d.index;var evaluatedData=evaluate(chart,d);var color=utils.color(d,index);var innerSelection=el.selectAll(":scope > path.line").data(evaluatedData);innerSelection.enter().append("path").attr("class","line line-"+index).attr("stroke-width",1).attr("stroke-linecap","round");innerSelection.each(function(){var path=d3.select(this);var pathD;if(d.closed){path.attr("fill",color);path.attr("fill-opacity",.3);pathD=area}else{path.attr("fill","none");pathD=line}path.attr("stroke",color).attr("marker-end",function(){return d.fnType==="vector"?"url(#"+chart.markerId+")":null}).attr("d",pathD)}).attr(d.attr);innerSelection.exit().remove()})}return plotLine}},{"../evaluate":3,"../utils":22}],8:[function(require,module,exports){"use strict";var d3=window.d3;var evaluate=require("../evaluate");var utils=require("../utils");module.exports=function(chart){var xScale=chart.meta.xScale;var yScale=chart.meta.yScale;function scatter(selection){selection.each(function(d){var i,j;var index=d.index;var color=utils.color(d,index);var evaluatedData=evaluate(chart,d);var joined=[];for(i=0;i circle").data(joined);innerSelection.enter().append("circle");innerSelection.attr("fill",d3.hsl(color.toString()).brighter(1.5)).attr("stroke",color).attr("opacity",.7).attr("r",1).attr("cx",function(d){return xScale(d[0])}).attr("cy",function(d){return yScale(d[1])}).attr(d.attr);innerSelection.exit().remove()})}return scatter}},{"../evaluate":3,"../utils":22}],9:[function(require,module,exports){"use strict";var d3=window.d3;module.exports=function(options){var annotations;var xScale=options.owner.meta.xScale;var yScale=options.owner.meta.yScale;var line=d3.svg.line().x(function(d){return d[0]}).y(function(d){return d[1]});annotations=function(parentSelection){parentSelection.each(function(){var current=d3.select(this);var selection=current.selectAll("g.annotations").data(function(d){return d.annotations||[]});selection.enter().append("g").attr("class","annotations");var yRange=yScale.range();var xRange=xScale.range();var path=selection.selectAll("path").data(function(d){if(d.hasOwnProperty("x")){return[[[0,yRange[0]],[0,yRange[1]]]]}else{return[[[xRange[0],0],[xRange[1],0]]]}});path.enter().append("path").attr("stroke","#eee").attr("d",line);path.exit().remove();var text=selection.selectAll("text").data(function(d){return[{text:d.text||"",hasX:d.hasOwnProperty("x")}]});text.enter().append("text").attr("y",function(d){return d.hasX?3:0}).attr("x",function(d){return d.hasX?0:3}).attr("dy",function(d){return d.hasX?5:-5}).attr("text-anchor",function(d){return d.hasX?"end":""}).attr("transform",function(d){return d.hasX?"rotate(-90)":""}).text(function(d){return d.text});text.exit().remove();selection.attr("transform",function(d){if(d.hasOwnProperty("x")){return"translate("+xScale(d.x)+", 0)"}else{return"translate(0, "+yScale(d.y)+")"}});selection.exit().remove()})};return annotations}},{}],10:[function(require,module,exports){"use strict";var d3=window.d3;var builtInEvaluator=require("./eval").builtIn;var polyline=require("../graph-types/polyline");var datumDefaults=require("../datum-defaults");module.exports=function(chart){var derivativeDatum=datumDefaults({skipTip:true,nSamples:2,graphType:"polyline"});var derivative;function computeLine(d){if(!d.derivative){return[]}var x0=typeof d.derivative.x0==="number"?d.derivative.x0:Infinity;derivativeDatum.index=d.index;derivativeDatum.scope={m:builtInEvaluator(d.derivative,"fn",{x:x0}),x0:x0,y0:builtInEvaluator(d,"fn",{x:x0})};derivativeDatum.fn="m * (x - x0) + y0";return[derivativeDatum]}function checkAutoUpdate(d){var self=this;if(!d.derivative){return}if(d.derivative.updateOnMouseMove&&!d.derivative.$$mouseListener){d.derivative.$$mouseListener=function(x0){d.derivative.x0=x0;derivative(self)};chart.on("tip:update",d.derivative.$$mouseListener)}}derivative=function(selection){selection.each(function(d){var el=d3.select(this);var data=computeLine.call(selection,d);checkAutoUpdate.call(selection,d);var innerSelection=el.selectAll("g.derivative").data(data);innerSelection.enter().append("g").attr("class","derivative");innerSelection.call(polyline(chart));innerSelection.selectAll("path").attr("opacity",.5);innerSelection.exit().remove()})};return derivative}},{"../datum-defaults":2,"../graph-types/polyline":7,"./eval":11}],11:[function(require,module,exports){"use strict";var samplers={interval:require("interval-arithmetic-eval"),builtIn:require("built-in-math-eval")};var extend=require("extend");window.math&&(samplers.builtIn=window.math.compile);function generateEvaluator(samplerName){function doCompile(expression){if(typeof expression==="string"){var compile=samplers[samplerName];return compile(expression)}else if(typeof expression==="function"){return{eval:expression}}else{throw Error("expression must be a string or a function")}}function compileIfPossible(meta,property){var expression=meta[property];var hiddenProperty=samplerName+"_Expression_"+property;var hiddenCompiled=samplerName+"_Compiled_"+property;if(expression!==meta[hiddenProperty]){meta[hiddenProperty]=expression;meta[hiddenCompiled]=doCompile(expression)}}function getCompiledExpression(meta,property){return meta[samplerName+"_Compiled_"+property]}function evaluate(meta,property,variables){compileIfPossible(meta,property);return getCompiledExpression(meta,property).eval(extend({},meta.scope||{},variables))}return evaluate}module.exports.builtIn=generateEvaluator("builtIn");module.exports.interval=generateEvaluator("interval")},{"built-in-math-eval":23,extend:28,"interval-arithmetic-eval":31}],12:[function(require,module,exports){"use strict";var d3=window.d3;var derivative=require("./derivative");var secant=require("./secant");module.exports=function(chart){function helper(selection){selection.each(function(){var el=d3.select(this);el.call(derivative(chart));el.call(secant(chart))})}return helper}},{"./derivative":10,"./secant":13}],13:[function(require,module,exports){"use strict";var d3=window.d3;var extend=require("extend");var builtInEvaluator=require("./eval").builtIn;var datumDefaults=require("../datum-defaults");var polyline=require("../graph-types/polyline");module.exports=function(chart){var secantDefaults=datumDefaults({isHelper:true,skipTip:true,nSamples:2,graphType:"polyline"});var secant;function computeSlope(scope){scope.m=(scope.y1-scope.y0)/(scope.x1-scope.x0)}function updateLine(d,secant){if(!secant.hasOwnProperty("x0")){throw Error("secant must have the property `x0` defined")}secant.scope=secant.scope||{};var x0=secant.x0;var x1=typeof secant.x1==="number"?secant.x1:Infinity;extend(secant.scope,{x0:x0,x1:x1,y0:builtInEvaluator(d,"fn",{x:x0}),y1:builtInEvaluator(d,"fn",{x:x1})});computeSlope(secant.scope)}function setFn(d,secant){updateLine(d,secant);secant.fn="m * (x - x0) + y0"}function setMouseListener(d,secantObject){var self=this;if(secantObject.updateOnMouseMove&&!secantObject.$$mouseListener){secantObject.$$mouseListener=function(x1){secantObject.x1=x1;updateLine(d,secantObject);secant(self)};chart.on("tip:update",secantObject.$$mouseListener)}}function computeLines(d){var self=this;var data=[];d.secants=d.secants||[];for(var i=0;i=xDomain[1]){throw Error("the pair defining the x-domain is inverted")}if(yDomain[0]>=yDomain[1]){throw Error("the pair defining the y-domain is inverted")}xScale=this.meta.xScale=d3.scale[options.xAxis.type]().domain(xDomain).range(options.xAxis.invert?[width,0]:[0,width]);yScale=this.meta.yScale=d3.scale[options.yAxis.type]().domain(yDomain).range(options.yAxis.invert?[0,height]:[height,0]);this.meta.xAxis=d3.svg.axis().scale(xScale).tickSize(options.grid?-height:0).tickFormat(format(xScale)).orient("bottom");this.meta.yAxis=d3.svg.axis().scale(yScale).tickSize(options.grid?-width:0).tickFormat(format(yScale)).orient("left")};Chart.prototype.internalVars=function(){this.meta={};margin=this.meta.margin={left:30,right:30,top:20,bottom:20};if(options.title){this.meta.margin.top=40}zoomBehavior=this.meta.zoomBehavior=d3.behavior.zoom();width=this.meta.width=(options.width||globals.DEFAULT_WIDTH)-margin.left-margin.right;height=this.meta.height=(options.height||globals.DEFAULT_HEIGHT)-margin.top-margin.bottom;this.initializeAxes()};Chart.prototype.drawGraphWrapper=function(){var root=this.root=d3.select(options.target).selectAll("svg").data([options]);this.root.enter=root.enter().append("svg").attr("class","function-plot").attr("font-size",this.getFontSize());root.attr("width",width+margin.left+margin.right).attr("height",height+margin.top+margin.bottom);this.buildTitle();this.buildLegend();this.buildCanvas();this.buildClip();this.buildAxis();this.buildAxisLabel();this.draw();var tip=this.tip=mousetip(extend(options.tip,{owner:this}));this.canvas.call(tip);this.buildZoomHelper();this.setUpPlugins()};Chart.prototype.buildTitle=function(){var selection=this.root.selectAll("text.title").data(function(d){return[d.title].filter(Boolean)});selection.enter().append("text").attr("class","title").attr("y",margin.top/2).attr("x",margin.left+width/2).attr("font-size",25).attr("text-anchor","middle").attr("alignment-baseline","middle").text(options.title);selection.exit().remove()};Chart.prototype.buildLegend=function(){this.root.enter.append("text").attr("class","top-right-legend").attr("text-anchor","end");this.root.select(".top-right-legend").attr("y",margin.top/2).attr("x",width+margin.left)};Chart.prototype.buildCanvas=function(){var self=this;this.meta.zoomBehavior.x(xScale).y(yScale).on("zoom",function onZoom(){self.emit("all:zoom",d3.event.translate,d3.event.scale)});var canvas=this.canvas=this.root.selectAll(".canvas").data(function(d){return[d]});this.canvas.enter=canvas.enter().append("g").attr("class","canvas")};Chart.prototype.buildClip=function(){var id=this.id;var defs=this.canvas.enter.append("defs");defs.append("clipPath").attr("id","function-plot-clip-"+id).append("rect").attr("class","clip static-clip");this.canvas.selectAll(".clip").attr("width",width).attr("height",height);this.markerId=this.id+"-marker";defs.append("clipPath").append("marker").attr("id",this.markerId).attr("viewBox","0 -5 10 10").attr("refX",10).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").append("svg:path").attr("d","M0,-5L10,0L0,5L0,0").attr("stroke-width","0px").attr("fill-opacity",1).attr("fill","#777")};Chart.prototype.buildAxis=function(){var canvasEnter=this.canvas.enter;canvasEnter.append("g").attr("class","x axis");canvasEnter.append("g").attr("class","y axis");this.canvas.select(".x.axis").attr("transform","translate(0,"+height+")").call(this.meta.xAxis);this.canvas.select(".y.axis").call(this.meta.yAxis)};Chart.prototype.buildAxisLabel=function(){var xLabel,yLabel;var canvas=this.canvas;xLabel=canvas.selectAll("text.x.axis-label").data(function(d){return[d.xAxis.label].filter(Boolean)});xLabel.enter().append("text").attr("class","x axis-label").attr("text-anchor","end");xLabel.attr("x",width).attr("y",height-6).text(function(d){return d});xLabel.exit().remove();yLabel=canvas.selectAll("text.y.axis-label").data(function(d){return[d.yAxis.label].filter(Boolean)});yLabel.enter().append("text").attr("class","y axis-label").attr("y",6).attr("dy",".75em").attr("text-anchor","end").attr("transform","rotate(-90)");yLabel.text(function(d){return d});yLabel.exit().remove()};Chart.prototype.buildContent=function(){var self=this;var canvas=this.canvas;canvas.attr("transform","translate("+margin.left+","+margin.top+")").call(zoomBehavior).each(function(){var el=d3.select(this);var listeners=["mousedown","touchstart","onwheel"in document?"wheel":"ononmousewheel"in document?"mousewheel":"MozMousePixelScroll"].map(function(d){return d+".zoom"});if(!el._zoomListenersCache){listeners.forEach(function(l){el["_"+l]=el.on(l)});el._zoomListenersCache=true}function setState(state){listeners.forEach(function(l){state?el.on(l,el["_"+l]):el.on(l,null)})}setState(!options.disableZoom)});var content=this.content=canvas.selectAll(":scope > g.content").data(function(d){return[d]});content.enter().append("g").attr("clip-path","url(#function-plot-clip-"+this.id+")").attr("class","content");if(options.xAxis.type==="linear"){var yOrigin=content.selectAll(":scope > path.y.origin").data([[[0,yScale.domain()[0]],[0,yScale.domain()[1]]]]);yOrigin.enter().append("path").attr("class","y origin").attr("stroke","black").attr("opacity",.2);yOrigin.attr("d",line)}if(options.yAxis.type==="linear"){var xOrigin=content.selectAll(":scope > path.x.origin").data([[[xScale.domain()[0],0],[xScale.domain()[1],0]]]);xOrigin.enter().append("path").attr("class","x origin").attr("stroke","black").attr("opacity",.2);xOrigin.attr("d",line)}content.call(annotations({owner:self}));var graphs=content.selectAll(":scope > g.graph").data(function(d){return d.data.map(datumDefaults)});graphs.enter().append("g").attr("class","graph");graphs.each(function(d,index){d.index=index;d3.select(this).call(graphTypes[d.graphType](self));d3.select(this).call(helpers(self))})};Chart.prototype.buildZoomHelper=function(){var self=this;this.draggable=this.canvas.enter.append("rect").attr("class","zoom-and-drag").style("fill","none").style("pointer-events","all");this.canvas.select(".zoom-and-drag").attr("width",width).attr("height",height).on("mouseover",function(){self.emit("all:mouseover")}).on("mouseout",function(){self.emit("all:mouseout")}).on("mousemove",function(){self.emit("all:mousemove")})};Chart.prototype.setUpPlugins=function(){var plugins=options.plugins||[];var self=this;plugins.forEach(function(plugin){plugin(self)})};Chart.prototype.addLink=function(){for(var i=0;i",toggle:false},options);var brush=d3.svg.brush();var kd=keydown(options.key);var visible=false;var cachedInstance;function wrapper(datum){return function(x){var functionPlot=window.functionPlot;return functionPlot.eval.builtIn(datum,"fn",{x:x})}}function setBrushState(visible){var brushEl=cachedInstance.canvas.selectAll(".definite-integral");brushEl.style("display",visible?null:"none")}function inner(instance){cachedInstance=instance;var oldDisableZoom;brush.x(instance.meta.xScale).on("brushstart",function(){if(!d3.event.sourceEvent)return;oldDisableZoom=!!instance.options.disableZoom;instance.options.disableZoom=true;instance.emit("draw")}).on("brushend",function(){if(!d3.event.sourceEvent)return;instance.options.disableZoom=oldDisableZoom;if(!brush.empty()){var a=brush.extent()[0];var b=brush.extent()[1];instance.options.data.forEach(function(datum,i){var value=integrateSimpson(wrapper(datum),a,b,options.tol,options.maxdepth);instance.emit("definite-integral",datum,i,value,a,b)})}instance.draw()});var brushEl=instance.canvas.append("g").attr("class","brush definite-integral");brushEl.call(brush).call(brush.event);instance.canvas.selectAll(".brush .extent").attr("stroke","#fff").attr("fill-opacity",.125).attr("shape-rendering","crispEdges");brushEl.selectAll("rect").attr("height",instance.meta.height);instance.canvas.on("mousemove.definiteIntegral",function(){if(!options.toggle){inner.visible(pressed(options.key))}});kd.on("pressed",function(){inner.visible(options.toggle?!inner.visible():true)});inner.visible(false)}inner.visible=function(_){if(!arguments.length){return visible}visible=_;setBrushState(_);return inner};return inner}},{extend:28,"integrate-adaptive-simpson":30,"key-pressed":49,keydown:50}],16:[function(require,module,exports){module.exports={zoomBox:require("./zoom-box"),definiteIntegral:require("./definite-integral")}},{"./definite-integral":15,"./zoom-box":17}],17:[function(require,module,exports){var d3=window.d3;var extend=require("extend");var pressed=require("key-pressed");var keydown=require("keydown");module.exports=function(options){options=extend({key:"",toggle:false},options);var brush=d3.svg.brush();var kd=keydown(options.key);var cachedInstance;var visible=false;function setBrushState(visible){var brushEl=cachedInstance.canvas.selectAll(".zoom-box");brushEl.style("display",visible?null:"none")}function inner(instance){cachedInstance=instance;var oldDisableZoom;brush.x(instance.meta.xScale).y(instance.meta.yScale).on("brushstart",function(){if(!d3.event.sourceEvent)return;oldDisableZoom=!!instance.options.disableZoom;instance.options.disableZoom=true;instance.draw()}).on("brushend",function(){if(!d3.event.sourceEvent)return;instance.options.disableZoom=oldDisableZoom;if(!brush.empty()){var lo=brush.extent()[0];var hi=brush.extent()[1];var x=[lo[0],hi[0]];var y=[lo[1],hi[1]];instance.programmaticZoom(x,y)}d3.select(this).transition().duration(1).call(brush.clear()).call(brush.event)});var brushEl=instance.canvas.append("g").attr("class","brush zoom-box");brushEl.call(brush).call(brush.event);instance.canvas.selectAll(".brush .extent").attr("stroke","#fff").attr("fill-opacity",.125).attr("shape-rendering","crispEdges");instance.canvas.on("mousemove.zoombox",function(){if(!options.toggle){inner.visible(pressed(options.key))}});kd.on("pressed",function(){inner.visible(options.toggle?!inner.visible():true)});inner.visible(false)}inner.visible=function(_){if(!arguments.length){return visible}visible=_;setBrushState(_);return inner};return inner}},{extend:28,"key-pressed":49,keydown:50}],18:[function(require,module,exports){(function(doc,proto){try{doc.querySelector(":scope body")}catch(err){["querySelector","querySelectorAll"].forEach(function(method){var native=proto[method];proto[method]=function(selectors){if(/(^|,)\s*:scope/.test(selectors)){var id=this.id;this.id="ID_"+Date.now();selectors=selectors.replace(/((^|,)\s*):scope/g,"$1#"+this.id);var result=doc[method](selectors);this.id=id;return result}else{return native.call(this,selectors)}}})}})(window.document,Element.prototype)},{}],19:[function(require,module,exports){"use strict";var clamp=require("clamp");var linspace=require("linspace");var utils=require("../utils");var evaluate=require("../helpers/eval").builtIn;function checkAsymptote(d0,d1,meta,sign,level){if(!level){return{asymptote:true,d0:d0,d1:d1}}var i;var n=10;var x0=d0[0];var x1=d1[0];var samples=linspace(x0,x1,n);var oldY,oldX;for(i=0;i1/zoomScale){var check=checkAsymptote(data[i-1],data[i],meta,newSign,3);if(check.asymptote){st.push(updateY(check.d0));sets.push(st);st=[updateY(check.d1)]}}oldSign=newSign;st.push(data[i]);++i}if(st.length){sets.push(st)}return sets}function linear(chart,meta,range,n){var allX=utils.space(chart,range,n);var yDomain=chart.meta.yScale.domain();var yDomainMargin=yDomain[1]-yDomain[0];var yMin=yDomain[0]-yDomainMargin*1e5;var yMax=yDomain[1]+yDomainMargin*1e5;var data=[];var i;for(i=0;inext[1].hi){prev[1].hi=Math.max(yMax,prev[1].hi);next[1].lo=Math.min(yMin,next[1].lo)}if(prev[1].hirange[0]-globals.TIP_X_EPS&&x00){return 1}return 0},color:function(data,index){return data.color||globals.COLORS[index]}}},{"./globals":4,linspace:51,log10:52,logspace:53}],23:[function(require,module,exports){"use strict";module.exports=require("./lib/eval")},{"./lib/eval":25}],24:[function(require,module,exports){"use strict";module.exports=function(){var math=Object.create(Math);math.factory=function(a){if(typeof a!=="number"){throw new TypeError("built-in math factory only accepts numbers")}return Number(a)};math.add=function(a,b){return a+b};math.sub=function(a,b){return a-b};math.mul=function(a,b){return a*b};math.div=function(a,b){return a/b};math.mod=function(a,b){return a%b};math.factorial=function(a){var res=1;for(var i=2;i<=a;i+=1){res*=i}return res};math.nthRoot=function(a,root){var inv=root<0;if(inv){root=-root}if(root===0){throw new Error("Root must be non-zero")}if(a<0&&Math.abs(root)%2!==1){throw new Error("Root must be odd when a is negative.")}if(a===0){return 0}if(!isFinite(a)){return inv?0:a}var x=Math.pow(Math.abs(a),1/root);x=a<0?-x:x;return inv?1/x:x};math.logicalOR=function(a,b){return a||b};math.logicalXOR=function(a,b){return a!=b};math.logicalAND=function(a,b){return a&&b};math.bitwiseOR=function(a,b){return a|b};math.bitwiseXOR=function(a,b){return a^b};math.bitwiseAND=function(a,b){return a&b};math.lessThan=function(a,b){return ab};math.greaterEqualThan=function(a,b){return a>=b};math.equal=function(a,b){return a==b};math.strictlyEqual=function(a,b){return a===b};math.notEqual=function(a,b){return a!=b};math.strictlyNotEqual=function(a,b){return a!==b};math.shiftRight=function(a,b){return a>>b};math.shiftLeft=function(a,b){return a<>>b};math.negative=function(a){return-a};math.positive=function(a){return a};return math}},{}],25:[function(require,module,exports){"use strict";var CodeGenerator=require("math-codegen");var math=require("./adapter")();function processScope(scope){Object.keys(scope).forEach(function(k){var value=scope[k];scope[k]=math.factory(value)})}module.exports=function(expression){return(new CodeGenerator).setDefs({$$processScope:processScope}).parse(expression).compile(math)};module.exports.math=math},{"./adapter":24,"math-codegen":54}],26:[function(require,module,exports){module.exports=clamp;function clamp(value,min,max){return minmax?max:value:valuemin?min:value}},{}],27:[function(require,module,exports){(function(Buffer){var hasTypedArrays=false;if(typeof Float64Array!=="undefined"){var DOUBLE_VIEW=new Float64Array(1),UINT_VIEW=new Uint32Array(DOUBLE_VIEW.buffer);DOUBLE_VIEW[0]=1;hasTypedArrays=true;if(UINT_VIEW[1]===1072693248){module.exports=function doubleBitsLE(n){DOUBLE_VIEW[0]=n;return[UINT_VIEW[0],UINT_VIEW[1]]};function toDoubleLE(lo,hi){UINT_VIEW[0]=lo;UINT_VIEW[1]=hi;return DOUBLE_VIEW[0]}module.exports.pack=toDoubleLE;function lowUintLE(n){DOUBLE_VIEW[0]=n;return UINT_VIEW[0]}module.exports.lo=lowUintLE;function highUintLE(n){DOUBLE_VIEW[0]=n;return UINT_VIEW[1]}module.exports.hi=highUintLE}else if(UINT_VIEW[0]===1072693248){module.exports=function doubleBitsBE(n){DOUBLE_VIEW[0]=n;return[UINT_VIEW[1],UINT_VIEW[0]]};function toDoubleBE(lo,hi){UINT_VIEW[1]=lo;UINT_VIEW[0]=hi;return DOUBLE_VIEW[0]}module.exports.pack=toDoubleBE;function lowUintBE(n){DOUBLE_VIEW[0]=n;return UINT_VIEW[1]}module.exports.lo=lowUintBE;function highUintBE(n){DOUBLE_VIEW[0]=n;return UINT_VIEW[0]}module.exports.hi=highUintBE}else{hasTypedArrays=false}}if(!hasTypedArrays){var buffer=new Buffer(8);module.exports=function doubleBits(n){buffer.writeDoubleLE(n,0,true);return[buffer.readUInt32LE(0,true),buffer.readUInt32LE(4,true)]};function toDouble(lo,hi){buffer.writeUInt32LE(lo,0,true);buffer.writeUInt32LE(hi,4,true);return buffer.readDoubleLE(0,true)}module.exports.pack=toDouble;function lowUint(n){buffer.writeDoubleLE(n,0,true);return buffer.readUInt32LE(0,true)}module.exports.lo=lowUint;function highUint(n){buffer.writeDoubleLE(n,0,true);return buffer.readUInt32LE(4,true)}module.exports.hi=highUint}module.exports.sign=function(n){return module.exports.hi(n)>>>31};module.exports.exponent=function(n){var b=module.exports.hi(n);return(b<<1>>>21)-1023};module.exports.fraction=function(n){var lo=module.exports.lo(n);var hi=module.exports.hi(n);var b=hi&(1<<20)-1;if(hi&2146435072){b+=1<<20}return[lo,b]};module.exports.denormalized=function(n){var hi=module.exports.hi(n);return!(hi&2146435072)}}).call(this,require("buffer").Buffer)},{buffer:87}],28:[function(require,module,exports){"use strict";var hasOwn=Object.prototype.hasOwnProperty;var toStr=Object.prototype.toString;var isArray=function isArray(arr){if(typeof Array.isArray==="function"){return Array.isArray(arr)}return toStr.call(arr)==="[object Array]"};var isPlainObject=function isPlainObject(obj){if(!obj||toStr.call(obj)!=="[object Object]"){return false}var hasOwnConstructor=hasOwn.call(obj,"constructor");var hasIsPrototypeOf=obj.constructor&&obj.constructor.prototype&&hasOwn.call(obj.constructor.prototype,"isPrototypeOf");if(obj.constructor&&!hasOwnConstructor&&!hasIsPrototypeOf){return false}var key;for(key in obj){}return typeof key==="undefined"||hasOwn.call(obj,key)};module.exports=function extend(){var options,name,src,copy,copyIsArray,clone,target=arguments[0],i=1,length=arguments.length,deep=false;if(typeof target==="boolean"){deep=target;target=arguments[1]||{};i=2}else if(typeof target!=="object"&&typeof target!=="function"||target==null){target={}}for(;imaxdepth){state.maxDepthCount++;return s2+err}else if(Math.abs(err)0&&console&&console.warn){console.warn("integrate-adaptive-simpson: Warning: maximum recursion depth ("+maxdepth+") reached "+state.maxDepthCount+" times")}if(state.nanEncountered&&console&&console.warn){console.warn("integrate-adaptive-simpson: Warning: NaN encountered. Halting early.")}return result}},{}],31:[function(require,module,exports){"use strict";module.exports=require("./lib/eval")},{"./lib/eval":33}],32:[function(require,module,exports){"use strict";module.exports=function(ns){ns.mod=ns.fmod;ns.lessThan=ns.lt;ns.lessEqualThan=ns.leq;ns.greaterThan=ns.gt;ns.greaterEqualThan=ns.geq;ns.strictlyEqual=ns.equal;ns.strictlyNotEqual=ns.notEqual;ns.logicalAND=function(a,b){return a&&b};ns.logicalXOR=function(a,b){return a^b};ns.logicalOR=function(a,b){return a||b}}},{}],33:[function(require,module,exports){"use strict";var CodeGenerator=require("math-codegen");var Interval=require("interval-arithmetic");require("./adapter")(Interval);function processScope(scope){Object.keys(scope).forEach(function(k){var value=scope[k];if(typeof value==="number"||Array.isArray(value)){scope[k]=Interval.factory(value)}else if(typeof value==="object"&&"lo"in value&&"hi"in value){scope[k]=Interval.factory(value.lo,value.hi)}})}module.exports=function(expression){return(new CodeGenerator).setDefs({$$processScope:processScope}).parse(expression).compile(Interval)};module.exports.policies=require("./policies")(Interval);module.exports.Interval=Interval},{"./adapter":32,"./policies":34,"interval-arithmetic":35,"math-codegen":54}],34:[function(require,module,exports){"use strict";module.exports=function(Interval){return{disableRounding:function(){Interval.rmath.disable()},enableRounding:function(){Interval.rmath.enable()}}}},{}],35:[function(require,module,exports){"use strict";var extend=require("xtend/mutable");require("./lib/polyfill");module.exports=require("./lib/interval");module.exports.rmath=require("./lib/round-math");module.exports.round=require("./lib/round-math");extend(module.exports,require("./lib/constants"),require("./lib/operations/relational"),require("./lib/operations/arithmetic"),require("./lib/operations/algebra"),require("./lib/operations/trigonometric"),require("./lib/operations/misc"),require("./lib/operations/utils"))},{"./lib/constants":36,"./lib/interval":37,"./lib/operations/algebra":38,"./lib/operations/arithmetic":39,"./lib/operations/misc":41,"./lib/operations/relational":42,"./lib/operations/trigonometric":43,"./lib/operations/utils":44,"./lib/polyfill":45,"./lib/round-math":46,"xtend/mutable":85}],36:[function(require,module,exports){"use strict";var Interval=require("./interval");var mutate=require("xtend/mutable");var piLow=(3373259426+273688/(1<<21))/(1<<30);var piHigh=(3373259426+273689/(1<<21))/(1<<30);var constants={};mutate(constants,{PI_LOW:piLow,PI_HIGH:piHigh,PI_HALF_LOW:piLow/2,PI_HALF_HIGH:piHigh/2,PI_TWICE_LOW:piLow*2,PI_TWICE_HIGH:piHigh*2});function getter(property,fn){Object.defineProperty(constants,property,{get:function(){return fn()},enumerable:true})}getter("PI",function(){return Interval(piLow,piHigh)});getter("PI_HALF",function(){return Interval(constants.PI_HALF_LOW,constants.PI_HALF_HIGH)});getter("PI_TWICE",function(){return Interval(constants.PI_TWICE_LOW,constants.PI_TWICE_HIGH)});getter("ZERO",function(){return Interval(0)});getter("ONE",function(){return Interval(1)});getter("WHOLE",function(){return Interval().setWhole()});getter("EMPTY",function(){return Interval().setEmpty()});module.exports=constants},{"./interval":37,"xtend/mutable":85}],37:[function(require,module,exports){"use strict";var utils=require("./operations/utils");var round=require("./round-math");module.exports=Interval;function Interval(lo,hi){if(!(this instanceof Interval)){return new Interval(lo,hi)}if(typeof lo!=="undefined"&&typeof hi!=="undefined"){if(utils.isInterval(lo)){if(!utils.isSingleton(lo)){throw new TypeError("Interval: interval `lo` must be a singleton")}lo=lo.lo}if(utils.isInterval(hi)){if(!utils.isSingleton(hi)){throw TypeError("Interval: interval `hi` must be a singleton")}hi=hi.hi}}else if(typeof lo!=="undefined"){if(Array.isArray(lo)){return Interval(lo[0],lo[1])}return Interval(lo,lo)}else{lo=hi=0}this.lo=undefined;this.hi=undefined;this.assign(lo,hi)}Interval.factory=Interval;Interval.prototype.singleton=function(v){return this.set(v,v)};Interval.prototype.bounded=function(lo,hi){return this.set(round.prev(lo),round.next(hi))};Interval.prototype.boundedSingleton=function(v){return this.bounded(v,v)};Interval.prototype.set=function(lo,hi){this.lo=lo;this.hi=hi;return this};Interval.prototype.assign=function(lo,hi){if(typeof lo!=="number"||typeof hi!=="number"){throw TypeError("Interval#assign: arguments must be numbers")}if(isNaN(lo)||isNaN(hi)||lo>hi){return this.setEmpty()}return this.set(lo,hi)};Interval.prototype.setEmpty=function(){return this.set(Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY)};Interval.prototype.setWhole=function(){return this.set(Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY)};Interval.prototype.open=function(lo,hi){return this.assign(round.safeNext(lo),round.safePrev(hi))};Interval.prototype.halfOpenLeft=function(lo,hi){return this.assign(round.safeNext(lo),hi)};Interval.prototype.halfOpenRight=function(lo,hi){return this.assign(lo,round.safePrev(hi))};Interval.prototype.toArray=function(){return[this.lo,this.hi]};Interval.prototype.clone=function(){return Interval().set(this.lo,this.hi)}},{"./operations/utils":44,"./round-math":46}],38:[function(require,module,exports){"use strict";var isSafeInteger=require("is-safe-integer");var Interval=require("../interval");var rmath=require("../round-math");var utils=require("./utils");var arithmetic=require("./arithmetic");var constants=require("../constants");var algebra={};algebra.fmod=function(x,y){if(utils.isEmpty(x)||utils.isEmpty(y)){return constants.EMPTY}var yb=x.lo<0?y.lo:y.hi;var n=rmath.intLo(rmath.divLo(x.lo,yb));return arithmetic.sub(x,arithmetic.mul(y,Interval(n)))};algebra.multiplicativeInverse=function(x){if(utils.isEmpty(x)){return constants.EMPTY}if(utils.zeroIn(x)){if(x.lo!==0){if(x.hi!==0){return constants.WHOLE}else{return Interval(Number.NEGATIVE_INFINITY,rmath.divHi(1,x.lo))}}else{if(x.hi!==0){return Interval(rmath.divLo(1,x.hi),Number.POSITIVE_INFINITY)}else{return constants.EMPTY}}}else{return Interval(rmath.divLo(1,x.hi),rmath.divHi(1,x.lo))}};algebra.pow=function(x,power){if(utils.isEmpty(x)){return constants.EMPTY}if(typeof power==="object"){if(!utils.isSingleton(power)){return constants.EMPTY}power=power.lo}if(power===0){if(x.lo===0&&x.hi===0){return constants.EMPTY}else{return constants.ONE}}else if(power<0){return algebra.multiplicativeInverse(algebra.pow(x,-power))}if(isSafeInteger(power)){if(x.hi<0){var yl=rmath.powLo(-x.hi,power);var yh=rmath.powHi(-x.lo,power);if(power&1){return Interval(-yh,-yl)}else{return Interval(yl,yh)}}else if(x.lo<0){if(power&1){return Interval(-rmath.powLo(-x.lo,power),rmath.powHi(x.hi,power))}else{return Interval(0,rmath.powHi(Math.max(-x.lo,x.hi),power))}}else{return Interval(rmath.powLo(x.lo,power),rmath.powHi(x.hi,power))}}else{console.warn("power is not an integer, you should use nth-root instead, returning an empty interval");return constants.EMPTY}};algebra.sqrt=function(x){return algebra.nthRoot(x,2)};algebra.nthRoot=function(x,n){if(utils.isEmpty(x)||n<0){return constants.EMPTY}if(typeof n==="object"){if(!utils.isSingleton(n)){return constants.EMPTY}n=n.lo}var power=1/n;if(x.hi<0){if(isSafeInteger(n)&(n&1)){var yl=rmath.powHi(-x.lo,power);var yh=rmath.powLo(-x.hi,power);return Interval(-yl,-yh)}return Interval.EMPTY}else if(x.lo<0){var yp=rmath.powHi(x.hi,power);if(isSafeInteger(n)&(n&1)){var yn=rmath.powHi(-x.lo,power);return Interval(0,Math.max(yn,yp))}return Interval(0,yp)}else{return Interval(rmath.powLo(x.lo,power),rmath.powHi(x.hi,power))}};module.exports=algebra},{"../constants":36,"../interval":37,"../round-math":46,"./arithmetic":39,"./utils":44,"is-safe-integer":48}],39:[function(require,module,exports){"use strict";var Interval=require("../interval");var rmath=require("../round-math");var utils=require("./utils");var constants=require("../constants");var division=require("./division");var arithmetic={};arithmetic.add=function(x,y){return Interval(rmath.addLo(x.lo,y.lo),rmath.addHi(x.hi,y.hi))};arithmetic.subtract=function(x,y){return Interval(rmath.subLo(x.lo,y.hi),rmath.subHi(x.hi,y.lo))};arithmetic.sub=arithmetic.subtract;arithmetic.multiply=function(x,y){if(utils.isEmpty(x)||utils.isEmpty(y)){return constants.EMPTY}var xl=x.lo;var xh=x.hi;var yl=y.lo;var yh=y.hi;var out=Interval();if(xl<0){if(xh>0){if(yl<0){if(yh>0){out.lo=Math.min(rmath.mulLo(xl,yh),rmath.mulLo(xh,yl));out.hi=Math.max(rmath.mulHi(xl,yl),rmath.mulHi(xh,yh))}else{out.lo=rmath.mulLo(xh,yl);out.hi=rmath.mulHi(xl,yl)}}else{if(yh>0){out.lo=rmath.mulLo(xl,yh);out.hi=rmath.mulHi(xh,yh)}else{out.lo=0;out.hi=0}}}else{if(yl<0){if(yh>0){out.lo=rmath.mulLo(xl,yh);out.hi=rmath.mulHi(xl,yl)}else{out.lo=rmath.mulLo(xh,yh);out.hi=rmath.mulHi(xl,yl)}}else{if(yh>0){out.lo=rmath.mulLo(xl,yh);out.hi=rmath.mulHi(xh,yl)}else{out.lo=0;out.hi=0}}}}else{if(xh>0){if(yl<0){if(yh>0){out.lo=rmath.mulLo(xh,yl);out.hi=rmath.mulHi(xh,yh)}else{out.lo=rmath.mulLo(xh,yl);out.hi=rmath.mulHi(xl,yh)}}else{if(yh>0){out.lo=rmath.mulLo(xl,yl);out.hi=rmath.mulHi(xh,yh)}else{out.lo=0;out.hi=0}}}else{out.lo=0;out.hi=0}}return out};arithmetic.mul=arithmetic.multiply;arithmetic.divide=function(x,y){if(utils.isEmpty(x)||utils.isEmpty(y)){return constants.EMPTY}if(utils.zeroIn(y)){if(y.lo!==0){if(y.hi!==0){return division.zero(x)}else{return division.negative(x,y.lo)}}else{if(y.hi!==0){return division.positive(x,y.hi)}else{return constants.EMPTY}}}else{return division.nonZero(x,y)}};arithmetic.div=arithmetic.divide;arithmetic.positive=function(x){return Interval(x.lo,x.hi)};arithmetic.negative=function(x){return Interval(-x.hi,-x.lo)};module.exports=arithmetic},{"../constants":36,"../interval":37,"../round-math":46,"./division":40,"./utils":44}],40:[function(require,module,exports){"use strict";var Interval=require("../interval");var rmath=require("../round-math");var utils=require("./utils");var constants=require("../constants");var division={nonZero:function(x,y){var xl=x.lo;var xh=x.hi;var yl=y.lo;var yh=y.hi;var out=Interval();if(xh<0){if(yh<0){out.lo=rmath.divLo(xh,yl);out.hi=rmath.divHi(xl,yh)}else{out.lo=rmath.divLo(xl,yl);out.hi=rmath.divHi(xh,yh)}}else if(xl<0){if(yh<0){out.lo=rmath.divLo(xh,yh);out.hi=rmath.divHi(xl,yh)}else{out.lo=rmath.divLo(xl,yl);out.hi=rmath.divHi(xh,yl)}}else{if(yh<0){out.lo=rmath.divLo(xh,yh);out.hi=rmath.divHi(xl,yl)}else{out.lo=rmath.divLo(xl,yh);out.hi=rmath.divHi(xh,yl)}}return out},positive:function(x,v){if(x.lo===0&&x.hi===0){return x}if(utils.zeroIn(x)){return constants.WHOLE}if(x.hi<0){return Interval(Number.NEGATIVE_INFINITY,rmath.divHi(x.hi,v))}else{return Interval(rmath.divLo(x.lo,v),Number.POSITIVE_INFINITY)}},negative:function(x,v){if(x.lo===0&&x.hi===0){return x}if(utils.zeroIn(x)){return constants.WHOLE}if(x.hi<0){return Interval(rmath.divLo(x.hi,v),Number.POSITIVE_INFINITY)}else{return Interval(Number.NEGATIVE_INFINITY,rmath.divHi(x.lo,v))}},zero:function(x){if(x.lo===0&&x.hi===0){return x}return constants.WHOLE}};module.exports=division},{"../constants":36,"../interval":37,"../round-math":46,"./utils":44}],41:[function(require,module,exports){"use strict";var constants=require("../constants");var Interval=require("../interval");var rmath=require("../round-math");var utils=require("./utils");var arithmetic=require("./arithmetic");var misc={};misc.exp=function(x){if(utils.isEmpty(x)){return constants.EMPTY}return Interval(rmath.expLo(x.lo),rmath.expHi(x.hi))};misc.log=function(x){if(utils.isEmpty(x)){return constants.EMPTY}var l=x.lo<=0?Number.NEGATIVE_INFINITY:rmath.logLo(x.lo);return Interval(l,rmath.logHi(x.hi))};misc.ln=misc.log;misc.LOG_EXP_10=misc.log(Interval(10,10));misc.log10=function(x){if(utils.isEmpty(x)){return constants.EMPTY}return arithmetic.div(misc.log(x),misc.LOG_EXP_10)};misc.LOG_EXP_2=misc.log(Interval(2,2));misc.log2=function(x){if(utils.isEmpty(x)){return constants.EMPTY}return arithmetic.div(misc.log(x),misc.LOG_EXP_2)};misc.hull=function(x,y){var badX=utils.isEmpty(x);var badY=utils.isEmpty(y);if(badX&&badY){return constants.EMPTY}else if(badX){return y.clone()}else if(badY){return x.clone()}else{return Interval(Math.min(x.lo,y.lo),Math.max(x.hi,y.hi))}};misc.intersection=function(x,y){if(utils.isEmpty(x)||utils.isEmpty(y)){return constants.EMPTY}var lo=Math.max(x.lo,y.lo);var hi=Math.min(x.hi,y.hi);if(lo<=hi){return Interval(lo,hi)}return constants.EMPTY};misc.union=function(x,y){if(!utils.intervalsOverlap(x,y)){throw Error("Interval#union: intervals do not overlap")}return Interval(Math.min(x.lo,y.lo),Math.max(x.hi,y.hi))};misc.difference=function(x,y){if(utils.isEmpty(x)||utils.isWhole(y)){return constants.EMPTY}if(utils.intervalsOverlap(x,y)){if(x.lo=x.hi&&y.lo===-Infinity){return constants.EMPTY}if(y.lo<=x.lo){return Interval().halfOpenLeft(y.hi,x.hi)}return Interval().halfOpenRight(x.lo,y.lo)}return Interval.clone(x)};misc.width=function(x){if(utils.isEmpty(x)){return 0}return rmath.subHi(x.hi,x.lo)};misc.wid=misc.width;misc.abs=function(x){if(utils.isEmpty(x)){return constants.EMPTY}if(x.lo>=0){return Interval.clone(x)}if(x.hi<=0){return arithmetic.negative(x)}return Interval(0,Math.max(-x.lo,x.hi))};misc.max=function(x,y){var badX=utils.isEmpty(x);var badY=utils.isEmpty(y);if(badX&&badY){return constants.EMPTY}else if(badX){return y.clone()}else if(badY){return x.clone()}else{return Interval(Math.max(x.lo,y.lo),Math.max(x.hi,y.hi))}};misc.min=function(x,y){var badX=utils.isEmpty(x);var badY=utils.isEmpty(y);if(badX&&badY){return constants.EMPTY}else if(badX){return y.clone()}else if(badY){return x.clone()}else{return Interval(Math.min(x.lo,y.lo),Math.min(x.hi,y.hi))}};misc.clone=function(x){return Interval().set(x.lo,x.hi)};module.exports=misc},{"../constants":36,"../interval":37,"../round-math":46,"./arithmetic":39,"./utils":44}],42:[function(require,module,exports){"use strict";var utils=require("./utils");var relational={};relational.equal=function(x,y){if(utils.isEmpty(x)){return utils.isEmpty(y)}return!utils.isEmpty(y)&&x.lo===y.lo&&x.hi===y.hi};relational.almostEqual=function(x,y){var EPS=1e-7;function assert(a,message){if(!a){throw new Error(message||"assertion failed")}}function assertEps(a,b){assert(Math.abs(a-b)y.hi};relational.lessThan=function(x,y){if(utils.isEmpty(x)||utils.isEmpty(y)){return false}return x.hiy.hi};relational.gt=relational.greaterThan;relational.lessEqualThan=function(x,y){if(utils.isEmpty(x)||utils.isEmpty(y)){return false}return x.hi<=y.lo};relational.leq=relational.lessEqualThan;relational.greaterEqualThan=function(x,y){if(utils.isEmpty(x)||utils.isEmpty(y)){return false}return x.lo>=y.hi};relational.geq=relational.greaterEqualThan;module.exports=relational},{"./utils":44}],43:[function(require,module,exports){"use strict";var constants=require("../constants");var Interval=require("../interval");var rmath=require("../round-math");var utils=require("./utils");var misc=require("./misc");var algebra=require("./algebra");var arithmetic=require("./arithmetic");var trigonometric={};trigonometric.cos=function(x){var rlo,rhi;if(utils.isEmpty(x)){return constants.EMPTY}var cache=Interval();cache.set(x.lo,x.hi);if(cache.lo<0){var n=Math.ceil(-cache.lo/constants.PI_TWICE_LOW);cache.lo+=constants.PI_TWICE_LOW*n;cache.hi+=constants.PI_TWICE_LOW*n}var pi2=constants.PI_TWICE;var t=algebra.fmod(cache,pi2);if(misc.width(t)>=pi2.lo){return Interval(-1,1)}if(t.lo>=constants.PI_HIGH){var cos=trigonometric.cos(arithmetic.sub(t,constants.PI));return arithmetic.negative(cos)}var lo=t.lo;var hi=t.hi;rlo=rmath.cosLo(hi);rhi=rmath.cosHi(lo);if(hi<=constants.PI_LOW){return Interval(rlo,rhi)}else if(hi<=pi2.lo){return Interval(-1,Math.max(rlo,rhi))}else{return Interval(-1,1)}};trigonometric.sin=function(x){if(utils.isEmpty(x)){return constants.EMPTY}return trigonometric.cos(arithmetic.sub(x,constants.PI_HALF))};trigonometric.tan=function(x){if(utils.isEmpty(x)){return constants.EMPTY}var cache=Interval();cache.set(x.lo,x.hi);if(cache.lo<0){var n=Math.ceil(-cache.lo/constants.PI_TWICE_LOW);cache.lo+=constants.PI_TWICE_LOW*n;cache.hi+=constants.PI_TWICE_LOW*n}var pi=constants.PI;var t=algebra.fmod(cache,pi);if(t.lo>=constants.PI_HALF_LOW){t=arithmetic.sub(t,pi)}if(t.lo<=-constants.PI_HALF_LOW||t.hi>=constants.PI_HALF_LOW){return constants.WHOLE}return Interval(rmath.tanLo(t.lo),rmath.tanHi(t.hi))};trigonometric.asin=function(x){if(utils.isEmpty(x)||x.hi<-1||x.lo>1){return constants.EMPTY}var lo=x.lo<=-1?-constants.PI_HALF_HIGH:rmath.asinLo(x.lo);var hi=x.hi>=1?constants.PI_HALF_HIGH:rmath.asinHi(x.hi);return Interval(lo,hi)};trigonometric.acos=function(x){if(utils.isEmpty(x)||x.hi<-1||x.lo>1){return constants.EMPTY}var lo=x.hi>=1?0:rmath.acosLo(x.hi);var hi=x.lo<=-1?constants.PI_HIGH:rmath.acosHi(x.lo);return Interval(lo,hi)};trigonometric.atan=function(x){if(utils.isEmpty(x)){return constants.EMPTY}return Interval(rmath.atanLo(x.lo),rmath.atanHi(x.hi))};trigonometric.sinh=function(x){if(utils.isEmpty(x)){return constants.EMPTY}return Interval(rmath.sinhLo(x.lo),rmath.sinhHi(x.hi))};trigonometric.cosh=function(x){if(utils.isEmpty(x)){return constants.EMPTY}if(x.hi<0){return Interval(rmath.coshLo(x.hi),rmath.coshHi(x.lo))}else if(x.lo>=0){return Interval(rmath.coshLo(x.lo),rmath.coshHi(x.hi))}else{return Interval(1,rmath.coshHi(-x.lo>x.hi?x.lo:x.hi))}};trigonometric.tanh=function(x){if(utils.isEmpty(x)){return constants.EMPTY}return Interval(rmath.tanhLo(x.lo),rmath.tanhHi(x.hi))};module.exports=trigonometric},{"../constants":36,"../interval":37,"../round-math":46,"./algebra":38,"./arithmetic":39,"./misc":41,"./utils":44}],44:[function(require,module,exports){"use strict";var utils={};utils.isInterval=function(x){return typeof x==="object"&&typeof x.lo==="number"&&typeof x.hi==="number"};utils.isEmpty=function(x){return x.lo>x.hi};utils.isWhole=function(x){return x.lo===-Infinity&&x.hi===Infinity; -};utils.isSingleton=function(x){return x.lo===x.hi};utils.zeroIn=function(x){return utils.hasValue(x,0)};utils.hasValue=function(a,value){if(utils.isEmpty(a)){return false}return a.lo<=value&&value<=a.hi};utils.hasInterval=function(x,y){if(utils.isEmpty(x)){return true}return!utils.isEmpty(y)&&y.lo<=x.lo&&x.hi<=y.hi};utils.intervalsOverlap=function(x,y){if(utils.isEmpty(x)||utils.isEmpty(y)){return false}return x.lo<=y.lo&&y.lo<=x.hi||y.lo<=x.lo&&x.lo<=y.hi};module.exports=utils},{}],45:[function(require,module,exports){"use strict";Math.sinh=Math.sinh||function(x){var y=Math.exp(x);return(y-1/y)/2};Math.cosh=Math.cosh||function(x){var y=Math.exp(x);return(y+1/y)/2};Math.tanh=Math.tanh||function(x){if(x===Number.POSITIVE_INFINITY){return 1}else if(x===Number.NEGATIVE_INFINITY){return-1}else{var y=Math.exp(2*x);return(y-1)/(y+1)}}},{}],46:[function(require,module,exports){"use strict";var nextafter=require("nextafter");function identity(v){return v}function prev(v){if(v===Infinity){return v}return nextafter(v,-Infinity)}function next(v){if(v===-Infinity){return v}return nextafter(v,Infinity)}var round={safePrev:prev,safeNext:next,prev:prev,next:next};round.addLo=function(x,y){return this.prev(x+y)};round.addHi=function(x,y){return this.next(x+y)};round.subLo=function(x,y){return this.prev(x-y)};round.subHi=function(x,y){return this.next(x-y)};round.mulLo=function(x,y){return this.prev(x*y)};round.mulHi=function(x,y){return this.next(x*y)};round.divLo=function(x,y){return this.prev(x/y)};round.divHi=function(x,y){return this.next(x/y)};function toInteger(x){return x<0?Math.ceil(x):Math.floor(x)}round.intLo=function(x){return toInteger(this.prev(x))};round.intHi=function(x){return toInteger(this.next(x))};round.logLo=function(x){return this.prev(Math.log(x))};round.logHi=function(x){return this.next(Math.log(x))};round.expLo=function(x){return this.prev(Math.exp(x))};round.expHi=function(x){return this.next(Math.exp(x))};round.sinLo=function(x){return this.prev(Math.sin(x))};round.sinHi=function(x){return this.next(Math.sin(x))};round.cosLo=function(x){return this.prev(Math.cos(x))};round.cosHi=function(x){return this.next(Math.cos(x))};round.tanLo=function(x){return this.prev(Math.tan(x))};round.tanHi=function(x){return this.next(Math.tan(x))};round.asinLo=function(x){return this.prev(Math.asin(x))};round.asinHi=function(x){return this.next(Math.asin(x))};round.acosLo=function(x){return this.prev(Math.acos(x))};round.acosHi=function(x){return this.next(Math.acos(x))};round.atanLo=function(x){return this.prev(Math.atan(x))};round.atanHi=function(x){return this.next(Math.atan(x))};round.sinhLo=function(x){return this.prev(Math.sinh(x))};round.sinhHi=function(x){return this.next(Math.sinh(x))};round.coshLo=function(x){return this.prev(Math.cosh(x))};round.coshHi=function(x){return this.next(Math.cosh(x))};round.tanhLo=function(x){return this.prev(Math.tanh(x))};round.tanhHi=function(x){return this.next(Math.tanh(x))};round.powLo=function(x,power){if(power%1!==0){return this.prev(Math.pow(x,power))}var y=power&1?x:1;power>>=1;while(power>0){x=round.mulLo(x,x);if(power&1){y=round.mulLo(x,y)}power>>=1}return y};round.powHi=function(x,power){if(power%1!==0){return this.next(Math.pow(x,power))}var y=power&1?x:1;power>>=1;while(power>0){x=round.mulHi(x,x);if(power&1){y=round.mulHi(x,y)}power>>=1}return y};round.sqrtLo=function(x){return this.prev(Math.sqrt(x))};round.sqrtHi=function(x){return this.next(Math.sqrt(x))};round.disable=function(){this.next=this.prev=identity};round.enable=function(){this.next=next;this.prev=prev};module.exports=round},{nextafter:83}],47:[function(require,module,exports){"use strict";module.exports=function isObject(x){return typeof x==="object"&&x!==null}},{}],48:[function(require,module,exports){"use strict";var MAX_SAFE_INTEGER=require("max-safe-integer");module.exports=Number.isSafeInteger||function(val){return typeof val==="number"&&val===val&&val!==Infinity&&val!==-Infinity&&parseInt(val,10)===val&&Math.abs(val)<=MAX_SAFE_INTEGER}},{"max-safe-integer":67}],49:[function(require,module,exports){(function(process){var keys=require("vkey");var list=Object.keys(keys);var down={};reset();module.exports=pressed;if(process.browser){window.addEventListener("keydown",keydown,false);window.addEventListener("keyup",keyup,false);window.addEventListener("blur",reset,false)}function pressed(key){return key?down[key]:down}function reset(){list.forEach(function(code){down[keys[code]]=false})}function keyup(e){down[keys[e.keyCode]]=false}function keydown(e){down[keys[e.keyCode]]=true}}).call(this,require("_process"))},{_process:91,vkey:84}],50:[function(require,module,exports){var Emitter=require("events").EventEmitter;var vkey=require("vkey");module.exports=function(keys,el){if(typeof keys==="string")keys=[keys];if(!el)el=window;var emitter=new Emitter;emitter.pressed={};el.addEventListener("blur",clearPressed);el.addEventListener("focus",clearPressed);el.addEventListener("keydown",function(ev){var key=vkey[ev.keyCode];emitter.pressed[key]=true;var allPressed=true;keys.forEach(function(k){if(!emitter.pressed[k])allPressed=false});if(allPressed){emitter.emit("pressed",emitter.pressed);clearPressed()}});el.addEventListener("keyup",function(ev){delete emitter.pressed[vkey[ev.keyCode]]});function clearPressed(){emitter.pressed={}}return emitter}},{events:89,vkey:84}],51:[function(require,module,exports){var integers=require("integers");module.exports=function linspace(a,b,n){var every=(b-a)/(n-1),ranged=integers(a,b,every);return ranged.length==n?ranged:ranged.concat(b)}},{integers:29}],52:[function(require,module,exports){"use strict";module.exports=Math.log10||function(x){return Math.log(x)*Math.LOG10E}},{}],53:[function(require,module,exports){var linspace=require("linspace");module.exports=function logspace(a,b,n){return linspace(a,b,n).map(function(x){return Math.pow(10,x)})}},{linspace:51}],54:[function(require,module,exports){"use strict";module.exports=require("./lib/CodeGenerator")},{"./lib/CodeGenerator":55}],55:[function(require,module,exports){"use strict";var Parser=require("mr-parser").Parser;var Interpreter=require("./Interpreter");var extend=require("extend");function CodeGenerator(options,defs){this.statements=[];this.defs=defs||{};this.interpreter=new Interpreter(this,options)}CodeGenerator.prototype.setDefs=function(defs){this.defs=extend(this.defs,defs);return this};CodeGenerator.prototype.compile=function(namespace){if(!namespace||!(typeof namespace==="object"||typeof namespace==="function")){throw TypeError("namespace must be an object")}if(typeof namespace.factory!=="function"){throw TypeError("namespace.factory must be a function")}this.defs.ns=namespace;this.defs.$$mathCodegen={getProperty:function(symbol,scope,ns){if(symbol in scope){return scope[symbol]}if(symbol in ns){return ns[symbol]}throw SyntaxError('symbol "'+symbol+'" is undefined')},functionProxy:function(fn,name){if(typeof fn!=="function"){throw SyntaxError('symbol "'+name+'" must be a function')}return fn}};this.defs.$$processScope=this.defs.$$processScope||function(){};var defsCode=Object.keys(this.defs).map(function(name){return"var "+name+' = defs["'+name+'"]'});if(!this.statements.length){throw Error("there are no statements saved in this generator, make sure you parse an expression before compiling it")}this.statements[this.statements.length-1]="return "+this.statements[this.statements.length-1];var code=this.statements.join(";");var factoryCode=defsCode.join("\n")+"\n"+["return {"," eval: function (scope) {"," scope = scope || {}"," $$processScope(scope)"," "+code," },"," code: '"+code+"'","}"].join("\n");var factory=new Function("defs",factoryCode);return factory(this.defs)};CodeGenerator.prototype.parse=function(code){var self=this;var program=(new Parser).parse(code);this.statements=program.blocks.map(function(statement){return self.interpreter.next(statement)});return this};module.exports=CodeGenerator},{"./Interpreter":56,extend:28,"mr-parser":68}],56:[function(require,module,exports){"use strict";var extend=require("extend");var types={ArrayNode:require("./node/ArrayNode"),AssignmentNode:require("./node/AssignmentNode"),ConditionalNode:require("./node/ConditionalNode"),ConstantNode:require("./node/ConstantNode"),FunctionNode:require("./node/FunctionNode"),OperatorNode:require("./node/OperatorNode"),SymbolNode:require("./node/SymbolNode"),UnaryNode:require("./node/UnaryNode")};var Interpreter=function(owner,options){this.owner=owner;this.options=extend({factory:"ns.factory",raw:false,rawArrayExpressionElements:true,rawCallExpressionElements:false},options)};extend(Interpreter.prototype,types);Interpreter.prototype.next=function(node){if(!(node.type in this)){throw new TypeError("the node type "+node.type+" is not implemented")}return this[node.type](node)};Interpreter.prototype.rawify=function(test,fn){var oldRaw=this.options.raw;if(test){this.options.raw=true}fn();if(test){this.options.raw=oldRaw}};module.exports=Interpreter},{"./node/ArrayNode":59,"./node/AssignmentNode":60,"./node/ConditionalNode":61,"./node/ConstantNode":62,"./node/FunctionNode":63,"./node/OperatorNode":64,"./node/SymbolNode":65,"./node/UnaryNode":66,extend:28}],57:[function(require,module,exports){"use strict";module.exports={"+":"add","-":"sub","*":"mul","/":"div","^":"pow","%":"mod","!":"factorial","|":"bitwiseOR","^|":"bitwiseXOR","&":"bitwiseAND","||":"logicalOR",xor:"logicalXOR","&&":"logicalAND","<":"lessThan",">":"greaterThan","<=":"lessEqualThan",">=":"greaterEqualThan","===":"strictlyEqual","==":"equal","!==":"strictlyNotEqual","!=":"notEqual",">>":"shiftRight","<<":"shiftLeft",">>>":"unsignedRightShift"}},{}],58:[function(require,module,exports){"use strict";module.exports={"+":"positive","-":"negative","~":"oneComplement"}},{}],59:[function(require,module,exports){"use strict";module.exports=function(node){var self=this;var arr=[];this.rawify(this.options.rawArrayExpressionElements,function(){arr=node.nodes.map(function(el){return self.next(el)})});var arrString="["+arr.join(",")+"]";if(this.options.raw){return arrString}return this.options.factory+"("+arrString+")"}},{}],60:[function(require,module,exports){"use strict";module.exports=function(node){return'scope["'+node.name+'"] = '+this.next(node.expr)}},{}],61:[function(require,module,exports){"use strict";module.exports=function(node){var condition="!!("+this.next(node.condition)+")";var trueExpr=this.next(node.trueExpr);var falseExpr=this.next(node.falseExpr);return"("+condition+" ? ("+trueExpr+") : ("+falseExpr+") )"}},{}],62:[function(require,module,exports){"use strict";module.exports=function(node){if(this.options.raw){return node.value}return this.options.factory+"("+node.value+")"}},{}],63:[function(require,module,exports){"use strict";var SymbolNode=require("mr-parser").nodeTypes.SymbolNode;var functionProxy=function(node){return"$$mathCodegen.functionProxy("+this.next(new SymbolNode(node.name))+', "'+node.name+'")'};module.exports=function(node){var self=this;var method=functionProxy.call(this,node);var args=[];this.rawify(this.options.rawCallExpressionElements,function(){args=node.args.map(function(arg){return self.next(arg)})});return method+"("+args.join(", ")+")"};module.exports.functionProxy=functionProxy},{"mr-parser":68}],64:[function(require,module,exports){"use strict";var Operators=require("../misc/Operators");module.exports=function(node){if(this.options.raw){return["("+this.next(node.args[0]),node.op,this.next(node.args[1])+")"].join(" ")}var namedOperator=Operators[node.op];if(!namedOperator){throw TypeError("unidentified operator")}return this.FunctionNode({name:namedOperator,args:node.args})}},{"../misc/Operators":57}],65:[function(require,module,exports){"use strict";module.exports=function(node){var id=node.name;return'$$mathCodegen.getProperty("'+id+'", scope, ns)'}},{}],66:[function(require,module,exports){"use strict";var UnaryOperators=require("../misc/UnaryOperators");module.exports=function(node){if(this.options.raw){return node.op+this.next(node.argument)}if(!(node.op in UnaryOperators)){throw new SyntaxError(node.op+" not implemented")}var namedOperator=UnaryOperators[node.op];return this.FunctionNode({name:namedOperator,args:[node.argument]})}},{"../misc/UnaryOperators":58}],67:[function(require,module,exports){"use strict";module.exports=9007199254740991},{}],68:[function(require,module,exports){"use strict";module.exports.Lexer=require("./lib/Lexer");module.exports.Parser=require("./lib/Parser");module.exports.nodeTypes=require("./lib/node/")},{"./lib/Lexer":69,"./lib/Parser":70,"./lib/node/":81}],69:[function(require,module,exports){var tokenType=require("./token-type");var ESCAPES={n:"\n",f:"\f",r:"\r",t:" ",v:" ","'":"'",'"':'"'};var DELIMITERS={",":true,"(":true,")":true,"[":true,"]":true,";":true,"~":true,"!":true,"+":true,"-":true,"*":true,"/":true,"%":true,"^":true,"**":true,"|":true,"&":true,"^|":true,"=":true,":":true,"?":true,"||":true,"&&":true,xor:true,"==":true,"!=":true,"===":true,"!==":true,"<":true,">":true,">=":true,"<=":true,">>>":true,"<<":true,">>":true};function isDigit(c){return c>="0"&&c<="9"}function isIdentifier(c){return c>="a"&&c<="z"||c>="A"&&c<="Z"||c==="$"||c==="_"}function isWhitespace(c){return c===" "||c==="\r"||c===" "||c==="\n"||c===" "||c===" "}function isDelimiter(str){return DELIMITERS[str]}function isQuote(c){return c==="'"||c==='"'}function Lexer(){}Lexer.prototype.throwError=function(message,index){index=typeof index==="undefined"?this.index:index;var error=new Error(message+" at index "+index);error.index=index;error.description=message;throw error};Lexer.prototype.lex=function(text){this.text=text;this.index=0;this.tokens=[];while(this.index=this.text.length){return}return this.text.charAt(this.index+nth)};Lexer.prototype.consume=function(){var current=this.peek();this.index+=1;return current};Lexer.prototype.readNumber=function(){var number="";if(this.peek()==="."){number+=this.consume();if(!isDigit(this.peek())){this.throwError("number expected")}}else{while(isDigit(this.peek())){number+=this.consume()}if(this.peek()==="."){number+=this.consume()}}while(isDigit(this.peek())){number+=this.consume()}if(this.peek()==="e"||this.peek()==="E"){number+=this.consume();if(!(isDigit(this.peek())||this.peek()==="+"||this.peek()==="-")){this.throwError()}if(this.peek()==="+"||this.peek()==="-"){number+=this.consume()}if(!isDigit(this.peek())){this.throwError("number expected")}while(isDigit(this.peek())){number+=this.consume()}}return number};Lexer.prototype.readIdentifier=function(){var text="";while(isIdentifier(this.peek())||isDigit(this.peek())){text+=this.consume()}return text};Lexer.prototype.readString=function(){var quote=this.consume();var string="";var escape;while(true){var c=this.consume();if(!c){this.throwError("string is not closed")}if(escape){if(c==="u"){var hex=this.text.substring(this.index+1,this.index+5);if(!hex.match(/[\da-f]{4}/i)){this.throwError("invalid unicode escape")}this.index+=4;string+=String.fromCharCode(parseInt(hex,16))}else{var replacement=ESCAPES[c];if(replacement){string+=replacement}else{string+=c}}escape=false}else if(c===quote){break}else if(c==="\\"){escape=true}else{string+=c}}return string};module.exports=Lexer},{"./token-type":82}],70:[function(require,module,exports){var tokenType=require("./token-type");var Lexer=require("./Lexer");var ConstantNode=require("./node/ConstantNode");var OperatorNode=require("./node/OperatorNode");var UnaryNode=require("./node/UnaryNode");var SymbolNode=require("./node/SymbolNode");var FunctionNode=require("./node/FunctionNode");var ArrayNode=require("./node/ArrayNode");var ConditionalNode=require("./node/ConditionalNode");var AssignmentNode=require("./node/AssignmentNode");var BlockNode=require("./node/BlockNode");function Parser(){this.lexer=new Lexer;this.tokens=null}Parser.prototype.current=function(){return this.tokens[0]};Parser.prototype.next=function(){return this.tokens[1]};Parser.prototype.peek=function(){if(this.tokens.length){var first=this.tokens[0];for(var i=0;i=","<=",">","<")){var op=this.consume();var right=this.shift();return new OperatorNode(op.value,[left,right])}return left};Parser.prototype.shift=function(){var left=this.additive();if(this.peek(">>","<<",">>>")){var op=this.consume();var right=this.shift();return new OperatorNode(op.value,[left,right])}return left};Parser.prototype.additive=function(){var left=this.multiplicative();while(this.peek("+","-")){var op=this.consume();left=new OperatorNode(op.value,[left,this.multiplicative()])}return left};Parser.prototype.multiplicative=function(){var op,right;var left=this.unary();while(this.peek("*","/","%")){op=this.consume();left=new OperatorNode(op.value,[left,this.unary()])}if(this.current().type===tokenType.SYMBOL||this.peek("(")||!(left.type instanceof ConstantNode)&&this.current().type===tokenType.NUMBER){right=this.multiplicative();return new OperatorNode("*",[left,right])}return left};Parser.prototype.unary=function(){if(this.peek("-","+","~")){var op=this.consume();var right=this.unary();return new UnaryNode(op.value,right)}return this.pow()};Parser.prototype.pow=function(){var left=this.factorial();if(this.peek("^","**")){var op=this.consume();var right=this.unary();return new OperatorNode(op.value,[left,right])}return left};Parser.prototype.factorial=function(){var left=this.symbol();if(this.peek("!")){var op=this.consume();return new OperatorNode(op.value,[left])}return left};Parser.prototype.symbol=function(){var current=this.current();if(current.type===tokenType.SYMBOL){var symbol=this.consume();var node=this.functionCall(symbol);return node}return this.string()};Parser.prototype.functionCall=function(symbolToken){var name=symbolToken.value;if(this.peek("(")){this.consume();var params=[];while(!this.peek(")")&&!this.isEOF()){params.push(this.assignment());if(this.peek(",")){this.consume()}}this.expect(")");return new FunctionNode(name,params)}return new SymbolNode(name)};Parser.prototype.string=function(){if(this.current().type===tokenType.STRING){return new ConstantNode(this.consume().value,"string")}return this.array()};Parser.prototype.array=function(){if(this.peek("[")){this.consume();var params=[];while(!this.peek("]")&&!this.isEOF()){params.push(this.assignment());if(this.peek(",")){this.consume()}}this.expect("]");return new ArrayNode(params)}return this.number()};Parser.prototype.number=function(){var token=this.current();if(token.type===tokenType.NUMBER){return new ConstantNode(this.consume().value,"number")}return this.parentheses()};Parser.prototype.parentheses=function(){var token=this.current();if(token.value==="("){this.consume();var left=this.assignment();this.expect(")");return left}return this.end()};Parser.prototype.end=function(){var token=this.current();if(token.type!==tokenType.EOF){throw Error("unexpected end of expression")}};module.exports=Parser},{"./Lexer":69,"./node/ArrayNode":71,"./node/AssignmentNode":72,"./node/BlockNode":73,"./node/ConditionalNode":74,"./node/ConstantNode":75,"./node/FunctionNode":76,"./node/OperatorNode":78,"./node/SymbolNode":79,"./node/UnaryNode":80,"./token-type":82}],71:[function(require,module,exports){var Node=require("./Node");function ArrayNode(nodes){this.nodes=nodes}ArrayNode.prototype=Object.create(Node.prototype);ArrayNode.prototype.type="ArrayNode";module.exports=ArrayNode},{"./Node":77}],72:[function(require,module,exports){var Node=require("./Node");function AssignmentNode(name,expr){this.name=name;this.expr=expr}AssignmentNode.prototype=Object.create(Node.prototype);AssignmentNode.prototype.type="AssignmentNode";module.exports=AssignmentNode},{"./Node":77}],73:[function(require,module,exports){var Node=require("./Node");function BlockNode(blocks){this.blocks=blocks}BlockNode.prototype=Object.create(Node.prototype);BlockNode.prototype.type="BlockNode";module.exports=BlockNode},{"./Node":77}],74:[function(require,module,exports){var Node=require("./Node");function ConditionalNode(predicate,truthy,falsy){this.condition=predicate;this.trueExpr=truthy;this.falseExpr=falsy}ConditionalNode.prototype=Object.create(Node.prototype);ConditionalNode.prototype.type="ConditionalNode";module.exports=ConditionalNode},{"./Node":77}],75:[function(require,module,exports){var Node=require("./Node");var SUPPORTED_TYPES={number:true,string:true,"boolean":true,undefined:true,"null":true};function ConstantNode(value,type){if(!SUPPORTED_TYPES[type]){throw Error("unsupported type '"+type+"'")}this.value=value;this.valueType=type}ConstantNode.prototype=Object.create(Node.prototype);ConstantNode.prototype.type="ConstantNode";module.exports=ConstantNode},{"./Node":77}],76:[function(require,module,exports){var Node=require("./Node");function FunctionNode(name,args){this.name=name;this.args=args}FunctionNode.prototype=Object.create(Node.prototype);FunctionNode.prototype.type="FunctionNode";module.exports=FunctionNode},{"./Node":77}],77:[function(require,module,exports){function Node(){}Node.prototype.type="Node";module.exports=Node},{}],78:[function(require,module,exports){var Node=require("./Node");function OperatorNode(op,args){this.op=op;this.args=args||[]}OperatorNode.prototype=Object.create(Node.prototype);OperatorNode.prototype.type="OperatorNode";module.exports=OperatorNode},{"./Node":77}],79:[function(require,module,exports){var Node=require("./Node");function SymbolNode(name){this.name=name}SymbolNode.prototype=Object.create(Node.prototype);SymbolNode.prototype.type="SymbolNode";module.exports=SymbolNode},{"./Node":77}],80:[function(require,module,exports){var Node=require("./Node");function UnaryNode(op,argument){this.op=op;this.argument=argument}UnaryNode.prototype=Object.create(Node.prototype);UnaryNode.prototype.type="UnaryNode";module.exports=UnaryNode},{"./Node":77}],81:[function(require,module,exports){module.exports={ArrayNode:require("./ArrayNode"),AssignmentNode:require("./AssignmentNode"),BlockNode:require("./BlockNode"),ConditionalNode:require("./ConditionalNode"),ConstantNode:require("./ConstantNode"),FunctionNode:require("./FunctionNode"),Node:require("./Node"),OperatorNode:require("./OperatorNode"),SymbolNode:require("./SymbolNode"),UnaryNode:require("./UnaryNode")}},{"./ArrayNode":71,"./AssignmentNode":72,"./BlockNode":73,"./ConditionalNode":74,"./ConstantNode":75,"./FunctionNode":76,"./Node":77,"./OperatorNode":78,"./SymbolNode":79,"./UnaryNode":80}],82:[function(require,module,exports){module.exports={EOF:0,DELIMITER:1,NUMBER:2,STRING:3,SYMBOL:4}},{}],83:[function(require,module,exports){"use strict";var doubleBits=require("double-bits");var SMALLEST_DENORM=Math.pow(2,-1074);var UINT_MAX=-1>>>0;module.exports=nextafter;function nextafter(x,y){if(isNaN(x)||isNaN(y)){return NaN}if(x===y){return x}if(x===0){if(y<0){return-SMALLEST_DENORM}else{return SMALLEST_DENORM}}var hi=doubleBits.hi(x);var lo=doubleBits.lo(x);if(y>x===x>0){if(lo===UINT_MAX){hi+=1;lo=0}else{lo+=1}}else{if(lo===0){lo=UINT_MAX;hi-=1}else{lo-=1}}return doubleBits.pack(lo,hi)}},{"double-bits":27}],84:[function(require,module,exports){var ua=typeof window!=="undefined"?window.navigator.userAgent:"",isOSX=/OS X/.test(ua),isOpera=/Opera/.test(ua),maybeFirefox=!/like Gecko/.test(ua)&&!isOpera;var i,output=module.exports={0:isOSX?"":"",1:"",2:"",3:"",4:"",5:"",6:"",8:"",9:"",12:"",13:"",16:"",17:"",18:"",19:"",20:"",21:"",23:"",24:"",25:"",27:"",28:"",29:"",30:"",31:"",27:"",32:"",33:"",34:"",35:"",36:"",37:"",38:"",39:"",40:"",41:"",42:"",43:"",44:"",45:"",46:"",47:"",91:"",92:"",93:isOSX?"":"",95:"",106:"",107:"",108:"",109:"",110:"",111:"",144:"",145:"",160:"",161:"",162:"",163:"",164:"",165:"",166:"",167:"",168:"",169:"",170:"",171:"",172:"",173:isOSX&&maybeFirefox?"-":"",174:"",175:"",176:"",177:"",178:"",179:"",180:"",181:"",182:"",183:"",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",223:"",224:"",226:"",229:"",231:isOpera?"`":"",246:"",247:"",248:"",249:"",250:"",251:"",252:"",253:"",254:""};for(i=58;i<65;++i){output[i]=String.fromCharCode(i)}for(i=48;i<58;++i){output[i]=i-48+""}for(i=65;i<91;++i){output[i]=String.fromCharCode(i)}for(i=96;i<106;++i){output[i]=""}for(i=112;i<136;++i){output[i]="F"+(i-111)}},{}],91:[function(require,module,exports){module.exports=extend;var hasOwnProperty=Object.prototype.hasOwnProperty;function extend(target){for(var i=1;igHi){var t=gLo;gLo=gHi;gHi=t}var hi=Math.min(vHi,gHi);var lo=Math.max(vLo,gLo);if(lo>hi){return[-minWidthHeight,0]}return[lo,hi]}var line=function(points,closed){var path="";var range=yScale.range();var minY=Math.min.apply(Math,range);var maxY=Math.max.apply(Math,range);for(var i=0,length=points.length;i path.line").data(evaluatedData);minWidthHeight=Math.max(evaluatedData[0].scaledDx,1);innerSelection.enter().append("path").attr("class","line line-"+index).attr("fill","none");innerSelection.attr("stroke-width",minWidthHeight).attr("stroke",utils.color(d,index)).attr("opacity",closed?.5:1).attr("d",function(d){return line(d,closed)}).attr(d.attr);innerSelection.exit().remove()})}return plotLine}},{"../evaluate":3,"../utils":22}],7:[function(require,module,exports){"use strict";var d3=window.d3;var evaluate=require("../evaluate");var utils=require("../utils");module.exports=function(chart){var xScale=chart.meta.xScale;var yScale=chart.meta.yScale;var line=d3.svg.line().interpolate("linear").x(function(d){return xScale(d[0])}).y(function(d){return yScale(d[1])});var area=d3.svg.area().x(function(d){return xScale(d[0])}).y0(yScale(0)).y1(function(d){return yScale(d[1])});function plotLine(selection){selection.each(function(d){var el=plotLine.el=d3.select(this);var index=d.index;var evaluatedData=evaluate(chart,d);var color=utils.color(d,index);var innerSelection=el.selectAll(":scope > path.line").data(evaluatedData);innerSelection.enter().append("path").attr("class","line line-"+index).attr("stroke-width",1).attr("stroke-linecap","round");innerSelection.each(function(){var path=d3.select(this);var pathD;if(d.closed){path.attr("fill",color);path.attr("fill-opacity",.3);pathD=area}else{path.attr("fill","none");pathD=line}path.attr("stroke",color).attr("marker-end",function(){return d.fnType==="vector"?"url(#"+chart.markerId+")":null}).attr("d",pathD)}).attr(d.attr);innerSelection.exit().remove()})}return plotLine}},{"../evaluate":3,"../utils":22}],8:[function(require,module,exports){"use strict";var d3=window.d3;var evaluate=require("../evaluate");var utils=require("../utils");module.exports=function(chart){var xScale=chart.meta.xScale;var yScale=chart.meta.yScale;function scatter(selection){selection.each(function(d){var i,j;var index=d.index;var color=utils.color(d,index);var evaluatedData=evaluate(chart,d);var joined=[];for(i=0;i circle").data(joined);innerSelection.enter().append("circle");innerSelection.attr("fill",d3.hsl(color.toString()).brighter(1.5)).attr("stroke",color).attr("opacity",.7).attr("r",1).attr("cx",function(d){return xScale(d[0])}).attr("cy",function(d){return yScale(d[1])}).attr(d.attr);innerSelection.exit().remove()})}return scatter}},{"../evaluate":3,"../utils":22}],9:[function(require,module,exports){"use strict";var d3=window.d3;module.exports=function(options){var annotations;var xScale=options.owner.meta.xScale;var yScale=options.owner.meta.yScale;var line=d3.svg.line().x(function(d){return d[0]}).y(function(d){return d[1]});annotations=function(parentSelection){parentSelection.each(function(){var current=d3.select(this);var selection=current.selectAll("g.annotations").data(function(d){return d.annotations||[]});selection.enter().append("g").attr("class","annotations");var yRange=yScale.range();var xRange=xScale.range();var path=selection.selectAll("path").data(function(d){if(d.hasOwnProperty("x")){return[[[0,yRange[0]],[0,yRange[1]]]]}else{return[[[xRange[0],0],[xRange[1],0]]]}});path.enter().append("path").attr("stroke","#eee").attr("d",line);path.exit().remove();var text=selection.selectAll("text").data(function(d){return[{text:d.text||"",hasX:d.hasOwnProperty("x")}]});text.enter().append("text").attr("y",function(d){return d.hasX?3:0}).attr("x",function(d){return d.hasX?0:3}).attr("dy",function(d){return d.hasX?5:-5}).attr("text-anchor",function(d){return d.hasX?"end":""}).attr("transform",function(d){return d.hasX?"rotate(-90)":""}).text(function(d){return d.text});text.exit().remove();selection.attr("transform",function(d){if(d.hasOwnProperty("x")){return"translate("+xScale(d.x)+", 0)"}else{return"translate(0, "+yScale(d.y)+")"}});selection.exit().remove()})};return annotations}},{}],10:[function(require,module,exports){"use strict";var d3=window.d3;var builtInEvaluator=require("./eval").builtIn;var polyline=require("../graph-types/polyline");var datumDefaults=require("../datum-defaults");module.exports=function(chart){var derivativeDatum=datumDefaults({skipTip:true,nSamples:2,graphType:"polyline"});var derivative;function computeLine(d){if(!d.derivative){return[]}var x0=typeof d.derivative.x0==="number"?d.derivative.x0:Infinity;derivativeDatum.index=d.index;derivativeDatum.scope={m:builtInEvaluator(d.derivative,"fn",{x:x0}),x0:x0,y0:builtInEvaluator(d,"fn",{x:x0})};derivativeDatum.fn="m * (x - x0) + y0";return[derivativeDatum]}function checkAutoUpdate(d){var self=this;if(!d.derivative){return}if(d.derivative.updateOnMouseMove&&!d.derivative.$$mouseListener){d.derivative.$$mouseListener=function(x0){d.derivative.x0=x0;derivative(self)};chart.on("tip:update",d.derivative.$$mouseListener)}}derivative=function(selection){selection.each(function(d){var el=d3.select(this);var data=computeLine.call(selection,d);checkAutoUpdate.call(selection,d);var innerSelection=el.selectAll("g.derivative").data(data);innerSelection.enter().append("g").attr("class","derivative");innerSelection.call(polyline(chart));innerSelection.selectAll("path").attr("opacity",.5);innerSelection.exit().remove()})};return derivative}},{"../datum-defaults":2,"../graph-types/polyline":7,"./eval":11}],11:[function(require,module,exports){"use strict";var samplers={interval:require("interval-arithmetic-eval"),builtIn:require("built-in-math-eval")};var extend=require("extend");window.math&&(samplers.builtIn=window.math.compile);function generateEvaluator(samplerName){function doCompile(expression){if(typeof expression==="string"){var compile=samplers[samplerName];return compile(expression)}else if(typeof expression==="function"){return{eval:expression}}else{throw Error("expression must be a string or a function")}}function compileIfPossible(meta,property){var expression=meta[property];var hiddenProperty=samplerName+"_Expression_"+property;var hiddenCompiled=samplerName+"_Compiled_"+property;if(expression!==meta[hiddenProperty]){meta[hiddenProperty]=expression;meta[hiddenCompiled]=doCompile(expression)}}function getCompiledExpression(meta,property){return meta[samplerName+"_Compiled_"+property]}function evaluate(meta,property,variables){compileIfPossible(meta,property);return getCompiledExpression(meta,property).eval(extend({},meta.scope||{},variables))}return evaluate}module.exports.builtIn=generateEvaluator("builtIn");module.exports.interval=generateEvaluator("interval")},{"built-in-math-eval":23,extend:28,"interval-arithmetic-eval":31}],12:[function(require,module,exports){"use strict";var d3=window.d3;var derivative=require("./derivative");var secant=require("./secant");module.exports=function(chart){function helper(selection){selection.each(function(){var el=d3.select(this);el.call(derivative(chart));el.call(secant(chart))})}return helper}},{"./derivative":10,"./secant":13}],13:[function(require,module,exports){"use strict";var d3=window.d3;var extend=require("extend");var builtInEvaluator=require("./eval").builtIn;var datumDefaults=require("../datum-defaults");var polyline=require("../graph-types/polyline");module.exports=function(chart){var secantDefaults=datumDefaults({isHelper:true,skipTip:true,nSamples:2,graphType:"polyline"});var secant;function computeSlope(scope){scope.m=(scope.y1-scope.y0)/(scope.x1-scope.x0)}function updateLine(d,secant){if(!secant.hasOwnProperty("x0")){throw Error("secant must have the property `x0` defined")}secant.scope=secant.scope||{};var x0=secant.x0;var x1=typeof secant.x1==="number"?secant.x1:Infinity;extend(secant.scope,{x0:x0,x1:x1,y0:builtInEvaluator(d,"fn",{x:x0}),y1:builtInEvaluator(d,"fn",{x:x1})});computeSlope(secant.scope)}function setFn(d,secant){updateLine(d,secant);secant.fn="m * (x - x0) + y0"}function setMouseListener(d,secantObject){var self=this;if(secantObject.updateOnMouseMove&&!secantObject.$$mouseListener){secantObject.$$mouseListener=function(x1){secantObject.x1=x1;updateLine(d,secantObject);secant(self)};chart.on("tip:update",secantObject.$$mouseListener)}}function computeLines(d){var self=this;var data=[];d.secants=d.secants||[];for(var i=0;i=xDomain[1]){throw Error("the pair defining the x-domain is inverted")}if(yDomain[0]>=yDomain[1]){throw Error("the pair defining the y-domain is inverted")}xScale=this.meta.xScale=d3.scale[options.xAxis.type]().domain(xDomain).range(options.xAxis.invert?[width,0]:[0,width]);yScale=this.meta.yScale=d3.scale[options.yAxis.type]().domain(yDomain).range(options.yAxis.invert?[0,height]:[height,0]);this.meta.xAxis=d3.svg.axis().scale(xScale).tickSize(options.grid?-height:0).tickFormat(format(xScale)).orient("bottom");this.meta.yAxis=d3.svg.axis().scale(yScale).tickSize(options.grid?-width:0).tickFormat(format(yScale)).orient("left")};Chart.prototype.internalVars=function(){this.meta={};margin=this.meta.margin={left:30,right:30,top:20,bottom:20};if(options.title){this.meta.margin.top=40}zoomBehavior=this.meta.zoomBehavior=d3.behavior.zoom();width=this.meta.width=(options.width||globals.DEFAULT_WIDTH)-margin.left-margin.right;height=this.meta.height=(options.height||globals.DEFAULT_HEIGHT)-margin.top-margin.bottom;this.initializeAxes()};Chart.prototype.drawGraphWrapper=function(){var root=this.root=d3.select(options.target).selectAll("svg").data([options]);this.root.enter=root.enter().append("svg").attr("class","function-plot").attr("font-size",this.getFontSize());root.attr("width",width+margin.left+margin.right).attr("height",height+margin.top+margin.bottom);this.buildTitle();this.buildLegend();this.buildCanvas();this.buildClip();this.buildAxis();this.buildAxisLabel();this.draw();var tip=this.tip=mousetip(extend(options.tip,{owner:this}));this.canvas.call(tip);this.buildZoomHelper();this.setUpPlugins()};Chart.prototype.buildTitle=function(){var selection=this.root.selectAll("text.title").data(function(d){return[d.title].filter(Boolean)});selection.enter().append("text").attr("class","title").attr("y",margin.top/2).attr("x",margin.left+width/2).attr("font-size",25).attr("text-anchor","middle").attr("alignment-baseline","middle").text(options.title);selection.exit().remove()};Chart.prototype.buildLegend=function(){this.root.enter.append("text").attr("class","top-right-legend").attr("text-anchor","end");this.root.select(".top-right-legend").attr("y",margin.top/2).attr("x",width+margin.left)};Chart.prototype.buildCanvas=function(){var self=this;this.meta.zoomBehavior.x(xScale).y(yScale).on("zoom",function onZoom(){self.emit("all:zoom",d3.event.translate,d3.event.scale)});var canvas=this.canvas=this.root.selectAll(".canvas").data(function(d){return[d]});this.canvas.enter=canvas.enter().append("g").attr("class","canvas")};Chart.prototype.buildClip=function(){var id=this.id;var defs=this.canvas.enter.append("defs");defs.append("clipPath").attr("id","function-plot-clip-"+id).append("rect").attr("class","clip static-clip");this.canvas.selectAll(".clip").attr("width",width).attr("height",height);this.markerId=this.id+"-marker";defs.append("clipPath").append("marker").attr("id",this.markerId).attr("viewBox","0 -5 10 10").attr("refX",10).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").append("svg:path").attr("d","M0,-5L10,0L0,5L0,0").attr("stroke-width","0px").attr("fill-opacity",1).attr("fill","#777")};Chart.prototype.buildAxis=function(){var canvasEnter=this.canvas.enter;canvasEnter.append("g").attr("class","x axis");canvasEnter.append("g").attr("class","y axis");this.canvas.select(".x.axis").attr("transform","translate(0,"+height+")").call(this.meta.xAxis);this.canvas.select(".y.axis").call(this.meta.yAxis)};Chart.prototype.buildAxisLabel=function(){var xLabel,yLabel;var canvas=this.canvas;xLabel=canvas.selectAll("text.x.axis-label").data(function(d){return[d.xAxis.label].filter(Boolean)});xLabel.enter().append("text").attr("class","x axis-label").attr("text-anchor","end");xLabel.attr("x",width).attr("y",height-6).text(function(d){return d});xLabel.exit().remove();yLabel=canvas.selectAll("text.y.axis-label").data(function(d){return[d.yAxis.label].filter(Boolean)});yLabel.enter().append("text").attr("class","y axis-label").attr("y",6).attr("dy",".75em").attr("text-anchor","end").attr("transform","rotate(-90)");yLabel.text(function(d){return d});yLabel.exit().remove()};Chart.prototype.buildContent=function(){var self=this;var canvas=this.canvas;canvas.attr("transform","translate("+margin.left+","+margin.top+")").call(zoomBehavior).each(function(){var el=d3.select(this);var listeners=["mousedown","touchstart","onwheel"in document?"wheel":"ononmousewheel"in document?"mousewheel":"MozMousePixelScroll"].map(function(d){return d+".zoom"});if(!el._zoomListenersCache){listeners.forEach(function(l){el["_"+l]=el.on(l)});el._zoomListenersCache=true}function setState(state){listeners.forEach(function(l){state?el.on(l,el["_"+l]):el.on(l,null)})}setState(!options.disableZoom)});var content=this.content=canvas.selectAll(":scope > g.content").data(function(d){return[d]});content.enter().append("g").attr("clip-path","url(#function-plot-clip-"+this.id+")").attr("class","content");if(options.xAxis.type==="linear"){var yOrigin=content.selectAll(":scope > path.y.origin").data([[[0,yScale.domain()[0]],[0,yScale.domain()[1]]]]);yOrigin.enter().append("path").attr("class","y origin").attr("stroke","black").attr("opacity",.2);yOrigin.attr("d",line)}if(options.yAxis.type==="linear"){var xOrigin=content.selectAll(":scope > path.x.origin").data([[[xScale.domain()[0],0],[xScale.domain()[1],0]]]);xOrigin.enter().append("path").attr("class","x origin").attr("stroke","black").attr("opacity",.2);xOrigin.attr("d",line)}content.call(annotations({owner:self}));var graphs=content.selectAll(":scope > g.graph").data(function(d){return d.data.map(datumDefaults)});graphs.enter().append("g").attr("class","graph");graphs.each(function(d,index){d.index=index;d3.select(this).call(graphTypes[d.graphType](self));d3.select(this).call(helpers(self))})};Chart.prototype.buildZoomHelper=function(){var self=this;this.draggable=this.canvas.enter.append("rect").attr("class","zoom-and-drag").style("fill","none").style("pointer-events","all");this.canvas.select(".zoom-and-drag").attr("width",width).attr("height",height).on("mouseover",function(){self.emit("all:mouseover")}).on("mouseout",function(){self.emit("all:mouseout")}).on("mousemove",function(){self.emit("all:mousemove")})};Chart.prototype.setUpPlugins=function(){var plugins=options.plugins||[];var self=this;plugins.forEach(function(plugin){plugin(self)})};Chart.prototype.addLink=function(){for(var i=0;i",toggle:false},options);var brush=d3.svg.brush();var kd=keydown(options.key);var visible=false;var cachedInstance;function wrapper(datum){return function(x){var functionPlot=window.functionPlot;return functionPlot.eval.builtIn(datum,"fn",{x:x})}}function setBrushState(visible){var brushEl=cachedInstance.canvas.selectAll(".definite-integral");brushEl.style("display",visible?null:"none")}function inner(instance){cachedInstance=instance;var oldDisableZoom;brush.x(instance.meta.xScale).on("brushstart",function(){if(!d3.event.sourceEvent)return;oldDisableZoom=!!instance.options.disableZoom;instance.options.disableZoom=true;instance.emit("draw")}).on("brushend",function(){if(!d3.event.sourceEvent)return;instance.options.disableZoom=oldDisableZoom;if(!brush.empty()){var a=brush.extent()[0];var b=brush.extent()[1];instance.options.data.forEach(function(datum,i){var value=integrateSimpson(wrapper(datum),a,b,options.tol,options.maxdepth);instance.emit("definite-integral",datum,i,value,a,b)})}instance.draw()});var brushEl=instance.canvas.append("g").attr("class","brush definite-integral");brushEl.call(brush).call(brush.event);instance.canvas.selectAll(".brush .extent").attr("stroke","#fff").attr("fill-opacity",.125).attr("shape-rendering","crispEdges");brushEl.selectAll("rect").attr("height",instance.meta.height);instance.canvas.on("mousemove.definiteIntegral",function(){if(!options.toggle){inner.visible(pressed(options.key))}});kd.on("pressed",function(){inner.visible(options.toggle?!inner.visible():true)});inner.visible(false)}inner.visible=function(_){if(!arguments.length){return visible}visible=_;setBrushState(_);return inner};return inner}},{extend:28,"integrate-adaptive-simpson":30,"key-pressed":49,keydown:50}],16:[function(require,module,exports){module.exports={zoomBox:require("./zoom-box"),definiteIntegral:require("./definite-integral")}},{"./definite-integral":15,"./zoom-box":17}],17:[function(require,module,exports){var d3=window.d3;var extend=require("extend");var pressed=require("key-pressed");var keydown=require("keydown");module.exports=function(options){options=extend({key:"",toggle:false},options);var brush=d3.svg.brush();var kd=keydown(options.key);var cachedInstance;var visible=false;function setBrushState(visible){var brushEl=cachedInstance.canvas.selectAll(".zoom-box");brushEl.style("display",visible?null:"none")}function inner(instance){cachedInstance=instance;var oldDisableZoom;brush.x(instance.meta.xScale).y(instance.meta.yScale).on("brushstart",function(){if(!d3.event.sourceEvent)return;oldDisableZoom=!!instance.options.disableZoom;instance.options.disableZoom=true;instance.draw()}).on("brushend",function(){if(!d3.event.sourceEvent)return;instance.options.disableZoom=oldDisableZoom;if(!brush.empty()){var lo=brush.extent()[0];var hi=brush.extent()[1];var x=[lo[0],hi[0]];var y=[lo[1],hi[1]];instance.programmaticZoom(x,y)}d3.select(this).transition().duration(1).call(brush.clear()).call(brush.event)});var brushEl=instance.canvas.append("g").attr("class","brush zoom-box");brushEl.call(brush).call(brush.event);instance.canvas.selectAll(".brush .extent").attr("stroke","#fff").attr("fill-opacity",.125).attr("shape-rendering","crispEdges");instance.canvas.on("mousemove.zoombox",function(){if(!options.toggle){inner.visible(pressed(options.key))}});kd.on("pressed",function(){inner.visible(options.toggle?!inner.visible():true)});inner.visible(false)}inner.visible=function(_){if(!arguments.length){return visible}visible=_;setBrushState(_);return inner};return inner}},{extend:28,"key-pressed":49,keydown:50}],18:[function(require,module,exports){(function(doc,proto){try{doc.querySelector(":scope body")}catch(err){["querySelector","querySelectorAll"].forEach(function(method){var native=proto[method];proto[method]=function(selectors){if(/(^|,)\s*:scope/.test(selectors)){var id=this.id;this.id="ID_"+Date.now();selectors=selectors.replace(/((^|,)\s*):scope/g,"$1#"+this.id);var result=doc[method](selectors);this.id=id;return result}else{return native.call(this,selectors)}}})}})(window.document,Element.prototype)},{}],19:[function(require,module,exports){"use strict";var clamp=require("clamp");var linspace=require("linspace");var utils=require("../utils");var evaluate=require("../helpers/eval").builtIn;function checkAsymptote(d0,d1,meta,sign,level){if(!level){return{asymptote:true,d0:d0,d1:d1}}var i;var n=10;var x0=d0[0];var x1=d1[0];var samples=linspace(x0,x1,n);var oldY,oldX;for(i=0;i1/zoomScale){var check=checkAsymptote(data[i-1],data[i],meta,newSign,3);if(check.asymptote){st.push(updateY(check.d0));sets.push(st);st=[updateY(check.d1)]}}oldSign=newSign;st.push(data[i]);++i}if(st.length){sets.push(st)}return sets}function linear(chart,meta,range,n){var allX=utils.space(chart,range,n);var yDomain=chart.meta.yScale.domain();var yDomainMargin=yDomain[1]-yDomain[0];var yMin=yDomain[0]-yDomainMargin*1e5;var yMax=yDomain[1]+yDomainMargin*1e5;var data=[];var i;for(i=0;inext[1].hi){prev[1].hi=Math.max(yMax,prev[1].hi);next[1].lo=Math.min(yMin,next[1].lo)}if(prev[1].hirange[0]-globals.TIP_X_EPS&&x00){return 1}return 0},color:function(data,index){return data.color||globals.COLORS[index]}}},{"./globals":4,linspace:51,log10:52,logspace:53}],23:[function(require,module,exports){"use strict";module.exports=require("./lib/eval")},{"./lib/eval":25}],24:[function(require,module,exports){"use strict";module.exports=function(){var math=Object.create(Math);math.factory=function(a){if(typeof a!=="number"){throw new TypeError("built-in math factory only accepts numbers")}return Number(a)};math.add=function(a,b){return a+b};math.sub=function(a,b){return a-b};math.mul=function(a,b){return a*b};math.div=function(a,b){return a/b};math.mod=function(a,b){return a%b};math.factorial=function(a){var res=1;for(var i=2;i<=a;i+=1){res*=i}return res};math.nthRoot=function(a,root){var inv=root<0;if(inv){root=-root}if(root===0){throw new Error("Root must be non-zero")}if(a<0&&Math.abs(root)%2!==1){throw new Error("Root must be odd when a is negative.")}if(a===0){return 0}if(!isFinite(a)){return inv?0:a}var x=Math.pow(Math.abs(a),1/root);x=a<0?-x:x;return inv?1/x:x};math.logicalOR=function(a,b){return a||b};math.logicalXOR=function(a,b){return a!=b};math.logicalAND=function(a,b){return a&&b};math.bitwiseOR=function(a,b){return a|b};math.bitwiseXOR=function(a,b){return a^b};math.bitwiseAND=function(a,b){return a&b};math.lessThan=function(a,b){return ab};math.greaterEqualThan=function(a,b){return a>=b};math.equal=function(a,b){return a==b};math.strictlyEqual=function(a,b){return a===b};math.notEqual=function(a,b){return a!=b};math.strictlyNotEqual=function(a,b){return a!==b};math.shiftRight=function(a,b){return a>>b};math.shiftLeft=function(a,b){return a<>>b};math.negative=function(a){return-a};math.positive=function(a){return a};return math}},{}],25:[function(require,module,exports){"use strict";var CodeGenerator=require("math-codegen");var math=require("./adapter")();function processScope(scope){Object.keys(scope).forEach(function(k){var value=scope[k];scope[k]=math.factory(value)})}module.exports=function(expression){return(new CodeGenerator).setDefs({$$processScope:processScope}).parse(expression).compile(math)};module.exports.math=math},{"./adapter":24,"math-codegen":54}],26:[function(require,module,exports){module.exports=clamp;function clamp(value,min,max){return minmax?max:value:valuemin?min:value}},{}],27:[function(require,module,exports){(function(Buffer){var hasTypedArrays=false;if(typeof Float64Array!=="undefined"){var DOUBLE_VIEW=new Float64Array(1),UINT_VIEW=new Uint32Array(DOUBLE_VIEW.buffer);DOUBLE_VIEW[0]=1;hasTypedArrays=true;if(UINT_VIEW[1]===1072693248){module.exports=function doubleBitsLE(n){DOUBLE_VIEW[0]=n;return[UINT_VIEW[0],UINT_VIEW[1]]};function toDoubleLE(lo,hi){UINT_VIEW[0]=lo;UINT_VIEW[1]=hi;return DOUBLE_VIEW[0]}module.exports.pack=toDoubleLE;function lowUintLE(n){DOUBLE_VIEW[0]=n;return UINT_VIEW[0]}module.exports.lo=lowUintLE;function highUintLE(n){DOUBLE_VIEW[0]=n;return UINT_VIEW[1]}module.exports.hi=highUintLE}else if(UINT_VIEW[0]===1072693248){module.exports=function doubleBitsBE(n){DOUBLE_VIEW[0]=n;return[UINT_VIEW[1],UINT_VIEW[0]]};function toDoubleBE(lo,hi){UINT_VIEW[1]=lo;UINT_VIEW[0]=hi;return DOUBLE_VIEW[0]}module.exports.pack=toDoubleBE;function lowUintBE(n){DOUBLE_VIEW[0]=n;return UINT_VIEW[1]}module.exports.lo=lowUintBE;function highUintBE(n){DOUBLE_VIEW[0]=n;return UINT_VIEW[0]}module.exports.hi=highUintBE}else{hasTypedArrays=false}}if(!hasTypedArrays){var buffer=new Buffer(8);module.exports=function doubleBits(n){buffer.writeDoubleLE(n,0,true);return[buffer.readUInt32LE(0,true),buffer.readUInt32LE(4,true)]};function toDouble(lo,hi){buffer.writeUInt32LE(lo,0,true);buffer.writeUInt32LE(hi,4,true);return buffer.readDoubleLE(0,true)}module.exports.pack=toDouble;function lowUint(n){buffer.writeDoubleLE(n,0,true);return buffer.readUInt32LE(0,true)}module.exports.lo=lowUint;function highUint(n){buffer.writeDoubleLE(n,0,true);return buffer.readUInt32LE(4,true)}module.exports.hi=highUint}module.exports.sign=function(n){return module.exports.hi(n)>>>31};module.exports.exponent=function(n){var b=module.exports.hi(n);return(b<<1>>>21)-1023};module.exports.fraction=function(n){var lo=module.exports.lo(n);var hi=module.exports.hi(n);var b=hi&(1<<20)-1;if(hi&2146435072){b+=1<<20}return[lo,b]};module.exports.denormalized=function(n){var hi=module.exports.hi(n);return!(hi&2146435072)}}).call(this,require("buffer").Buffer)},{buffer:87}],28:[function(require,module,exports){"use strict";var hasOwn=Object.prototype.hasOwnProperty;var toStr=Object.prototype.toString;var isArray=function isArray(arr){if(typeof Array.isArray==="function"){return Array.isArray(arr)}return toStr.call(arr)==="[object Array]"};var isPlainObject=function isPlainObject(obj){if(!obj||toStr.call(obj)!=="[object Object]"){return false}var hasOwnConstructor=hasOwn.call(obj,"constructor");var hasIsPrototypeOf=obj.constructor&&obj.constructor.prototype&&hasOwn.call(obj.constructor.prototype,"isPrototypeOf");if(obj.constructor&&!hasOwnConstructor&&!hasIsPrototypeOf){return false}var key;for(key in obj){}return typeof key==="undefined"||hasOwn.call(obj,key)};module.exports=function extend(){var options,name,src,copy,copyIsArray,clone,target=arguments[0],i=1,length=arguments.length,deep=false;if(typeof target==="boolean"){deep=target;target=arguments[1]||{};i=2}else if(typeof target!=="object"&&typeof target!=="function"||target==null){target={}}for(;imaxdepth){state.maxDepthCount++;return s2+err}else if(Math.abs(err)0&&console&&console.warn){console.warn("integrate-adaptive-simpson: Warning: maximum recursion depth ("+maxdepth+") reached "+state.maxDepthCount+" times")}if(state.nanEncountered&&console&&console.warn){console.warn("integrate-adaptive-simpson: Warning: NaN encountered. Halting early.")}return result}},{}],31:[function(require,module,exports){"use strict";module.exports=require("./lib/eval")},{"./lib/eval":33}],32:[function(require,module,exports){"use strict";module.exports=function(ns){ns.mod=ns.fmod;ns.lessThan=ns.lt;ns.lessEqualThan=ns.leq;ns.greaterThan=ns.gt;ns.greaterEqualThan=ns.geq;ns.strictlyEqual=ns.equal;ns.strictlyNotEqual=ns.notEqual;ns.logicalAND=function(a,b){return a&&b};ns.logicalXOR=function(a,b){return a^b};ns.logicalOR=function(a,b){return a||b}}},{}],33:[function(require,module,exports){"use strict";var CodeGenerator=require("math-codegen");var Interval=require("interval-arithmetic");require("./adapter")(Interval);function processScope(scope){Object.keys(scope).forEach(function(k){var value=scope[k];if(typeof value==="number"||Array.isArray(value)){scope[k]=Interval.factory(value)}else if(typeof value==="object"&&"lo"in value&&"hi"in value){scope[k]=Interval.factory(value.lo,value.hi)}})}module.exports=function(expression){return(new CodeGenerator).setDefs({$$processScope:processScope}).parse(expression).compile(Interval)};module.exports.policies=require("./policies")(Interval);module.exports.Interval=Interval},{"./adapter":32,"./policies":34,"interval-arithmetic":35,"math-codegen":54}],34:[function(require,module,exports){"use strict";module.exports=function(Interval){return{disableRounding:function(){Interval.rmath.disable()},enableRounding:function(){Interval.rmath.enable()}}}},{}],35:[function(require,module,exports){"use strict";var extend=require("xtend/mutable");require("./lib/polyfill");module.exports=require("./lib/interval");module.exports.rmath=require("./lib/round-math");module.exports.round=require("./lib/round-math");extend(module.exports,require("./lib/constants"),require("./lib/operations/relational"),require("./lib/operations/arithmetic"),require("./lib/operations/algebra"),require("./lib/operations/trigonometric"),require("./lib/operations/misc"),require("./lib/operations/utils"))},{"./lib/constants":36,"./lib/interval":37,"./lib/operations/algebra":38,"./lib/operations/arithmetic":39,"./lib/operations/misc":41,"./lib/operations/relational":42,"./lib/operations/trigonometric":43,"./lib/operations/utils":44,"./lib/polyfill":45,"./lib/round-math":46,"xtend/mutable":85}],36:[function(require,module,exports){"use strict";var Interval=require("./interval");var mutate=require("xtend/mutable");var piLow=(3373259426+273688/(1<<21))/(1<<30);var piHigh=(3373259426+273689/(1<<21))/(1<<30);var constants={};mutate(constants,{PI_LOW:piLow,PI_HIGH:piHigh,PI_HALF_LOW:piLow/2,PI_HALF_HIGH:piHigh/2,PI_TWICE_LOW:piLow*2,PI_TWICE_HIGH:piHigh*2});function getter(property,fn){Object.defineProperty(constants,property,{get:function(){return fn()},enumerable:true})}getter("PI",function(){return Interval(piLow,piHigh)});getter("PI_HALF",function(){return Interval(constants.PI_HALF_LOW,constants.PI_HALF_HIGH)});getter("PI_TWICE",function(){return Interval(constants.PI_TWICE_LOW,constants.PI_TWICE_HIGH)});getter("ZERO",function(){return Interval(0)});getter("ONE",function(){return Interval(1)});getter("WHOLE",function(){return Interval().setWhole()});getter("EMPTY",function(){return Interval().setEmpty()});module.exports=constants},{"./interval":37,"xtend/mutable":85}],37:[function(require,module,exports){"use strict";var utils=require("./operations/utils");var round=require("./round-math");module.exports=Interval;function Interval(lo,hi){if(!(this instanceof Interval)){return new Interval(lo,hi)}if(typeof lo!=="undefined"&&typeof hi!=="undefined"){if(utils.isInterval(lo)){if(!utils.isSingleton(lo)){throw new TypeError("Interval: interval `lo` must be a singleton")}lo=lo.lo}if(utils.isInterval(hi)){if(!utils.isSingleton(hi)){throw TypeError("Interval: interval `hi` must be a singleton")}hi=hi.hi}}else if(typeof lo!=="undefined"){if(Array.isArray(lo)){return Interval(lo[0],lo[1])}return Interval(lo,lo)}else{lo=hi=0}this.lo=undefined;this.hi=undefined;this.assign(lo,hi)}Interval.factory=Interval;Interval.prototype.singleton=function(v){return this.set(v,v)};Interval.prototype.bounded=function(lo,hi){return this.set(round.prev(lo),round.next(hi))};Interval.prototype.boundedSingleton=function(v){return this.bounded(v,v)};Interval.prototype.set=function(lo,hi){this.lo=lo;this.hi=hi;return this};Interval.prototype.assign=function(lo,hi){if(typeof lo!=="number"||typeof hi!=="number"){throw TypeError("Interval#assign: arguments must be numbers")}if(isNaN(lo)||isNaN(hi)||lo>hi){return this.setEmpty()}return this.set(lo,hi)};Interval.prototype.setEmpty=function(){return this.set(Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY)};Interval.prototype.setWhole=function(){return this.set(Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY)};Interval.prototype.open=function(lo,hi){return this.assign(round.safeNext(lo),round.safePrev(hi))};Interval.prototype.halfOpenLeft=function(lo,hi){return this.assign(round.safeNext(lo),hi)};Interval.prototype.halfOpenRight=function(lo,hi){return this.assign(lo,round.safePrev(hi))};Interval.prototype.toArray=function(){return[this.lo,this.hi]};Interval.prototype.clone=function(){return Interval().set(this.lo,this.hi)}},{"./operations/utils":44,"./round-math":46}],38:[function(require,module,exports){"use strict";var isSafeInteger=require("is-safe-integer");var Interval=require("../interval");var rmath=require("../round-math");var utils=require("./utils");var arithmetic=require("./arithmetic");var constants=require("../constants");var algebra={};algebra.fmod=function(x,y){if(utils.isEmpty(x)||utils.isEmpty(y)){return constants.EMPTY}var yb=x.lo<0?y.lo:y.hi;var n=rmath.intLo(rmath.divLo(x.lo,yb));return arithmetic.sub(x,arithmetic.mul(y,Interval(n)))};algebra.multiplicativeInverse=function(x){if(utils.isEmpty(x)){return constants.EMPTY}if(utils.zeroIn(x)){if(x.lo!==0){if(x.hi!==0){return constants.WHOLE}else{return Interval(Number.NEGATIVE_INFINITY,rmath.divHi(1,x.lo))}}else{if(x.hi!==0){return Interval(rmath.divLo(1,x.hi),Number.POSITIVE_INFINITY)}else{return constants.EMPTY}}}else{return Interval(rmath.divLo(1,x.hi),rmath.divHi(1,x.lo))}};algebra.pow=function(x,power){if(utils.isEmpty(x)){return constants.EMPTY}if(typeof power==="object"){if(!utils.isSingleton(power)){return constants.EMPTY}power=power.lo}if(power===0){if(x.lo===0&&x.hi===0){return constants.EMPTY}else{return constants.ONE}}else if(power<0){return algebra.multiplicativeInverse(algebra.pow(x,-power))}if(isSafeInteger(power)){if(x.hi<0){var yl=rmath.powLo(-x.hi,power);var yh=rmath.powHi(-x.lo,power);if(power&1){return Interval(-yh,-yl)}else{return Interval(yl,yh)}}else if(x.lo<0){if(power&1){return Interval(-rmath.powLo(-x.lo,power),rmath.powHi(x.hi,power))}else{return Interval(0,rmath.powHi(Math.max(-x.lo,x.hi),power))}}else{return Interval(rmath.powLo(x.lo,power),rmath.powHi(x.hi,power))}}else{console.warn("power is not an integer, you should use nth-root instead, returning an empty interval");return constants.EMPTY}};algebra.sqrt=function(x){return algebra.nthRoot(x,2)};algebra.nthRoot=function(x,n){if(utils.isEmpty(x)||n<0){return constants.EMPTY}if(typeof n==="object"){if(!utils.isSingleton(n)){return constants.EMPTY}n=n.lo}var power=1/n;if(x.hi<0){if(isSafeInteger(n)&(n&1)){var yl=rmath.powHi(-x.lo,power);var yh=rmath.powLo(-x.hi,power);return Interval(-yl,-yh)}return Interval.EMPTY}else if(x.lo<0){var yp=rmath.powHi(x.hi,power);if(isSafeInteger(n)&(n&1)){var yn=rmath.powHi(-x.lo,power);return Interval(0,Math.max(yn,yp))}return Interval(0,yp)}else{return Interval(rmath.powLo(x.lo,power),rmath.powHi(x.hi,power))}};module.exports=algebra},{"../constants":36,"../interval":37,"../round-math":46,"./arithmetic":39,"./utils":44,"is-safe-integer":48}],39:[function(require,module,exports){"use strict";var Interval=require("../interval");var rmath=require("../round-math");var utils=require("./utils");var constants=require("../constants");var division=require("./division");var arithmetic={};arithmetic.add=function(x,y){return Interval(rmath.addLo(x.lo,y.lo),rmath.addHi(x.hi,y.hi))};arithmetic.subtract=function(x,y){return Interval(rmath.subLo(x.lo,y.hi),rmath.subHi(x.hi,y.lo))};arithmetic.sub=arithmetic.subtract;arithmetic.multiply=function(x,y){if(utils.isEmpty(x)||utils.isEmpty(y)){return constants.EMPTY}var xl=x.lo;var xh=x.hi;var yl=y.lo;var yh=y.hi;var out=Interval();if(xl<0){if(xh>0){if(yl<0){if(yh>0){out.lo=Math.min(rmath.mulLo(xl,yh),rmath.mulLo(xh,yl));out.hi=Math.max(rmath.mulHi(xl,yl),rmath.mulHi(xh,yh))}else{out.lo=rmath.mulLo(xh,yl);out.hi=rmath.mulHi(xl,yl)}}else{if(yh>0){out.lo=rmath.mulLo(xl,yh);out.hi=rmath.mulHi(xh,yh)}else{out.lo=0;out.hi=0}}}else{if(yl<0){if(yh>0){out.lo=rmath.mulLo(xl,yh);out.hi=rmath.mulHi(xl,yl)}else{out.lo=rmath.mulLo(xh,yh);out.hi=rmath.mulHi(xl,yl)}}else{if(yh>0){out.lo=rmath.mulLo(xl,yh);out.hi=rmath.mulHi(xh,yl)}else{out.lo=0;out.hi=0}}}}else{if(xh>0){if(yl<0){if(yh>0){out.lo=rmath.mulLo(xh,yl);out.hi=rmath.mulHi(xh,yh)}else{out.lo=rmath.mulLo(xh,yl);out.hi=rmath.mulHi(xl,yh)}}else{if(yh>0){out.lo=rmath.mulLo(xl,yl);out.hi=rmath.mulHi(xh,yh)}else{out.lo=0;out.hi=0}}}else{out.lo=0;out.hi=0}}return out};arithmetic.mul=arithmetic.multiply;arithmetic.divide=function(x,y){if(utils.isEmpty(x)||utils.isEmpty(y)){return constants.EMPTY}if(utils.zeroIn(y)){if(y.lo!==0){if(y.hi!==0){return division.zero(x)}else{return division.negative(x,y.lo)}}else{if(y.hi!==0){return division.positive(x,y.hi)}else{return constants.EMPTY}}}else{return division.nonZero(x,y)}};arithmetic.div=arithmetic.divide;arithmetic.positive=function(x){return Interval(x.lo,x.hi)};arithmetic.negative=function(x){return Interval(-x.hi,-x.lo)};module.exports=arithmetic},{"../constants":36,"../interval":37,"../round-math":46,"./division":40,"./utils":44}],40:[function(require,module,exports){"use strict";var Interval=require("../interval");var rmath=require("../round-math");var utils=require("./utils");var constants=require("../constants");var division={nonZero:function(x,y){var xl=x.lo;var xh=x.hi;var yl=y.lo;var yh=y.hi;var out=Interval();if(xh<0){if(yh<0){out.lo=rmath.divLo(xh,yl);out.hi=rmath.divHi(xl,yh)}else{out.lo=rmath.divLo(xl,yl);out.hi=rmath.divHi(xh,yh)}}else if(xl<0){if(yh<0){out.lo=rmath.divLo(xh,yh);out.hi=rmath.divHi(xl,yh)}else{out.lo=rmath.divLo(xl,yl);out.hi=rmath.divHi(xh,yl)}}else{if(yh<0){out.lo=rmath.divLo(xh,yh);out.hi=rmath.divHi(xl,yl)}else{out.lo=rmath.divLo(xl,yh);out.hi=rmath.divHi(xh,yl)}}return out},positive:function(x,v){if(x.lo===0&&x.hi===0){return x}if(utils.zeroIn(x)){return constants.WHOLE}if(x.hi<0){return Interval(Number.NEGATIVE_INFINITY,rmath.divHi(x.hi,v))}else{return Interval(rmath.divLo(x.lo,v),Number.POSITIVE_INFINITY)}},negative:function(x,v){if(x.lo===0&&x.hi===0){return x}if(utils.zeroIn(x)){return constants.WHOLE}if(x.hi<0){return Interval(rmath.divLo(x.hi,v),Number.POSITIVE_INFINITY)}else{return Interval(Number.NEGATIVE_INFINITY,rmath.divHi(x.lo,v))}},zero:function(x){if(x.lo===0&&x.hi===0){return x}return constants.WHOLE}};module.exports=division},{"../constants":36,"../interval":37,"../round-math":46,"./utils":44}],41:[function(require,module,exports){"use strict";var constants=require("../constants");var Interval=require("../interval");var rmath=require("../round-math");var utils=require("./utils");var arithmetic=require("./arithmetic");var misc={};misc.exp=function(x){if(utils.isEmpty(x)){return constants.EMPTY}return Interval(rmath.expLo(x.lo),rmath.expHi(x.hi))};misc.log=function(x){if(utils.isEmpty(x)){return constants.EMPTY}var l=x.lo<=0?Number.NEGATIVE_INFINITY:rmath.logLo(x.lo);return Interval(l,rmath.logHi(x.hi))};misc.ln=misc.log;misc.LOG_EXP_10=misc.log(Interval(10,10));misc.log10=function(x){if(utils.isEmpty(x)){return constants.EMPTY}return arithmetic.div(misc.log(x),misc.LOG_EXP_10)};misc.LOG_EXP_2=misc.log(Interval(2,2));misc.log2=function(x){if(utils.isEmpty(x)){return constants.EMPTY}return arithmetic.div(misc.log(x),misc.LOG_EXP_2)};misc.hull=function(x,y){var badX=utils.isEmpty(x);var badY=utils.isEmpty(y);if(badX&&badY){return constants.EMPTY}else if(badX){return y.clone()}else if(badY){return x.clone()}else{return Interval(Math.min(x.lo,y.lo),Math.max(x.hi,y.hi))}};misc.intersection=function(x,y){if(utils.isEmpty(x)||utils.isEmpty(y)){return constants.EMPTY}var lo=Math.max(x.lo,y.lo);var hi=Math.min(x.hi,y.hi);if(lo<=hi){return Interval(lo,hi)}return constants.EMPTY};misc.union=function(x,y){if(!utils.intervalsOverlap(x,y)){throw Error("Interval#union: intervals do not overlap")}return Interval(Math.min(x.lo,y.lo),Math.max(x.hi,y.hi))};misc.difference=function(x,y){if(utils.isEmpty(x)||utils.isWhole(y)){return constants.EMPTY}if(utils.intervalsOverlap(x,y)){if(x.lo=x.hi&&y.lo===-Infinity){return constants.EMPTY}if(y.lo<=x.lo){return Interval().halfOpenLeft(y.hi,x.hi)}return Interval().halfOpenRight(x.lo,y.lo)}return Interval.clone(x)};misc.width=function(x){if(utils.isEmpty(x)){return 0}return rmath.subHi(x.hi,x.lo)};misc.wid=misc.width;misc.abs=function(x){if(utils.isEmpty(x)){return constants.EMPTY}if(x.lo>=0){return Interval.clone(x)}if(x.hi<=0){return arithmetic.negative(x)}return Interval(0,Math.max(-x.lo,x.hi))};misc.max=function(x,y){var badX=utils.isEmpty(x);var badY=utils.isEmpty(y);if(badX&&badY){return constants.EMPTY}else if(badX){return y.clone()}else if(badY){return x.clone()}else{return Interval(Math.max(x.lo,y.lo),Math.max(x.hi,y.hi))}};misc.min=function(x,y){var badX=utils.isEmpty(x);var badY=utils.isEmpty(y);if(badX&&badY){return constants.EMPTY}else if(badX){return y.clone()}else if(badY){return x.clone()}else{return Interval(Math.min(x.lo,y.lo),Math.min(x.hi,y.hi))}};misc.clone=function(x){return Interval().set(x.lo,x.hi)};module.exports=misc},{"../constants":36,"../interval":37,"../round-math":46,"./arithmetic":39,"./utils":44}],42:[function(require,module,exports){"use strict";var utils=require("./utils");var relational={};relational.equal=function(x,y){if(utils.isEmpty(x)){return utils.isEmpty(y)}return!utils.isEmpty(y)&&x.lo===y.lo&&x.hi===y.hi};relational.almostEqual=function(x,y){var EPS=1e-7;function assert(a,message){if(!a){throw new Error(message||"assertion failed")}}function assertEps(a,b){assert(Math.abs(a-b)y.hi};relational.lessThan=function(x,y){if(utils.isEmpty(x)||utils.isEmpty(y)){return false}return x.hiy.hi};relational.gt=relational.greaterThan;relational.lessEqualThan=function(x,y){if(utils.isEmpty(x)||utils.isEmpty(y)){return false}return x.hi<=y.lo};relational.leq=relational.lessEqualThan;relational.greaterEqualThan=function(x,y){if(utils.isEmpty(x)||utils.isEmpty(y)){return false}return x.lo>=y.hi};relational.geq=relational.greaterEqualThan;module.exports=relational},{"./utils":44}],43:[function(require,module,exports){"use strict";var constants=require("../constants");var Interval=require("../interval");var rmath=require("../round-math");var utils=require("./utils");var misc=require("./misc");var algebra=require("./algebra");var arithmetic=require("./arithmetic");var trigonometric={};trigonometric.cos=function(x){var rlo,rhi;if(utils.isEmpty(x)){return constants.EMPTY}var cache=Interval();cache.set(x.lo,x.hi);if(cache.lo<0){var n=Math.ceil(-cache.lo/constants.PI_TWICE_LOW);cache.lo+=constants.PI_TWICE_LOW*n;cache.hi+=constants.PI_TWICE_LOW*n}var pi2=constants.PI_TWICE;var t=algebra.fmod(cache,pi2);if(misc.width(t)>=pi2.lo){return Interval(-1,1)}if(t.lo>=constants.PI_HIGH){var cos=trigonometric.cos(arithmetic.sub(t,constants.PI));return arithmetic.negative(cos)}var lo=t.lo;var hi=t.hi;rlo=rmath.cosLo(hi);rhi=rmath.cosHi(lo);if(hi<=constants.PI_LOW){return Interval(rlo,rhi)}else if(hi<=pi2.lo){return Interval(-1,Math.max(rlo,rhi))}else{return Interval(-1,1)}};trigonometric.sin=function(x){if(utils.isEmpty(x)){return constants.EMPTY}return trigonometric.cos(arithmetic.sub(x,constants.PI_HALF))};trigonometric.tan=function(x){if(utils.isEmpty(x)){return constants.EMPTY}var cache=Interval();cache.set(x.lo,x.hi);if(cache.lo<0){var n=Math.ceil(-cache.lo/constants.PI_TWICE_LOW);cache.lo+=constants.PI_TWICE_LOW*n;cache.hi+=constants.PI_TWICE_LOW*n}var pi=constants.PI;var t=algebra.fmod(cache,pi);if(t.lo>=constants.PI_HALF_LOW){t=arithmetic.sub(t,pi)}if(t.lo<=-constants.PI_HALF_LOW||t.hi>=constants.PI_HALF_LOW){return constants.WHOLE}return Interval(rmath.tanLo(t.lo),rmath.tanHi(t.hi))};trigonometric.asin=function(x){if(utils.isEmpty(x)||x.hi<-1||x.lo>1){return constants.EMPTY}var lo=x.lo<=-1?-constants.PI_HALF_HIGH:rmath.asinLo(x.lo);var hi=x.hi>=1?constants.PI_HALF_HIGH:rmath.asinHi(x.hi);return Interval(lo,hi)};trigonometric.acos=function(x){if(utils.isEmpty(x)||x.hi<-1||x.lo>1){return constants.EMPTY}var lo=x.hi>=1?0:rmath.acosLo(x.hi);var hi=x.lo<=-1?constants.PI_HIGH:rmath.acosHi(x.lo);return Interval(lo,hi)};trigonometric.atan=function(x){if(utils.isEmpty(x)){return constants.EMPTY}return Interval(rmath.atanLo(x.lo),rmath.atanHi(x.hi))};trigonometric.sinh=function(x){if(utils.isEmpty(x)){return constants.EMPTY}return Interval(rmath.sinhLo(x.lo),rmath.sinhHi(x.hi))};trigonometric.cosh=function(x){if(utils.isEmpty(x)){return constants.EMPTY}if(x.hi<0){return Interval(rmath.coshLo(x.hi),rmath.coshHi(x.lo))}else if(x.lo>=0){return Interval(rmath.coshLo(x.lo),rmath.coshHi(x.hi))}else{return Interval(1,rmath.coshHi(-x.lo>x.hi?x.lo:x.hi))}};trigonometric.tanh=function(x){if(utils.isEmpty(x)){return constants.EMPTY}return Interval(rmath.tanhLo(x.lo),rmath.tanhHi(x.hi))};module.exports=trigonometric},{"../constants":36,"../interval":37,"../round-math":46,"./algebra":38,"./arithmetic":39,"./misc":41,"./utils":44}],44:[function(require,module,exports){"use strict";var utils={};utils.isInterval=function(x){return typeof x==="object"&&typeof x.lo==="number"&&typeof x.hi==="number"};utils.isEmpty=function(x){return x.lo>x.hi};utils.isWhole=function(x){return x.lo===-Infinity&&x.hi===Infinity; -};utils.isSingleton=function(x){return x.lo===x.hi};utils.zeroIn=function(x){return utils.hasValue(x,0)};utils.hasValue=function(a,value){if(utils.isEmpty(a)){return false}return a.lo<=value&&value<=a.hi};utils.hasInterval=function(x,y){if(utils.isEmpty(x)){return true}return!utils.isEmpty(y)&&y.lo<=x.lo&&x.hi<=y.hi};utils.intervalsOverlap=function(x,y){if(utils.isEmpty(x)||utils.isEmpty(y)){return false}return x.lo<=y.lo&&y.lo<=x.hi||y.lo<=x.lo&&x.lo<=y.hi};module.exports=utils},{}],45:[function(require,module,exports){"use strict";Math.sinh=Math.sinh||function(x){var y=Math.exp(x);return(y-1/y)/2};Math.cosh=Math.cosh||function(x){var y=Math.exp(x);return(y+1/y)/2};Math.tanh=Math.tanh||function(x){if(x===Number.POSITIVE_INFINITY){return 1}else if(x===Number.NEGATIVE_INFINITY){return-1}else{var y=Math.exp(2*x);return(y-1)/(y+1)}}},{}],46:[function(require,module,exports){"use strict";var nextafter=require("nextafter");function identity(v){return v}function prev(v){if(v===Infinity){return v}return nextafter(v,-Infinity)}function next(v){if(v===-Infinity){return v}return nextafter(v,Infinity)}var round={safePrev:prev,safeNext:next,prev:prev,next:next};round.addLo=function(x,y){return this.prev(x+y)};round.addHi=function(x,y){return this.next(x+y)};round.subLo=function(x,y){return this.prev(x-y)};round.subHi=function(x,y){return this.next(x-y)};round.mulLo=function(x,y){return this.prev(x*y)};round.mulHi=function(x,y){return this.next(x*y)};round.divLo=function(x,y){return this.prev(x/y)};round.divHi=function(x,y){return this.next(x/y)};function toInteger(x){return x<0?Math.ceil(x):Math.floor(x)}round.intLo=function(x){return toInteger(this.prev(x))};round.intHi=function(x){return toInteger(this.next(x))};round.logLo=function(x){return this.prev(Math.log(x))};round.logHi=function(x){return this.next(Math.log(x))};round.expLo=function(x){return this.prev(Math.exp(x))};round.expHi=function(x){return this.next(Math.exp(x))};round.sinLo=function(x){return this.prev(Math.sin(x))};round.sinHi=function(x){return this.next(Math.sin(x))};round.cosLo=function(x){return this.prev(Math.cos(x))};round.cosHi=function(x){return this.next(Math.cos(x))};round.tanLo=function(x){return this.prev(Math.tan(x))};round.tanHi=function(x){return this.next(Math.tan(x))};round.asinLo=function(x){return this.prev(Math.asin(x))};round.asinHi=function(x){return this.next(Math.asin(x))};round.acosLo=function(x){return this.prev(Math.acos(x))};round.acosHi=function(x){return this.next(Math.acos(x))};round.atanLo=function(x){return this.prev(Math.atan(x))};round.atanHi=function(x){return this.next(Math.atan(x))};round.sinhLo=function(x){return this.prev(Math.sinh(x))};round.sinhHi=function(x){return this.next(Math.sinh(x))};round.coshLo=function(x){return this.prev(Math.cosh(x))};round.coshHi=function(x){return this.next(Math.cosh(x))};round.tanhLo=function(x){return this.prev(Math.tanh(x))};round.tanhHi=function(x){return this.next(Math.tanh(x))};round.powLo=function(x,power){if(power%1!==0){return this.prev(Math.pow(x,power))}var y=power&1?x:1;power>>=1;while(power>0){x=round.mulLo(x,x);if(power&1){y=round.mulLo(x,y)}power>>=1}return y};round.powHi=function(x,power){if(power%1!==0){return this.next(Math.pow(x,power))}var y=power&1?x:1;power>>=1;while(power>0){x=round.mulHi(x,x);if(power&1){y=round.mulHi(x,y)}power>>=1}return y};round.sqrtLo=function(x){return this.prev(Math.sqrt(x))};round.sqrtHi=function(x){return this.next(Math.sqrt(x))};round.disable=function(){this.next=this.prev=identity};round.enable=function(){this.next=next;this.prev=prev};module.exports=round},{nextafter:83}],47:[function(require,module,exports){"use strict";module.exports=function isObject(x){return typeof x==="object"&&x!==null}},{}],48:[function(require,module,exports){"use strict";var MAX_SAFE_INTEGER=require("max-safe-integer");module.exports=Number.isSafeInteger||function(val){return typeof val==="number"&&val===val&&val!==Infinity&&val!==-Infinity&&parseInt(val,10)===val&&Math.abs(val)<=MAX_SAFE_INTEGER}},{"max-safe-integer":67}],49:[function(require,module,exports){(function(process){var keys=require("vkey");var list=Object.keys(keys);var down={};reset();module.exports=pressed;if(process.browser){window.addEventListener("keydown",keydown,false);window.addEventListener("keyup",keyup,false);window.addEventListener("blur",reset,false)}function pressed(key){return key?down[key]:down}function reset(){list.forEach(function(code){down[keys[code]]=false})}function keyup(e){down[keys[e.keyCode]]=false}function keydown(e){down[keys[e.keyCode]]=true}}).call(this,require("_process"))},{_process:91,vkey:84}],50:[function(require,module,exports){var Emitter=require("events").EventEmitter;var vkey=require("vkey");module.exports=function(keys,el){if(typeof keys==="string")keys=[keys];if(!el)el=window;var emitter=new Emitter;emitter.pressed={};el.addEventListener("blur",clearPressed);el.addEventListener("focus",clearPressed);el.addEventListener("keydown",function(ev){var key=vkey[ev.keyCode];emitter.pressed[key]=true;var allPressed=true;keys.forEach(function(k){if(!emitter.pressed[k])allPressed=false});if(allPressed){emitter.emit("pressed",emitter.pressed);clearPressed()}});el.addEventListener("keyup",function(ev){delete emitter.pressed[vkey[ev.keyCode]]});function clearPressed(){emitter.pressed={}}return emitter}},{events:89,vkey:84}],51:[function(require,module,exports){var integers=require("integers");module.exports=function linspace(a,b,n){var every=(b-a)/(n-1),ranged=integers(a,b,every);return ranged.length==n?ranged:ranged.concat(b)}},{integers:29}],52:[function(require,module,exports){"use strict";module.exports=Math.log10||function(x){return Math.log(x)*Math.LOG10E}},{}],53:[function(require,module,exports){var linspace=require("linspace");module.exports=function logspace(a,b,n){return linspace(a,b,n).map(function(x){return Math.pow(10,x)})}},{linspace:51}],54:[function(require,module,exports){"use strict";module.exports=require("./lib/CodeGenerator")},{"./lib/CodeGenerator":55}],55:[function(require,module,exports){"use strict";var Parser=require("mr-parser").Parser;var Interpreter=require("./Interpreter");var extend=require("extend");function CodeGenerator(options,defs){this.statements=[];this.defs=defs||{};this.interpreter=new Interpreter(this,options)}CodeGenerator.prototype.setDefs=function(defs){this.defs=extend(this.defs,defs);return this};CodeGenerator.prototype.compile=function(namespace){if(!namespace||!(typeof namespace==="object"||typeof namespace==="function")){throw TypeError("namespace must be an object")}if(typeof namespace.factory!=="function"){throw TypeError("namespace.factory must be a function")}this.defs.ns=namespace;this.defs.$$mathCodegen={getProperty:function(symbol,scope,ns){if(symbol in scope){return scope[symbol]}if(symbol in ns){return ns[symbol]}throw SyntaxError('symbol "'+symbol+'" is undefined')},functionProxy:function(fn,name){if(typeof fn!=="function"){throw SyntaxError('symbol "'+name+'" must be a function')}return fn}};this.defs.$$processScope=this.defs.$$processScope||function(){};var defsCode=Object.keys(this.defs).map(function(name){return"var "+name+' = defs["'+name+'"]'});if(!this.statements.length){throw Error("there are no statements saved in this generator, make sure you parse an expression before compiling it")}this.statements[this.statements.length-1]="return "+this.statements[this.statements.length-1];var code=this.statements.join(";");var factoryCode=defsCode.join("\n")+"\n"+["return {"," eval: function (scope) {"," scope = scope || {}"," $$processScope(scope)"," "+code," },"," code: '"+code+"'","}"].join("\n");var factory=new Function("defs",factoryCode);return factory(this.defs)};CodeGenerator.prototype.parse=function(code){var self=this;var program=(new Parser).parse(code);this.statements=program.blocks.map(function(statement){return self.interpreter.next(statement)});return this};module.exports=CodeGenerator},{"./Interpreter":56,extend:28,"mr-parser":68}],56:[function(require,module,exports){"use strict";var extend=require("extend");var types={ArrayNode:require("./node/ArrayNode"),AssignmentNode:require("./node/AssignmentNode"),ConditionalNode:require("./node/ConditionalNode"),ConstantNode:require("./node/ConstantNode"),FunctionNode:require("./node/FunctionNode"),OperatorNode:require("./node/OperatorNode"),SymbolNode:require("./node/SymbolNode"),UnaryNode:require("./node/UnaryNode")};var Interpreter=function(owner,options){this.owner=owner;this.options=extend({factory:"ns.factory",raw:false,rawArrayExpressionElements:true,rawCallExpressionElements:false},options)};extend(Interpreter.prototype,types);Interpreter.prototype.next=function(node){if(!(node.type in this)){throw new TypeError("the node type "+node.type+" is not implemented")}return this[node.type](node)};Interpreter.prototype.rawify=function(test,fn){var oldRaw=this.options.raw;if(test){this.options.raw=true}fn();if(test){this.options.raw=oldRaw}};module.exports=Interpreter},{"./node/ArrayNode":59,"./node/AssignmentNode":60,"./node/ConditionalNode":61,"./node/ConstantNode":62,"./node/FunctionNode":63,"./node/OperatorNode":64,"./node/SymbolNode":65,"./node/UnaryNode":66,extend:28}],57:[function(require,module,exports){"use strict";module.exports={"+":"add","-":"sub","*":"mul","/":"div","^":"pow","%":"mod","!":"factorial","|":"bitwiseOR","^|":"bitwiseXOR","&":"bitwiseAND","||":"logicalOR",xor:"logicalXOR","&&":"logicalAND","<":"lessThan",">":"greaterThan","<=":"lessEqualThan",">=":"greaterEqualThan","===":"strictlyEqual","==":"equal","!==":"strictlyNotEqual","!=":"notEqual",">>":"shiftRight","<<":"shiftLeft",">>>":"unsignedRightShift"}},{}],58:[function(require,module,exports){"use strict";module.exports={"+":"positive","-":"negative","~":"oneComplement"}},{}],59:[function(require,module,exports){"use strict";module.exports=function(node){var self=this;var arr=[];this.rawify(this.options.rawArrayExpressionElements,function(){arr=node.nodes.map(function(el){return self.next(el)})});var arrString="["+arr.join(",")+"]";if(this.options.raw){return arrString}return this.options.factory+"("+arrString+")"}},{}],60:[function(require,module,exports){"use strict";module.exports=function(node){return'scope["'+node.name+'"] = '+this.next(node.expr)}},{}],61:[function(require,module,exports){"use strict";module.exports=function(node){var condition="!!("+this.next(node.condition)+")";var trueExpr=this.next(node.trueExpr);var falseExpr=this.next(node.falseExpr);return"("+condition+" ? ("+trueExpr+") : ("+falseExpr+") )"}},{}],62:[function(require,module,exports){"use strict";module.exports=function(node){if(this.options.raw){return node.value}return this.options.factory+"("+node.value+")"}},{}],63:[function(require,module,exports){"use strict";var SymbolNode=require("mr-parser").nodeTypes.SymbolNode;var functionProxy=function(node){return"$$mathCodegen.functionProxy("+this.next(new SymbolNode(node.name))+', "'+node.name+'")'};module.exports=function(node){var self=this;var method=functionProxy.call(this,node);var args=[];this.rawify(this.options.rawCallExpressionElements,function(){args=node.args.map(function(arg){return self.next(arg)})});return method+"("+args.join(", ")+")"};module.exports.functionProxy=functionProxy},{"mr-parser":68}],64:[function(require,module,exports){"use strict";var Operators=require("../misc/Operators");module.exports=function(node){if(this.options.raw){return["("+this.next(node.args[0]),node.op,this.next(node.args[1])+")"].join(" ")}var namedOperator=Operators[node.op];if(!namedOperator){throw TypeError("unidentified operator")}return this.FunctionNode({name:namedOperator,args:node.args})}},{"../misc/Operators":57}],65:[function(require,module,exports){"use strict";module.exports=function(node){var id=node.name;return'$$mathCodegen.getProperty("'+id+'", scope, ns)'}},{}],66:[function(require,module,exports){"use strict";var UnaryOperators=require("../misc/UnaryOperators");module.exports=function(node){if(this.options.raw){return node.op+this.next(node.argument)}if(!(node.op in UnaryOperators)){throw new SyntaxError(node.op+" not implemented")}var namedOperator=UnaryOperators[node.op];return this.FunctionNode({name:namedOperator,args:[node.argument]})}},{"../misc/UnaryOperators":58}],67:[function(require,module,exports){"use strict";module.exports=9007199254740991},{}],68:[function(require,module,exports){"use strict";module.exports.Lexer=require("./lib/Lexer");module.exports.Parser=require("./lib/Parser");module.exports.nodeTypes=require("./lib/node/")},{"./lib/Lexer":69,"./lib/Parser":70,"./lib/node/":81}],69:[function(require,module,exports){var tokenType=require("./token-type");var ESCAPES={n:"\n",f:"\f",r:"\r",t:" ",v:" ","'":"'",'"':'"'};var DELIMITERS={",":true,"(":true,")":true,"[":true,"]":true,";":true,"~":true,"!":true,"+":true,"-":true,"*":true,"/":true,"%":true,"^":true,"**":true,"|":true,"&":true,"^|":true,"=":true,":":true,"?":true,"||":true,"&&":true,xor:true,"==":true,"!=":true,"===":true,"!==":true,"<":true,">":true,">=":true,"<=":true,">>>":true,"<<":true,">>":true};function isDigit(c){return c>="0"&&c<="9"}function isIdentifier(c){return c>="a"&&c<="z"||c>="A"&&c<="Z"||c==="$"||c==="_"}function isWhitespace(c){return c===" "||c==="\r"||c===" "||c==="\n"||c===" "||c===" "}function isDelimiter(str){return DELIMITERS[str]}function isQuote(c){return c==="'"||c==='"'}function Lexer(){}Lexer.prototype.throwError=function(message,index){index=typeof index==="undefined"?this.index:index;var error=new Error(message+" at index "+index);error.index=index;error.description=message;throw error};Lexer.prototype.lex=function(text){this.text=text;this.index=0;this.tokens=[];while(this.index=this.text.length){return}return this.text.charAt(this.index+nth)};Lexer.prototype.consume=function(){var current=this.peek();this.index+=1;return current};Lexer.prototype.readNumber=function(){var number="";if(this.peek()==="."){number+=this.consume();if(!isDigit(this.peek())){this.throwError("number expected")}}else{while(isDigit(this.peek())){number+=this.consume()}if(this.peek()==="."){number+=this.consume()}}while(isDigit(this.peek())){number+=this.consume()}if(this.peek()==="e"||this.peek()==="E"){number+=this.consume();if(!(isDigit(this.peek())||this.peek()==="+"||this.peek()==="-")){this.throwError()}if(this.peek()==="+"||this.peek()==="-"){number+=this.consume()}if(!isDigit(this.peek())){this.throwError("number expected")}while(isDigit(this.peek())){number+=this.consume()}}return number};Lexer.prototype.readIdentifier=function(){var text="";while(isIdentifier(this.peek())||isDigit(this.peek())){text+=this.consume()}return text};Lexer.prototype.readString=function(){var quote=this.consume();var string="";var escape;while(true){var c=this.consume();if(!c){this.throwError("string is not closed")}if(escape){if(c==="u"){var hex=this.text.substring(this.index+1,this.index+5);if(!hex.match(/[\da-f]{4}/i)){this.throwError("invalid unicode escape")}this.index+=4;string+=String.fromCharCode(parseInt(hex,16))}else{var replacement=ESCAPES[c];if(replacement){string+=replacement}else{string+=c}}escape=false}else if(c===quote){break}else if(c==="\\"){escape=true}else{string+=c}}return string};module.exports=Lexer},{"./token-type":82}],70:[function(require,module,exports){var tokenType=require("./token-type");var Lexer=require("./Lexer");var ConstantNode=require("./node/ConstantNode");var OperatorNode=require("./node/OperatorNode");var UnaryNode=require("./node/UnaryNode");var SymbolNode=require("./node/SymbolNode");var FunctionNode=require("./node/FunctionNode");var ArrayNode=require("./node/ArrayNode");var ConditionalNode=require("./node/ConditionalNode");var AssignmentNode=require("./node/AssignmentNode");var BlockNode=require("./node/BlockNode");function Parser(){this.lexer=new Lexer;this.tokens=null}Parser.prototype.current=function(){return this.tokens[0]};Parser.prototype.next=function(){return this.tokens[1]};Parser.prototype.peek=function(){if(this.tokens.length){var first=this.tokens[0];for(var i=0;i=","<=",">","<")){var op=this.consume();var right=this.shift();return new OperatorNode(op.value,[left,right])}return left};Parser.prototype.shift=function(){var left=this.additive();if(this.peek(">>","<<",">>>")){var op=this.consume();var right=this.shift();return new OperatorNode(op.value,[left,right])}return left};Parser.prototype.additive=function(){var left=this.multiplicative();while(this.peek("+","-")){var op=this.consume();left=new OperatorNode(op.value,[left,this.multiplicative()])}return left};Parser.prototype.multiplicative=function(){var op,right;var left=this.unary();while(this.peek("*","/","%")){op=this.consume();left=new OperatorNode(op.value,[left,this.unary()])}if(this.current().type===tokenType.SYMBOL||this.peek("(")||!(left.type instanceof ConstantNode)&&this.current().type===tokenType.NUMBER){right=this.multiplicative();return new OperatorNode("*",[left,right])}return left};Parser.prototype.unary=function(){if(this.peek("-","+","~")){var op=this.consume();var right=this.unary();return new UnaryNode(op.value,right)}return this.pow()};Parser.prototype.pow=function(){var left=this.factorial();if(this.peek("^","**")){var op=this.consume();var right=this.unary();return new OperatorNode(op.value,[left,right])}return left};Parser.prototype.factorial=function(){var left=this.symbol();if(this.peek("!")){var op=this.consume();return new OperatorNode(op.value,[left])}return left};Parser.prototype.symbol=function(){var current=this.current();if(current.type===tokenType.SYMBOL){var symbol=this.consume();var node=this.functionCall(symbol);return node}return this.string()};Parser.prototype.functionCall=function(symbolToken){var name=symbolToken.value;if(this.peek("(")){this.consume();var params=[];while(!this.peek(")")&&!this.isEOF()){params.push(this.assignment());if(this.peek(",")){this.consume()}}this.expect(")");return new FunctionNode(name,params)}return new SymbolNode(name)};Parser.prototype.string=function(){if(this.current().type===tokenType.STRING){return new ConstantNode(this.consume().value,"string")}return this.array()};Parser.prototype.array=function(){if(this.peek("[")){this.consume();var params=[];while(!this.peek("]")&&!this.isEOF()){params.push(this.assignment());if(this.peek(",")){this.consume()}}this.expect("]");return new ArrayNode(params)}return this.number()};Parser.prototype.number=function(){var token=this.current();if(token.type===tokenType.NUMBER){return new ConstantNode(this.consume().value,"number")}return this.parentheses()};Parser.prototype.parentheses=function(){var token=this.current();if(token.value==="("){this.consume();var left=this.assignment();this.expect(")");return left}return this.end()};Parser.prototype.end=function(){var token=this.current();if(token.type!==tokenType.EOF){throw Error("unexpected end of expression")}};module.exports=Parser},{"./Lexer":69,"./node/ArrayNode":71,"./node/AssignmentNode":72,"./node/BlockNode":73,"./node/ConditionalNode":74,"./node/ConstantNode":75,"./node/FunctionNode":76,"./node/OperatorNode":78,"./node/SymbolNode":79,"./node/UnaryNode":80,"./token-type":82}],71:[function(require,module,exports){var Node=require("./Node");function ArrayNode(nodes){this.nodes=nodes}ArrayNode.prototype=Object.create(Node.prototype);ArrayNode.prototype.type="ArrayNode";module.exports=ArrayNode},{"./Node":77}],72:[function(require,module,exports){var Node=require("./Node");function AssignmentNode(name,expr){this.name=name;this.expr=expr}AssignmentNode.prototype=Object.create(Node.prototype);AssignmentNode.prototype.type="AssignmentNode";module.exports=AssignmentNode},{"./Node":77}],73:[function(require,module,exports){var Node=require("./Node");function BlockNode(blocks){this.blocks=blocks}BlockNode.prototype=Object.create(Node.prototype);BlockNode.prototype.type="BlockNode";module.exports=BlockNode},{"./Node":77}],74:[function(require,module,exports){var Node=require("./Node");function ConditionalNode(predicate,truthy,falsy){this.condition=predicate;this.trueExpr=truthy;this.falseExpr=falsy}ConditionalNode.prototype=Object.create(Node.prototype);ConditionalNode.prototype.type="ConditionalNode";module.exports=ConditionalNode},{"./Node":77}],75:[function(require,module,exports){var Node=require("./Node");var SUPPORTED_TYPES={number:true,string:true,"boolean":true,undefined:true,"null":true};function ConstantNode(value,type){if(!SUPPORTED_TYPES[type]){throw Error("unsupported type '"+type+"'")}this.value=value;this.valueType=type}ConstantNode.prototype=Object.create(Node.prototype);ConstantNode.prototype.type="ConstantNode";module.exports=ConstantNode},{"./Node":77}],76:[function(require,module,exports){var Node=require("./Node");function FunctionNode(name,args){this.name=name;this.args=args}FunctionNode.prototype=Object.create(Node.prototype);FunctionNode.prototype.type="FunctionNode";module.exports=FunctionNode},{"./Node":77}],77:[function(require,module,exports){function Node(){}Node.prototype.type="Node";module.exports=Node},{}],78:[function(require,module,exports){var Node=require("./Node");function OperatorNode(op,args){this.op=op;this.args=args||[]}OperatorNode.prototype=Object.create(Node.prototype);OperatorNode.prototype.type="OperatorNode";module.exports=OperatorNode},{"./Node":77}],79:[function(require,module,exports){var Node=require("./Node");function SymbolNode(name){this.name=name}SymbolNode.prototype=Object.create(Node.prototype);SymbolNode.prototype.type="SymbolNode";module.exports=SymbolNode},{"./Node":77}],80:[function(require,module,exports){var Node=require("./Node");function UnaryNode(op,argument){this.op=op;this.argument=argument}UnaryNode.prototype=Object.create(Node.prototype);UnaryNode.prototype.type="UnaryNode";module.exports=UnaryNode},{"./Node":77}],81:[function(require,module,exports){module.exports={ArrayNode:require("./ArrayNode"),AssignmentNode:require("./AssignmentNode"),BlockNode:require("./BlockNode"),ConditionalNode:require("./ConditionalNode"),ConstantNode:require("./ConstantNode"),FunctionNode:require("./FunctionNode"),Node:require("./Node"),OperatorNode:require("./OperatorNode"),SymbolNode:require("./SymbolNode"),UnaryNode:require("./UnaryNode")}},{"./ArrayNode":71,"./AssignmentNode":72,"./BlockNode":73,"./ConditionalNode":74,"./ConstantNode":75,"./FunctionNode":76,"./Node":77,"./OperatorNode":78,"./SymbolNode":79,"./UnaryNode":80}],82:[function(require,module,exports){module.exports={EOF:0,DELIMITER:1,NUMBER:2,STRING:3,SYMBOL:4}},{}],83:[function(require,module,exports){"use strict";var doubleBits=require("double-bits");var SMALLEST_DENORM=Math.pow(2,-1074);var UINT_MAX=-1>>>0;module.exports=nextafter;function nextafter(x,y){if(isNaN(x)||isNaN(y)){return NaN}if(x===y){return x}if(x===0){if(y<0){return-SMALLEST_DENORM}else{return SMALLEST_DENORM}}var hi=doubleBits.hi(x);var lo=doubleBits.lo(x);if(y>x===x>0){if(lo===UINT_MAX){hi+=1;lo=0}else{lo+=1}}else{if(lo===0){lo=UINT_MAX;hi-=1}else{lo-=1}}return doubleBits.pack(lo,hi)}},{"double-bits":27}],84:[function(require,module,exports){var ua=typeof window!=="undefined"?window.navigator.userAgent:"",isOSX=/OS X/.test(ua),isOpera=/Opera/.test(ua),maybeFirefox=!/like Gecko/.test(ua)&&!isOpera;var i,output=module.exports={0:isOSX?"":"",1:"",2:"",3:"",4:"",5:"",6:"",8:"",9:"",12:"",13:"",16:"",17:"",18:"",19:"",20:"",21:"",23:"",24:"",25:"",27:"",28:"",29:"",30:"",31:"",27:"",32:"",33:"",34:"",35:"",36:"",37:"",38:"",39:"",40:"",41:"",42:"",43:"",44:"",45:"",46:"",47:"",91:"",92:"",93:isOSX?"":"",95:"",106:"",107:"",108:"",109:"",110:"",111:"",144:"",145:"",160:"",161:"",162:"",163:"",164:"",165:"",166:"",167:"",168:"",169:"",170:"",171:"",172:"",173:isOSX&&maybeFirefox?"-":"",174:"",175:"",176:"",177:"",178:"",179:"",180:"",181:"",182:"",183:"",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",223:"",224:"",226:"",229:"",231:isOpera?"`":"",246:"",247:"",248:"",249:"",250:"",251:"",252:"",253:"",254:""};for(i=58;i<65;++i){output[i]=String.fromCharCode(i)}for(i=48;i<58;++i){output[i]=i-48+""}for(i=65;i<91;++i){output[i]=String.fromCharCode(i)}for(i=96;i<106;++i){output[i]=""}for(i=112;i<136;++i){output[i]="F"+(i-111)}},{}],91:[function(require,module,exports){module.exports=extend;var hasOwnProperty=Object.prototype.hasOwnProperty;function extend(target){for(var i=1;i