mathjs
Version:
Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser and offers an integrated solution to work with numbers, big numbers, complex numbers, units, and matrices.
28 lines • 219 kB
JavaScript
/**
* math.js
* https://github.com/josdejong/mathjs
*
* Math.js is an extensive math library for JavaScript and Node.js,
* It features real and complex numbers, units, matrices, a large set of
* mathematical functions, and a flexible expression parser.
*
* @version 1.0.1
* @date 2014-09-12
*
* @license
* Copyright (C) 2013-2014 Jos de Jong <wjosdejong@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):"object"==typeof exports?exports.math=r():e.math=r()}(this,function(){return function(e){function r(t){if(n[t])return n[t].exports;var i=n[t]={exports:{},id:t,loaded:!1};return e[t].call(i.exports,i,i.exports,r),i.loaded=!0,i.exports}var n={};return r.m=e,r.c=n,r.p="",r(0)}([function(e,r,n){e.exports=n(1)},function(e,r,n){"use strict";function t(e){if("function"!=typeof Object.create)throw new Error("ES5 not supported by this JavaScript engine. Please load the es5-shim and es5-sham library for compatibility.");var r={},a={matrix:"matrix",number:"number",precision:64,epsilon:1e-14};r.config=function(e){if(e){if(i.deepExtend(a,e),e.precision&&r.type.BigNumber.config({precision:e.precision}),n(2)(r,a),e.number&&e.number.defaultType)throw new Error("setting `number.defaultType` is deprecated. Use `number` instead.");if(e.number&&e.number.precision)throw new Error("setting `number.precision` is deprecated. Use `precision` instead.");if(e.matrix&&e.matrix.defaultType)throw new Error("setting `matrix.defaultType` is deprecated. Use `matrix` instead.");if(e.matrix&&e.matrix["default"])throw new Error("setting `matrix.default` is deprecated. Use `matrix` instead.");if(e.decimals)throw new Error("setting `decimals` is deprecated. Use `precision` instead.")}return i.clone(a)},r.create=t;var s=n(139).constructor();if("function"!=typeof s.prototype.clone&&(s.prototype.clone=function(){return new s(this)}),"function"==typeof s.convert)throw new Error("Cannot add function convert to BigNumber: function already exists");return s.convert=function(e){return o(e)>15?e:new s(e)},r.error=n(5),r.type={},r.type.Complex=n(6),r.type.Range=n(7),r.type.Index=n(8),r.type.Matrix=n(9),r.type.Unit=n(10),r.type.Help=n(11),r.type.ResultSet=n(12),r.type.BigNumber=s,r.collection=n(13),r.expression={},r.expression.node=n(16),r.expression.parse=n(14),r.expression.Parser=n(15),r.expression.docs=n(17),n(29)(r,a),n(30)(r,a),n(31)(r,a),n(32)(r,a),n(33)(r,a),n(34)(r,a),n(35)(r,a),n(36)(r,a),n(37)(r,a),n(38)(r,a),n(39)(r,a),n(40)(r,a),n(41)(r,a),n(42)(r,a),n(43)(r,a),n(44)(r,a),n(45)(r,a),n(46)(r,a),n(47)(r,a),n(48)(r,a),n(49)(r,a),n(50)(r,a),n(51)(r,a),n(52)(r,a),n(53)(r,a),n(54)(r,a),n(55)(r,a),n(56)(r,a),n(57)(r,a),n(58)(r,a),n(59)(r,a),n(60)(r,a),n(61)(r,a),n(62)(r,a),n(63)(r,a),n(64)(r,a),n(65)(r,a),n(66)(r,a),n(67)(r,a),n(68)(r,a),n(69)(r,a),n(70)(r,a),n(71)(r,a),n(72)(r,a),n(73)(r,a),n(74)(r,a),n(75)(r,a),n(76)(r,a),n(77)(r,a),n(78)(r,a),n(79)(r,a),n(80)(r,a),n(81)(r,a),n(82)(r,a),n(83)(r,a),n(84)(r,a),n(85)(r,a),n(86)(r,a),n(87)(r,a),n(88)(r,a),n(89)(r,a),n(90)(r,a),n(91)(r,a),n(92)(r,a),n(93)(r,a),n(94)(r,a),n(95)(r,a),n(96)(r,a),n(97)(r,a),n(98)(r,a),n(99)(r,a),n(100)(r,a),n(101)(r,a),n(102)(r,a),n(103)(r,a),n(104)(r,a),n(105)(r,a),n(106)(r,a),n(107)(r,a),n(108)(r,a),n(109)(r,a),n(110)(r,a),n(111)(r,a),n(112)(r,a),n(113)(r,a),n(114)(r,a),n(115)(r,a),n(116)(r,a),n(117)(r,a),n(118)(r,a),n(119)(r,a),n(120)(r,a),n(121)(r,a),n(122)(r,a),n(123)(r,a),n(124)(r,a),n(125)(r,a),n(126)(r,a),n(127)(r,a),n(128)(r,a),n(129)(r,a),n(130)(r,a),n(131)(r,a),n(132)(r,a),n(133)(r,a),n(134)(r,a),n(135)(r,a),r.ifElse=function(){throw new Error("Function ifElse is deprecated. Use the conditional operator instead.")},n(2)(r,a),n(18)(r,a),n(19)(r,a),n(20)(r,a),n(21)(r,a),n(22)(r,a),n(23)(r,a),n(24)(r,a),n(25)(r,a),n(26)(r,a),n(27)(r,a),r.chaining={},r.chaining.Selector=n(28)(r,a),r.config(a),r.config(e),r}var i=n(3),o=n(4).digits,a=t();"undefined"!=typeof window&&(window.mathjs=a),e.exports=a},function(e,r,n){"use strict";e.exports=function(e,r){function t(){return new f(1).exp()}function i(){return new f(1).plus(new f(5).sqrt()).div(2)}function o(e){for(var r=e,n=0/0,t=e.times(e),i=e,o=-1,a=3;!r.equals(n);a+=2)i=i.times(t),n=r,r=o>0?r.plus(i.div(a)):r.minus(i.div(a)),o=-o;return r}function a(){var e=f.constructor({precision:f.precision+4}),r=new e(4).times(o(new e(1).div(5))).minus(o(new e(1).div(239)));return new f(4).times(r)}function s(){f.config({precision:r.precision+2});var e=a();return f.config({precision:r.precision}),new f(2).times(e)}var u=(n(136),n(6)),f=e.type.BigNumber,c="bignumber"===r.number;e.pi=c?a():Math.PI,e.tau=c?s():2*Math.PI,e.e=c?t():Math.E,e.phi=c?i():1.618033988749895,e.i=new u(0,1),e.Infinity=1/0,e.NaN=0/0,e["true"]=!0,e["false"]=!1,e["null"]=null,e.uninitialized=n(137).UNINITIALIZED,e.E=e.e,e.LN2=c?new f(2).ln():Math.LN2,e.LN10=c?new f(10).ln():Math.LN10,e.LOG2E=c?new f(1).div(new f(2).ln()):Math.LOG2E,e.LOG10E=c?new f(1).div(new f(10).ln()):Math.LOG10E,e.PI=e.pi,e.SQRT1_2=c?new f(.5).sqrt():Math.SQRT1_2,e.SQRT2=c?new f(2).sqrt():Math.SQRT2,e.version=n(138)}},function(e,r){"use strict";r.clone=function n(e){var r=typeof e;if("number"===r||"string"===r||"boolean"===r||null===e||void 0===e)return e;if("function"==typeof e.clone)return e.clone();if(Array.isArray(e))return e.map(function(e){return n(e)});if(e instanceof Number)return new Number(e.valueOf());if(e instanceof String)return new String(e.valueOf());if(e instanceof Boolean)return new Boolean(e.valueOf());if(e instanceof Date)return new Date(e.valueOf());if(e instanceof RegExp)throw new TypeError("Cannot clone "+e);var t={};for(var i in e)e.hasOwnProperty(i)&&(t[i]=n(e[i]));return t},r.extend=function(e,r){for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n]);return e},r.deepExtend=function t(e,r){if(Array.isArray(r))throw new TypeError("Arrays are not supported by deepExtend");for(var n in r)if(r.hasOwnProperty(n))if(r[n]&&r[n].constructor===Object)void 0===e[n]&&(e[n]={}),e[n].constructor===Object?t(e[n],r[n]):e[n]=r[n];else{if(Array.isArray(r[n]))throw new TypeError("Arrays are not supported by deepExtend");e[n]=r[n]}return e},r.deepEqual=function(e,n){var t,i,o;if(Array.isArray(e)){if(!Array.isArray(n))return!1;if(e.length!=n.length)return!1;for(i=0,o=e.length;o>i;i++)if(!r.deepEqual(e[i],n[i]))return!1;return!0}if(e instanceof Object){if(Array.isArray(n)||!(n instanceof Object))return!1;for(t in e)if(!r.deepEqual(e[t],n[t]))return!1;for(t in n)if(!r.deepEqual(e[t],n[t]))return!1;return!0}return typeof e==typeof n&&e==n}},function(e,r){"use strict";r.isNumber=function(e){return e instanceof Number||"number"==typeof e},r.isInteger=function(e){return e==Math.round(e)},r.sign=function(e){return e>0?1:0>e?-1:0},r.format=function(e,n){if("function"==typeof n)return n(e);if(1/0===e)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var t="auto",i=void 0;switch(n&&(n.notation&&(t=n.notation),r.isNumber(n)?i=n:n.precision&&(i=n.precision)),t){case"fixed":return r.toFixed(e,i);case"exponential":return r.toExponential(e,i);case"auto":var o=.001,a=1e5;if(n&&n.exponential&&(void 0!==n.exponential.lower&&(o=n.exponential.lower),void 0!==n.exponential.upper&&(a=n.exponential.upper)),0===e)return"0";var s,u=Math.abs(e);if(u>=o&&a>u){var f=i?e.toPrecision(Math.min(i,21)):e.toPrecision();s=parseFloat(f)+""}else s=r.toExponential(e,i);return s.replace(/((\.\d*?)(0+))($|e)/,function(){var e=arguments[2],r=arguments[4];return"."!==e?e+r:r});default:throw new Error('Unknown notation "'+t+'". Choose "auto", "exponential", or "fixed".')}},r.toExponential=function(e,r){return void 0!==r?e.toExponential(Math.min(r-1,20)):e.toExponential()},r.toFixed=function(e,r){return e.toFixed(Math.min(r,20))},r.digits=function(e){return e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length},r.DBL_EPSILON=Number.EPSILON||2.220446049250313e-16,r.nearlyEqual=function(e,n,t){if(null==t)return e==n;if(e==n)return!0;if(isNaN(e)||isNaN(n))return!1;if(isFinite(e)&&isFinite(n)){var i=Math.abs(e-n);return i<r.DBL_EPSILON?!0:i<=Math.max(Math.abs(e),Math.abs(n))*t}return!1}},function(e,r,n){"use strict";r.ArgumentsError=n(140),r.DimensionError=n(141),r.IndexError=n(142),r.UnsupportedTypeError=n(143)},function(e,r,n){"use strict";function t(e,r){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");switch(arguments.length){case 0:this.re=0,this.im=0;break;case 1:var n=arguments[0];if("object"==typeof n){if("re"in n&&"im"in n){var i=new t(n.re,n.im);this.re=i.re,this.im=i.im;break}if("r"in n&&"phi"in n){var i=t.fromPolar(n.r,n.phi);this.re=i.re,this.im=i.im;break}}throw new SyntaxError("Object with the re and im or r and phi properties expected.");case 2:if(!h(e)||!h(r))throw new TypeError("Two numbers expected in Complex constructor");this.re=e,this.im=r;break;default:throw new SyntaxError("One, two or three arguments expected in Complex constructor")}}function i(){for(;" "==w||" "==w;)s()}function o(e){return e>="0"&&"9">=e||"."==e}function a(e){return e>="0"&&"9">=e}function s(){y++,w=x.charAt(y)}function u(e){y=e,w=x.charAt(y)}function f(){var e,r="";if(e=y,"+"==w?s():"-"==w&&(r+=w,s()),!o(w))return u(e),null;if("."==w){if(r+=w,s(),!a(w))return u(e),null}else{for(;a(w);)r+=w,s();"."==w&&(r+=w,s())}for(;a(w);)r+=w,s();if("E"==w||"e"==w){if(r+=w,s(),("+"==w||"-"==w)&&(r+=w,s()),!a(w))return u(e),null;for(;a(w);)r+=w,s()}return r}function c(){var e=x.charAt(y+1);if("I"==w||"i"==w)return s(),"1";if(!("+"!=w&&"-"!=w||"I"!=e&&"i"!=e)){var r="+"==w?"1":"-1";return s(),s(),r}return null}var l=n(144),p=n(10),m=l.number,h=l.number.isNumber,g=p.isUnit,d=l.string.isString;t.isComplex=function(e){return e instanceof t};var x,y,w;t.parse=function(e){if(x=e,y=-1,w="",!d(x))return null;s(),i();var r=f();if(r){if("I"==w||"i"==w)return s(),i(),w?null:new t(0,Number(r));i();var n=w;if("+"!=n&&"-"!=n)return i(),w?null:new t(Number(r),0);s(),i();var o=f();if(o){if("I"!=w&&"i"!=w)return null;s()}else if(o=c(),!o)return null;return"-"==n&&(o="-"==o[0]?"+"+o.substring(1):"-"+o),s(),i(),w?null:new t(Number(r),Number(o))}return(r=c())?(i(),w?null:new t(0,Number(r))):null},t.fromPolar=function(){switch(arguments.length){case 1:var e=arguments[0];if("object"==typeof e)return t.fromPolar(e.r,e.phi);throw new TypeError("Input has to be an object with r and phi keys.");case 2:var r=arguments[0],n=arguments[1];if(h(r)){if(g(n)&&n.hasBase(p.BASE_UNITS.ANGLE)&&(n=n.toNumber("rad")),h(n))return new t(r*Math.cos(n),r*Math.sin(n));throw new TypeError("Phi is not a number nor an angle unit.")}throw new TypeError("Radius r is not a number.");default:throw new SyntaxError("Wrong number of arguments in function fromPolar")}},t.prototype.toPolar=function(){return{r:Math.sqrt(this.re*this.re+this.im*this.im),phi:Math.atan2(this.im,this.re)}},t.prototype.clone=function(){return new t(this.re,this.im)},t.prototype.equals=function(e){return this.re===e.re&&this.im===e.im},t.prototype.format=function(e){var r="",n=m.format(this.re,e),t=m.format(this.im,e);return r=0==this.im?n:0==this.re?1==this.im?"i":-1==this.im?"-i":t+"i":this.im>0?1==this.im?n+" + i":n+" + "+t+"i":-1==this.im?n+" - i":n+" - "+t.substring(1)+"i"},t.prototype.toString=function(){return this.format()},t.prototype.valueOf=t.prototype.toString,e.exports=t},function(e,r,n){"use strict";function t(e,r,n){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(null!=e&&!o.isNumber(e))throw new TypeError("Parameter start must be a number");if(null!=r&&!o.isNumber(r))throw new TypeError("Parameter end must be a number");if(null!=n&&!o.isNumber(n))throw new TypeError("Parameter step must be a number");this.start=null!=e?parseFloat(e):0,this.end=null!=r?parseFloat(r):0,this.step=null!=n?parseFloat(n):1}{var i=n(144),o=i.number,a=i.string;i.array}t.parse=function(e){if(!a.isString(e))return null;var r=e.split(":"),n=r.map(function(e){return parseFloat(e)}),i=n.some(function(e){return isNaN(e)});if(i)return null;switch(n.length){case 2:return new t(n[0],n[1]);case 3:return new t(n[0],n[2],n[1]);default:return null}},t.prototype.clone=function(){return new t(this.start,this.end,this.step)},t.isRange=function(e){return e instanceof t},t.prototype.size=function(){var e=0,r=this.start,n=this.step,t=this.end,i=t-r;return o.sign(n)==o.sign(i)?e=Math.ceil(i/n):0==i&&(e=0),isNaN(e)&&(e=0),[e]},t.prototype.min=function(){var e=this.size()[0];return e>0?this.step>0?this.start:this.start+(e-1)*this.step:void 0},t.prototype.max=function(){var e=this.size()[0];return e>0?this.step>0?this.start+(e-1)*this.step:this.start:void 0},t.prototype.forEach=function(e){var r=this.start,n=this.step,t=this.end,i=0;if(n>0)for(;t>r;)e(r,i,this),r+=n,i++;else if(0>n)for(;r>t;)e(r,i,this),r+=n,i++},t.prototype.map=function(e){var r=[];return this.forEach(function(n,t,i){r[t]=e(n,t,i)}),r},t.prototype.toArray=function(){var e=[];return this.forEach(function(r,n){e[n]=r}),e},t.prototype.valueOf=function(){return this.toArray()},t.prototype.format=function(e){var r=o.format(this.start,e);return 1!=this.step&&(r+=":"+o.format(this.step,e)),r+=":"+o.format(this.end,e)},t.prototype.toString=function(){return this.format()},e.exports=t},function(e,r,n){"use strict";function t(){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");this._ranges=[],this._isScalar=!0;for(var e=0,r=arguments.length;r>e;e++){var n=arguments[e];if(n instanceof a)this._ranges.push(n),this._isScalar=!1;else if(c(n))this._ranges.push(i(n)),this._isScalar=!1;else if(u(n))this._ranges.push(i([n,n+1]));else{var o=n.valueOf();if(!c(o))throw new TypeError("Ranges must be an Array, Number, or Range");this._ranges.push(i(o)),this._isScalar=!1}}}function i(e){for(var r=e.length,n=0;r>n;n++)if(!u(e[n])||!f(e[n]))throw new TypeError("Index parameters must be integer numbers");switch(e.length){case 2:return new a(e[0],e[1]);case 3:return new a(e[0],e[1],e[2]);default:throw new SyntaxError("Wrong number of arguments in Index (2 or 3 expected)")}}var o=n(144),a=n(7),s=o.number,u=s.isNumber,f=s.isInteger,c=Array.isArray;t.prototype.clone=function(){var e=new t;return e._ranges=o.object.clone(this._ranges),e._isScalar=this._isScalar,e},t.isIndex=function(e){return e instanceof t},t.create=function(e){var r=new t;return t.apply(r,e),r},t.prototype.size=function(){for(var e=[],r=0,n=this._ranges.length;n>r;r++){var t=this._ranges[r];e[r]=t.size()[0]}return e},t.prototype.max=function(){for(var e=[],r=0,n=this._ranges.length;n>r;r++){var t=this._ranges[r];e[r]=t.max()}return e},t.prototype.min=function(){for(var e=[],r=0,n=this._ranges.length;n>r;r++){var t=this._ranges[r];e[r]=t.min()}return e},t.prototype.forEach=function(e){for(var r=0,n=this._ranges.length;n>r;r++)e(this._ranges[r],r,this)},t.prototype.range=function(e){return this._ranges[e]||null},t.prototype.isScalar=function(){return this._isScalar},t.prototype.toArray=function(){for(var e=[],r=0,n=this._ranges.length;n>r;r++){var t=this._ranges[r],i=[],o=t.start,a=t.end,s=t.step;if(s>0)for(;a>o;)i.push(o),o+=s;else if(0>s)for(;o>a;)i.push(o),o+=s;e.push(i)}return e},t.prototype.valueOf=t.prototype.toArray,t.prototype.toString=function(){for(var e=[],r=0,n=this._ranges.length;n>r;r++){var t=this._ranges[r],i=s.format(t.start);1!=t.step&&(i+=":"+s.format(t.step)),i+=":"+s.format(t.end),e.push(i)}return"["+e.join(", ")+"]"},e.exports=t},function(e,r,n){"use strict";function t(e){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(e instanceof t)this._data=e.clone()._data;else if(d(e))this._data=f(e);else{if(null!=e)throw new TypeError("Unsupported type of data ("+c.types.type(e)+")");this._data=[]}this._size=h.size(this._data)}function i(e,r){if(!(r instanceof p))throw new TypeError("Invalid index");var n=r.isScalar();if(n)return e.get(r.min());var i=r.size();if(i.length!=e._size.length)throw new l(i.length,e._size.length);for(var a=r.min(),s=r.max(),u=0,f=e._size.length;f>u;u++)x(a[u],e._size[u]),x(s[u],e._size[u]);return new t(o(e._data,r,i.length,0))}function o(e,r,n,t){var i=t==n-1,a=r.range(t);return a.map(i?function(r){return e[r]}:function(i){var a=e[i];return o(a,r,n,t+1)})}function a(e,r,n,i){if(!(r instanceof p))throw new TypeError("Invalid index");var o,a=r.size(),f=r.isScalar();if(n instanceof t?(o=n.size(),n=n.valueOf()):o=h.size(n),f){if(0!=o.length)throw new TypeError("Scalar expected");e.set(r.min(),n,i)}else{if(a.length<e._size.length)throw new l(a.length,e._size.length,"<");if(o.length<a.length){for(var c=0,m=0;1===a[c]&&1===o[c];)c++;for(;1===a[c];)m++,c++;n=h.unsqueeze(n,a.length,m,o)}if(!g.deepEqual(a,o))throw new l(a,o,">");var d=r.max().map(function(e){return e+1});u(e,d,i);var x=a.length,y=0;s(e._data,r,n,x,y)}return e}function s(e,r,n,t,i){var o=i==t-1,a=r.range(i);a.forEach(o?function(r,t){x(r),e[r]=n[t]}:function(o,a){x(o),s(e[o],r,n[a],t,i+1)})}function u(e,r,n){for(var t=g.clone(e._size),i=!1;t.length<r.length;)t.push(0),i=!0;for(var o=0,a=r.length;a>o;o++)r[o]>t[o]&&(t[o]=r[o],i=!0);i&&e.resize(t,n)}function f(e){for(var r=0,n=e.length;n>r;r++){var i=e[r];d(i)?e[r]=f(i):i instanceof t&&(e[r]=f(i._data))}return e}var c=n(144),l=n(141),p=n(8),m=(c.number,c.string),h=c.array,g=c.object,d=Array.isArray,x=h.validateIndex;t.isMatrix=function(e){return e instanceof t},t.prototype.subset=function(e,r,n){switch(arguments.length){case 1:return i(this,e);case 2:case 3:return a(this,e,r,n);default:throw new SyntaxError("Wrong number of arguments")}},t.prototype.get=function(e){if(!d(e))throw new TypeError("Array expected");if(e.length!=this._size.length)throw new l(e.length,this._size.length);for(var r=this._data,n=0,t=e.length;t>n;n++){var i=e[n];x(i,r.length),r=r[i]}return g.clone(r)},t.prototype.set=function(e,r,n){var t,i;if(!d(e))throw new Error("Array expected");if(e.length<this._size.length)throw new l(e.length,this._size.length,"<");var o=e.map(function(e){return e+1});u(this,o,n);var a=this._data;for(t=0,i=e.length-1;i>t;t++){var s=e[t];x(s,a.length),a=a[s]}return s=e[e.length-1],x(s,a.length),a[s]=r,this},t.prototype.resize=function(e,r){return this._size=g.clone(e),this._data=h.resize(this._data,this._size,r),this},t.prototype.clone=function(){var e=new t;return e._data=g.clone(this._data),e._size=g.clone(this._size),e},t.prototype.size=function(){return this._size},t.prototype.map=function(e){var r=this,n=new t,i=[],o=function(n,t){return d(n)?n.map(function(e,r){return i[t]=r,o(e,t+1)}):e(n,i,r)};return n._data=o(this._data,0),n._size=g.clone(this._size),n},t.prototype.forEach=function(e){var r=this,n=[],t=function(i,o){d(i)?i.forEach(function(e,r){n[o]=r,t(e,o+1)}):e(i,n,r)};t(this._data,0)},t.prototype.toArray=function(){return g.clone(this._data)},t.prototype.valueOf=function(){return this._data},t.prototype.format=function(e){return m.format(this._data,e)},t.prototype.toString=function(){return m.format(this._data)},e.exports=t},function(e,r,n){"use strict";function t(e,r){if(!(this instanceof t))throw new Error("Constructor must be called with the new operator");if(void 0!=e&&!y(e))throw new TypeError("First parameter in Unit constructor must be a number");if(void 0!=r&&(!w(r)||""==r))throw new TypeError("Second parameter in Unit constructor must be a string");if(void 0!=r){var n=l(r);if(!n)throw new SyntaxError('Unknown unit "'+r+'"');this.unit=n.unit,this.prefix=n.prefix}else this.unit=M,this.prefix=b;this.value=void 0!=e?this._normalize(e):null,this.fixPrefix=!1}function i(){for(;" "==h||" "==h;)s()}function o(e){return e>="0"&&"9">=e||"."==e}function a(e){return e>="0"&&"9">=e}function s(){m++,h=p.charAt(m)}function u(e){m=e,h=p.charAt(m)}function f(){var e,r="";if(e=m,"+"==h?s():"-"==h&&(r+=h,s()),!o(h))return u(e),null;if("."==h){if(r+=h,s(),!a(h))return u(e),null}else{for(;a(h);)r+=h,s();"."==h&&(r+=h,s())}for(;a(h);)r+=h,s();if("E"==h||"e"==h){if(r+=h,s(),("+"==h||"-"==h)&&(r+=h,s()),!a(h))return u(e),null;for(;a(h);)r+=h,s()}return r}function c(){var e="";for(i();h&&" "!=h&&" "!=h;)e+=h,s();return e||null}function l(e){for(var r in T)if(T.hasOwnProperty(r)&&x.endsWith(e,r)){var n=T[r],t=e.length-r.length,i=e.substring(0,t),o=n.prefixes[i];if(void 0!==o)return{unit:n,prefix:o}}return null}var p,m,h,g=n(144),d=g.number,x=g.string,y=g.number.isNumber,w=g.string.isString;t.parse=function(e){if(p=e,m=-1,h="",!w(p))return null;s(),i();var r,n=f();if(n){if(r=c(),s(),i(),h)return null;if(n&&r)try{return new t(Number(n),r)}catch(o){}}else{if(r=c(),s(),i(),h)return null;if(r)try{return new t(null,r)}catch(o){}}return null},t.isUnit=function(e){return e instanceof t},t.prototype.clone=function(){var e=new t;for(var r in this)this.hasOwnProperty(r)&&(e[r]=this[r]);return e},t.prototype._normalize=function(e){return(e+this.unit.offset)*this.unit.value*this.prefix.value},t.prototype._unnormalize=function(e,r){return void 0==r?e/this.unit.value/this.prefix.value-this.unit.offset:e/this.unit.value/r-this.unit.offset},t.isValuelessUnit=function(e){return null!=l(e)},t.prototype.hasBase=function(e){return this.unit.base===e},t.prototype.equalBase=function(e){return this.unit.base===e.unit.base},t.prototype.equals=function(e){return this.equalBase(e)&&this.value==e.value},t.prototype.to=function(e){var r;if(w(e)){if(r=new t(null,e),!this.equalBase(r))throw new Error("Units do not match");return r.value=this.value,r.fixPrefix=!0,r}if(e instanceof t){if(!this.equalBase(e))throw new Error("Units do not match");if(null!==e.value)throw new Error("Cannot convert to a unit with a value");return r=e.clone(),r.value=this.value,r.fixPrefix=!0,r}throw new Error("String or Unit expected as parameter")},t.prototype.toNumber=function(e){var r=this.to(e);return r._unnormalize(r.value,r.prefix.value)},t.prototype.toString=function(){return this.format()},t.prototype.valueOf=t.prototype.toString,t.prototype.format=function(e){var r,n;if(null===this.value||this.fixPrefix)r=this._unnormalize(this.value),n=null!==this.value?d.format(r,e)+" ":"",n+=this.prefix.name+this.unit.name;else{var t=this._bestPrefix();r=this._unnormalize(this.value,t.value),n=d.format(r,e)+" ",n+=t.name+this.unit.name}return n},t.prototype._bestPrefix=function(){var e=Math.abs(this.value/this.unit.value),r=b,n=Math.abs(Math.log(e/r.value)/Math.LN10-1.2),t=this.unit.prefixes;for(var i in t)if(t.hasOwnProperty(i)){var o=t[i];if(o.scientific){var a=Math.abs(Math.log(e/o.value)/Math.LN10-1.2);n>a&&(r=o,n=a)}}return r};var v={NONE:{"":{name:"",value:1,scientific:!0}},SHORT:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:10,scientific:!1},h:{name:"h",value:100,scientific:!1},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0},d:{name:"d",value:.1,scientific:!1},c:{name:"c",value:.01,scientific:!1},m:{name:"m",value:.001,scientific:!0},u:{name:"u",value:1e-6,scientific:!0},n:{name:"n",value:1e-9,scientific:!0},p:{name:"p",value:1e-12,scientific:!0},f:{name:"f",value:1e-15,scientific:!0},a:{name:"a",value:1e-18,scientific:!0},z:{name:"z",value:1e-21,scientific:!0},y:{name:"y",value:1e-24,scientific:!0}},LONG:{"":{name:"",value:1,scientific:!0},deca:{name:"deca",value:10,scientific:!1},hecto:{name:"hecto",value:100,scientific:!1},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0},deci:{name:"deci",value:.1,scientific:!1},centi:{name:"centi",value:.01,scientific:!1},milli:{name:"milli",value:.001,scientific:!0},micro:{name:"micro",value:1e-6,scientific:!0},nano:{name:"nano",value:1e-9,scientific:!0},pico:{name:"pico",value:1e-12,scientific:!0},femto:{name:"femto",value:1e-15,scientific:!0},atto:{name:"atto",value:1e-18,scientific:!0},zepto:{name:"zepto",value:1e-21,scientific:!0},yocto:{name:"yocto",value:1e-24,scientific:!0}},SQUARED:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:100,scientific:!1},h:{name:"h",value:1e4,scientific:!1},k:{name:"k",value:1e6,scientific:!0},M:{name:"M",value:1e12,scientific:!0},G:{name:"G",value:1e18,scientific:!0},T:{name:"T",value:1e24,scientific:!0},P:{name:"P",value:1e30,scientific:!0},E:{name:"E",value:1e36,scientific:!0},Z:{name:"Z",value:1e42,scientific:!0},Y:{name:"Y",value:1e48,scientific:!0},d:{name:"d",value:.01,scientific:!1},c:{name:"c",value:1e-4,scientific:!1},m:{name:"m",value:1e-6,scientific:!0},u:{name:"u",value:1e-12,scientific:!0},n:{name:"n",value:1e-18,scientific:!0},p:{name:"p",value:1e-24,scientific:!0},f:{name:"f",value:1e-30,scientific:!0},a:{name:"a",value:1e-36,scientific:!0},z:{name:"z",value:1e-42,scientific:!0},y:{name:"y",value:1e-42,scientific:!0}},CUBIC:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:1e3,scientific:!1},h:{name:"h",value:1e6,scientific:!1},k:{name:"k",value:1e9,scientific:!0},M:{name:"M",value:1e18,scientific:!0},G:{name:"G",value:1e27,scientific:!0},T:{name:"T",value:1e36,scientific:!0},P:{name:"P",value:1e45,scientific:!0},E:{name:"E",value:1e54,scientific:!0},Z:{name:"Z",value:1e63,scientific:!0},Y:{name:"Y",value:1e72,scientific:!0},d:{name:"d",value:.001,scientific:!1},c:{name:"c",value:1e-6,scientific:!1},m:{name:"m",value:1e-9,scientific:!0},u:{name:"u",value:1e-18,scientific:!0},n:{name:"n",value:1e-27,scientific:!0},p:{name:"p",value:1e-36,scientific:!0},f:{name:"f",value:1e-45,scientific:!0},a:{name:"a",value:1e-54,scientific:!0},z:{name:"z",value:1e-63,scientific:!0},y:{name:"y",value:1e-72,scientific:!0}},BINARY_SHORT:{"":{name:"",value:1,scientific:!0},k:{name:"k",value:1024,scientific:!0},M:{name:"M",value:Math.pow(1024,2),scientific:!0},G:{name:"G",value:Math.pow(1024,3),scientific:!0},T:{name:"T",value:Math.pow(1024,4),scientific:!0},P:{name:"P",value:Math.pow(1024,5),scientific:!0},E:{name:"E",value:Math.pow(1024,6),scientific:!0},Z:{name:"Z",value:Math.pow(1024,7),scientific:!0},Y:{name:"Y",value:Math.pow(1024,8),scientific:!0},Ki:{name:"Ki",value:1024,scientific:!0},Mi:{name:"Mi",value:Math.pow(1024,2),scientific:!0},Gi:{name:"Gi",value:Math.pow(1024,3),scientific:!0},Ti:{name:"Ti",value:Math.pow(1024,4),scientific:!0},Pi:{name:"Pi",value:Math.pow(1024,5),scientific:!0},Ei:{name:"Ei",value:Math.pow(1024,6),scientific:!0},Zi:{name:"Zi",value:Math.pow(1024,7),scientific:!0},Yi:{name:"Yi",value:Math.pow(1024,8),scientific:!0}},BINARY_LONG:{"":{name:"",value:1,scientific:!0},kilo:{name:"kilo",value:1024,scientific:!0},mega:{name:"mega",value:Math.pow(1024,2),scientific:!0},giga:{name:"giga",value:Math.pow(1024,3),scientific:!0},tera:{name:"tera",value:Math.pow(1024,4),scientific:!0},peta:{name:"peta",value:Math.pow(1024,5),scientific:!0},exa:{name:"exa",value:Math.pow(1024,6),scientific:!0},zetta:{name:"zetta",value:Math.pow(1024,7),scientific:!0},yotta:{name:"yotta",value:Math.pow(1024,8),scientific:!0},kibi:{name:"kibi",value:1024,scientific:!0},mebi:{name:"mebi",value:Math.pow(1024,2),scientific:!0},gibi:{name:"gibi",value:Math.pow(1024,3),scientific:!0},tebi:{name:"tebi",value:Math.pow(1024,4),scientific:!0},pebi:{name:"pebi",value:Math.pow(1024,5),scientific:!0},exi:{name:"exi",value:Math.pow(1024,6),scientific:!0},zebi:{name:"zebi",value:Math.pow(1024,7),scientific:!0},yobi:{name:"yobi",value:Math.pow(1024,8),scientific:!0}}},b={name:"",value:1,scientific:!0},E={NONE:{},LENGTH:{},MASS:{},TIME:{},CURRENT:{},TEMPERATURE:{},LUMINOUS_INTENSITY:{},AMOUNT_OF_SUBSTANCE:{},FORCE:{},SURFACE:{},VOLUME:{},ANGLE:{},BIT:{}},N={},M={name:"",base:N,value:1,offset:0},T={meter:{name:"meter",base:E.LENGTH,prefixes:v.LONG,value:1,offset:0},inch:{name:"inch",base:E.LENGTH,prefixes:v.NONE,value:.0254,offset:0},foot:{name:"foot",base:E.LENGTH,prefixes:v.NONE,value:.3048,offset:0},yard:{name:"yard",base:E.LENGTH,prefixes:v.NONE,value:.9144,offset:0},mile:{name:"mile",base:E.LENGTH,prefixes:v.NONE,value:1609.344,offset:0},link:{name:"link",base:E.LENGTH,prefixes:v.NONE,value:.201168,offset:0},rod:{name:"rod",base:E.LENGTH,prefixes:v.NONE,value:5.02921,offset:0},chain:{name:"chain",base:E.LENGTH,prefixes:v.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:E.LENGTH,prefixes:v.NONE,value:1e-10,offset:0},m:{name:"m",base:E.LENGTH,prefixes:v.SHORT,value:1,offset:0},"in":{name:"in",base:E.LENGTH,prefixes:v.NONE,value:.0254,offset:0},ft:{name:"ft",base:E.LENGTH,prefixes:v.NONE,value:.3048,offset:0},yd:{name:"yd",base:E.LENGTH,prefixes:v.NONE,value:.9144,offset:0},mi:{name:"mi",base:E.LENGTH,prefixes:v.NONE,value:1609.344,offset:0},li:{name:"li",base:E.LENGTH,prefixes:v.NONE,value:.201168,offset:0},rd:{name:"rd",base:E.LENGTH,prefixes:v.NONE,value:5.02921,offset:0},ch:{name:"ch",base:E.LENGTH,prefixes:v.NONE,value:20.1168,offset:0},mil:{name:"mil",base:E.LENGTH,prefixes:v.NONE,value:254e-7,offset:0},m2:{name:"m2",base:E.SURFACE,prefixes:v.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:E.SURFACE,prefixes:v.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:E.SURFACE,prefixes:v.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:E.SURFACE,prefixes:v.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:E.SURFACE,prefixes:v.NONE,value:2589988.110336,offset:0},sqrd:{name:"sqrd",base:E.SURFACE,prefixes:v.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:E.SURFACE,prefixes:v.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:E.SURFACE,prefixes:v.NONE,value:6.4516e-10,offset:0},m3:{name:"m3",base:E.VOLUME,prefixes:v.CUBIC,value:1,offset:0},L:{name:"L",base:E.VOLUME,prefixes:v.SHORT,value:.001,offset:0},l:{name:"l",base:E.VOLUME,prefixes:v.SHORT,value:.001,offset:0},litre:{name:"litre",base:E.VOLUME,prefixes:v.LONG,value:.001,offset:0},cuin:{name:"cuin",base:E.VOLUME,prefixes:v.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:E.VOLUME,prefixes:v.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:E.VOLUME,prefixes:v.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:E.VOLUME,prefixes:v.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:E.VOLUME,prefixes:v.NONE,value:15e-6,offset:0},drop:{name:"drop",base:E.VOLUME,prefixes:v.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:E.VOLUME,prefixes:v.NONE,value:5e-8,offset:0},minim:{name:"minim",base:E.VOLUME,prefixes:v.NONE,value:6.161152e-8,offset:0},fluiddram:{name:"fluiddram",base:E.VOLUME,prefixes:v.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:E.VOLUME,prefixes:v.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:E.VOLUME,prefixes:v.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:E.VOLUME,prefixes:v.NONE,value:1e-6,offset:0},cup:{name:"cup",base:E.VOLUME,prefixes:v.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:E.VOLUME,prefixes:v.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:E.VOLUME,prefixes:v.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:E.VOLUME,prefixes:v.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:E.VOLUME,prefixes:v.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:E.VOLUME,prefixes:v.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:E.VOLUME,prefixes:v.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:E.VOLUME,prefixes:v.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:E.VOLUME,prefixes:v.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:E.VOLUME,prefixes:v.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:E.VOLUME,prefixes:v.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:E.VOLUME,prefixes:v.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:E.VOLUME,prefixes:v.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:E.VOLUME,prefixes:v.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:E.VOLUME,prefixes:v.NONE,value:.1173478,offset:0},obl:{name:"obl",base:E.VOLUME,prefixes:v.NONE,value:.1589873,offset:0},g:{name:"g",base:E.MASS,prefixes:v.SHORT,value:.001,offset:0},gram:{name:"gram",base:E.MASS,prefixes:v.LONG,value:.001,offset:0},ton:{name:"ton",base:E.MASS,prefixes:v.SHORT,value:907.18474,offset:0},tonne:{name:"tonne",base:E.MASS,prefixes:v.SHORT,value:1e3,offset:0},grain:{name:"grain",base:E.MASS,prefixes:v.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:E.MASS,prefixes:v.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:E.MASS,prefixes:v.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:E.MASS,prefixes:v.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:E.MASS,prefixes:v.NONE,value:45.359237,offset:0},stick:{name:"stick",base:E.MASS,prefixes:v.NONE,value:.115,offset:0},gr:{name:"gr",base:E.MASS,prefixes:v.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:E.MASS,prefixes:v.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:E.MASS,prefixes:v.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:E.MASS,prefixes:v.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:E.MASS,prefixes:v.NONE,value:45.359237,offset:0},s:{name:"s",base:E.TIME,prefixes:v.SHORT,value:1,offset:0},min:{name:"min",base:E.TIME,prefixes:v.NONE,value:60,offset:0},h:{name:"h",base:E.TIME,prefixes:v.NONE,value:3600,offset:0},second:{name:"second",base:E.TIME,prefixes:v.LONG,value:1,offset:0},sec:{name:"sec",base:E.TIME,prefixes:v.LONG,value:1,offset:0},minute:{name:"minute",base:E.TIME,prefixes:v.NONE,value:60,offset:0},hour:{name:"hour",base:E.TIME,prefixes:v.NONE,value:3600,offset:0},day:{name:"day",base:E.TIME,prefixes:v.NONE,value:86400,offset:0},rad:{name:"rad",base:E.ANGLE,prefixes:v.NONE,value:1,offset:0},deg:{name:"deg",base:E.ANGLE,prefixes:v.NONE,value:.017453292519943295,offset:0},grad:{name:"grad",base:E.ANGLE,prefixes:v.NONE,value:.015707963267948967,offset:0},cycle:{name:"cycle",base:E.ANGLE,prefixes:v.NONE,value:6.283185307179586,offset:0},A:{name:"A",base:E.CURRENT,prefixes:v.SHORT,value:1,offset:0},ampere:{name:"ampere",base:E.CURRENT,prefixes:v.LONG,value:1,offset:0},K:{name:"K",base:E.TEMPERATURE,prefixes:v.NONE,value:1,offset:0},degC:{name:"degC",base:E.TEMPERATURE,prefixes:v.NONE,value:1,offset:273.15},degF:{name:"degF",base:E.TEMPERATURE,prefixes:v.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:E.TEMPERATURE,prefixes:v.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:E.TEMPERATURE,prefixes:v.NONE,value:1,offset:0},celsius:{name:"celsius",base:E.TEMPERATURE,prefixes:v.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:E.TEMPERATURE,prefixes:v.NONE,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:E.TEMPERATURE,prefixes:v.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:E.AMOUNT_OF_SUBSTANCE,prefixes:v.NONE,value:1,offset:0},mole:{name:"mole",base:E.AMOUNT_OF_SUBSTANCE,prefixes:v.NONE,value:1,offset:0},cd:{name:"cd",base:E.LUMINOUS_INTENSITY,prefixes:v.NONE,value:1,offset:0},candela:{name:"candela",base:E.LUMINOUS_INTENSITY,prefixes:v.NONE,value:1,offset:0},N:{name:"N",base:E.FORCE,prefixes:v.SHORT,value:1,offset:0},newton:{name:"newton",base:E.FORCE,prefixes:v.LONG,value:1,offset:0},lbf:{name:"lbf",base:E.FORCE,prefixes:v.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:E.FORCE,prefixes:v.NONE,value:4.4482216152605,offset:0},b:{name:"b",base:E.BIT,prefixes:v.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:E.BIT,prefixes:v.BINARY_LONG,value:1,offset:0},B:{name:"B",base:E.BIT,prefixes:v.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:E.BIT,prefixes:v.BINARY_LONG,value:8,offset:0}},A={meters:"meter",inches:"inch",feet:"foot",yards:"yard",miles:"mile",links:"link",rods:"rod",chains:"chain",angstroms:"angstrom",litres:"litre",teaspoons:"teaspoon",tablespoons:"tablespoon",minims:"minim",fluiddrams:"fluiddram",fluidounces:"fluidounce",gills:"gill",cups:"cup",pints:"pint",quarts:"quart",gallons:"gallon",beerbarrels:"beerbarrel",oilbarrels:"oilbarrel",hogsheads:"hogshead",gtts:"gtt",grams:"gram",tons:"ton",tonnes:"tonne",grains:"grain",drams:"dram",ounces:"ounce",poundmasses:"poundmass",hundredweights:"hundredweight",sticks:"stick",seconds:"second",minutes:"minute",hours:"hour",days:"day",radians:"rad",degrees:"deg",gradients:"grad",cycles:"cycle",amperes:"ampere",moles:"mole"};
for(var S in A)if(A.hasOwnProperty(S)){var O=T[A[S]],C=Object.create(O);C.name=S,T[S]=C}T.lt=T.l,T.liter=T.litre,T.liters=T.litres,T.lb=T.lbm,T.lbs=T.lbm,t.PREFIXES=v,t.BASE_UNITS=E,t.UNITS=T,e.exports=t},function(e,r,n){"use strict";function t(e,r){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");this.math=e,this.doc=r}var i=n(144),o=i.object,a=i.string;t.isHelp=function(e){return e instanceof t},t.prototype.toString=function(){var e=this.doc||{},r="\n";if(e.name&&(r+="Name: "+e.name+"\n\n"),e.category&&(r+="Category: "+e.category+"\n\n"),e.description&&(r+="Description:\n "+e.description+"\n\n"),e.syntax&&(r+="Syntax:\n "+e.syntax.join("\n ")+"\n\n"),e.examples){var n=this.math.parser();r+="Examples:\n";for(var i=0;i<e.examples.length;i++){var o,s=e.examples[i];try{o=n.eval(s)}catch(u){o=u}r+=" "+s+"\n",!o||o instanceof t||(r+=" "+a.format(o,{precision:14})+"\n")}r+="\n"}return e.seealso&&(r+="See also: "+e.seealso.join(", ")+"\n"),r},t.prototype.toJSON=function(){return o.clone(this.doc)},t.prototype.valueOf=t.prototype.toString,e.exports=t},function(e){"use strict";function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this.entries=e||[]}r.prototype.valueOf=function(){return this.entries},r.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},e.exports=r},function(e,r,n){"use strict";function t(e,r,n){var o,a,s,u;if(0>=r){if(c(e[0])){for(u=i(e),a=[],o=0;o<u.length;o++)a[o]=t(u[o],r-1,n);return a}for(s=e[0],o=1;o<e.length;o++)s=n(s,e[o]);return s}for(a=[],o=0;o<e.length;o++)a[o]=t(e[o],r-1,n);return a}function i(e){var r,n,t=e.length,i=e[0].length,o=[];for(n=0;i>n;n++){var a=[];for(r=0;t>r;r++)a.push(e[r][n]);o.push(a)}return o}{var o=n(144),a=n(142),s=n(141),u=n(9),f=o.array,c=o.array.isArray;o.string.isString}r.argsToArray=function(e){if(0==e.length)return[];if(1==e.length){var r=e[0];return r instanceof u&&(r=r.valueOf()),c(r)||(r=[r]),r}return o.array.argsToArray(e)},r.isCollection=function(e){return c(e)||e instanceof u},r.deepMap=function l(e,r){return e&&"function"==typeof e.map?e.map(function(e){return l(e,r)}):r(e)},r.deepMap2=function p(e,r,n){var t,i,o;if(c(e))if(c(r)){if(e.length!=r.length)throw new s(e.length,r.length);for(t=[],i=e.length,o=0;i>o;o++)t[o]=p(e[o],r[o],n)}else{if(r instanceof u)return t=p(e,r.valueOf(),n),new u(t);for(t=[],i=e.length,o=0;i>o;o++)t[o]=p(e[o],r,n)}else{if(e instanceof u)return r instanceof u?(t=p(e.valueOf(),r.valueOf(),n),new u(t)):(t=p(e.valueOf(),r,n),new u(t));if(c(r))for(t=[],i=r.length,o=0;i>o;o++)t[o]=p(e,r[o],n);else{if(r instanceof u)return t=p(e,r.valueOf(),n),new u(t);t=n(e,r)}}return t},r.reduce=function(e,r,n){var i=c(e)?f.size(e):e.size();if(0>r)throw new a(r);if(r>=i.length)throw new a(r,i.length);return e instanceof u?new u(t(e.valueOf(),r,n)):t(e,r,n)},r.deepForEach=function m(e,r){e instanceof u&&(e=e.valueOf());for(var n=0,t=e.length;t>n;n++){var i=e[n];c(i)?m(i,r):r(i)}}},function(e,r,n){"use strict";function t(e,r){if(1!=arguments.length&&2!=arguments.length)throw new F("parse",arguments.length,1,2);if(sr=r&&r.nodes?r.nodes:{},D(e))return ur=e,h();if(G(e)||e instanceof V)return H.deepMap(e,function(e){if(!D(e))throw new TypeError("String expected");return ur=e,h()});throw new TypeError("String or matrix expected")}function i(){fr=0,cr=ur.charAt(0),mr=0,hr=null}function o(){fr++,cr=ur.charAt(fr)}function a(){return ur.charAt(fr+1)}function s(){for(pr=ir.NULL,lr="";" "==cr||" "==cr||"\n"==cr&&mr;)o();if("#"==cr)for(;"\n"!=cr&&""!=cr;)o();if(""==cr)return void(pr=ir.DELIMITER);if("\n"==cr&&!mr)return pr=ir.DELIMITER,lr=cr,void o();var e=cr+a();if(2==e.length&&or[e])return pr=ir.DELIMITER,lr=e,o(),void o();if(or[cr])return pr=ir.DELIMITER,lr=cr,void o();if(!p(cr)){if(l(cr)){for(;l(cr)||m(cr);)lr+=cr,o();return void(pr=ar[lr]?ir.DELIMITER:ir.SYMBOL)}for(pr=ir.UNKNOWN;""!=cr;)lr+=cr,o();throw P('Syntax error in part "'+lr+'"')}if(pr=ir.NUMBER,"."==cr)lr+=cr,o(),m(cr)||(pr=ir.UNKNOWN);else{for(;m(cr);)lr+=cr,o();"."==cr&&(lr+=cr,o())}for(;m(cr);)lr+=cr,o();if("E"==cr||"e"==cr)for(lr+=cr,o(),("+"==cr||"-"==cr)&&(lr+=cr,o()),m(cr)||(pr=ir.UNKNOWN);m(cr);)lr+=cr,o()}function u(){do s();while("\n"==lr)}function f(){mr++}function c(){mr--}function l(e){return e>="a"&&"z">=e||e>="A"&&"Z">=e||"_"==e}function p(e){return e>="0"&&"9">=e||"."==e}function m(e){return e>="0"&&"9">=e}function h(){i(),s();var e=g();if(""!=lr)throw pr==ir.DELIMITER?k("Unexpected operator "+lr):P('Unexpected part "'+lr+'"');return e}function g(){var e,r,n;if(""==lr)return new K("undefined","undefined");for("\n"!=lr&&";"!=lr&&(e=d());"\n"==lr||";"==lr;)r||(r=new W,e&&(n=";"!=lr,r.add(e,n))),s(),"\n"!=lr&&";"!=lr&&""!=lr&&(e=d(),n=";"!=lr,r.add(e,n));return r?r:e}function d(){if(pr==ir.SYMBOL&&"function"==lr)throw P('Deprecated keyword "function". Functions can now be assigned without it, like "f(x) = x^2".');return x()}function x(){var e,r,n,t,i=y();if("="==lr){if(i instanceof nr)return e=i.name,u(),n=x(),new Z(e,n);if(i instanceof J)return u(),n=x(),new tr(i,n);if(i instanceof er&&(t=!0,r=[],e=i.symbol.name,i.params.forEach(function(e,n){e instanceof nr?r[n]=e.name:t=!1}),t))return u(),n=x(),new $(e,r,n);throw P("Invalid left hand side of assignment operator =")}return i}function y(){for(var e=w();"?"==lr;){var r=hr;hr=mr,u();var n=e,t=w();if(":"!=lr)throw P("False part of conditional expression expected");hr=null,u();var i=y();e=new Q(n,t,i),hr=r}return e}function w(){var e,r,n,t,i;for(e=v(),r={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};lr in r;)n=lr,t=r[n],u(),i=[e,v()],e=new X(n,t,i);return e}function v(){var e,r,n,t,i;for(e=b(),r={to:"to","in":"to"};lr in r;)n=lr,t=r[n],u(),i=[e,b()],e=new X(n,t,i);return e}function b(){var e,r=[];if(e=":"==lr?new K("1","number"):E(),":"==lr&&hr!==mr){for(r.push(e);":"==lr;)u(),r.push(")"==lr||"]"==lr||","==lr||""==lr?new nr("end"):E());if(3==r.length){var n=r[2];r[2]=r[1],r[1]=n}e=new rr(r)}return e}function E(){var e,r,n,t,i;for(e=N(),r={"+":"add","-":"subtract"};lr in r;)n=lr,t=r[n],u(),i=[e,N()],e=new X(n,t,i);return e}function N(){var e,r,n,t,i;if(e=M(),r={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide","%":"mod",mod:"mod"},lr in r)for(;lr in r;)n=lr,t=r[n],u(),i=[e,M()],e=new X(n,t,i);return(pr==ir.SYMBOL||"in"==lr&&e instanceof K||pr==ir.NUMBER&&!(e instanceof K)||"("==lr||"["==lr)&&(e=new X("*","multiply",[e,N()])),e}function M(){var e,r,n;return"-"==lr||"+"==lr?(e=lr,r="+"==e?"unaryPlus":"unaryMinus",u(),n=[M()],new X(e,r,n)):T()}function T(){var e,r,n,t;return e=A(),("^"==lr||".^"==lr)&&(r=lr,n="^"==r?"pow":"dotPow",u(),t=[e,M()],e=new X(r,n,t)),e}function A(){var e,r,n,t,i;for(e=S(),r={"!":"factorial","'":"transpose"};lr in r;)n=lr,t=r[n],s(),i=[e],e=new X(n,t,i);return e}function S(){var e,r=[];if(pr==ir.SYMBOL&&sr[lr]){if(e=sr[lr],s(),"("==lr){if(r=[],f(),s(),")"!=lr)for(r.push(y());","==lr;)s(),r.push(y());if(")"!=lr)throw P("Parenthesis ) expected");c(),s()}return new e(r)}return O()}function O(){var e,r;return pr==ir.SYMBOL||pr==ir.DELIMITER&&lr in ar?(r=lr,s(),e=new nr(r),e=C(e),e=U(e)):q()}function C(e){var r;if("("==lr){if(r=[],f(),s(),")"!=lr)for(r.push(y());","==lr;)s(),r.push(y());if(")"!=lr)throw P("Parenthesis ) expected");return c(),s(),new er(e,r)}return e}function U(e){for(var r;"["==lr;){if(r=[],f(),s(),"]"!=lr)for(r.push(y());","==lr;)s(),r.push(y());if("]"!=lr)throw P("Parenthesis ] expected");c(),s(),e=new J(e,r)}return e}function q(){var e,r,n;if('"'==lr){for(r="",n="";""!=cr&&('"'!=cr||"\\"==n);)r+=cr,n=cr,o();if(s(),'"'!=lr)throw P('End of string " expected');return s(),e=new K(r,"string"),e=U(e)}return B()}function B(){var e,r,n,t;if("["==lr){if(f(),s(),"]"!=lr){var i=z();if(";"==lr){for(n=1,r=[i];";"==lr;)s(),r[n]=z(),n++;if("]"!=lr)throw P("End of matrix ] expected");c(),s(),t=r[0].nodes.length;for(var o=1;n>o;o++)if(r[o].nodes.length!=t)throw k("Column dimensions mismatch ("+r[o].nodes.length+" != "+t+")");e=new Y(r)}else{if("]"!=lr)throw P("End of matrix ] expected");c(),s(),e=i}}else c(),s(),e=new Y([]);return e}return I()}function z(){for(var e=[x()],r=1;","==lr;)s(),e[r]=x(),r++;return new Y(e)}function I(){var e;return pr==ir.NUMBER?(e=lr,s(),new K(e,"number")):_()}function _(){var e;if("("==lr){if(f(),s(),e=x(),")"!=lr)throw P("Parenthesis ) expected");return c(),s(),e}return R()}function R(){throw P(""==lr?"Unexpected end of expression":"Value expected")}function L(){return fr-lr.length+1}function P(e){var r=L(),n=new SyntaxError(e+" (char "+r+")");return n["char"]=r,n}function k(e){var r=L(),n=new Error(e+" (char "+r+")");return n["char"]=r,n}var j=n(144),F=n(140),D=j.string.isString,G=Array.isArray,V=(j.types.type,n(6),n(9)),H=(n(10),n(13)),Y=n(145),Z=n(146),W=n(147),Q=n(148),K=n(149),$=n(150),J=n(151),X=n(152),er=n(153),rr=n(154),nr=n(155),tr=n(156),ir={NULL:0,DELIMITER:1,NUMBER:2,SYMBOL:3,UNKNOWN:4},or={",":!0,"(":!0,")":!0,"[":!0,"]":!0,'"':!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"!":!0,"'":!0,"=":!0,":":!0,"?":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0},ar={mod:!0,to:!0,"in":!0},sr={},ur="",fr=0,cr="",lr="",pr=ir.NULL,mr=0,hr=null;e.exports=t},function(e,r,n){"use strict";function t(e){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");if(!(e instanceof Object))throw new TypeError("Object expected as parameter math");this.math=e,this.scope={}}var i=n(14);t.prototype.parse=function(){throw new Error("Parser.parse is deprecated. Use math.parse instead.")},t.prototype.compile=function(){throw new Error("Parser.compile is deprecated. Use math.compile instead.")},t.prototype.eval=function(e){return i(e).compile(this.math).eval(this.scope)},t.prototype.get=function(e){return this.scope[e]},t.prototype.set=function(e,r){return this.scope[e]=r},t.prototype.remove=function(e){delete this.scope[e]},t.prototype.clear=function(){for(var e in this.scope)this.scope.hasOwnProperty(e)&&delete this.scope[e]},e.exports=t},function(e,r,n){"use strict";r.ArrayNode=n(145),r.AssignmentNode=n(146),r.BlockNode=n(147),r.ConditionalNode=n(148),r.ConstantNode=n(149),r.IndexNode=n(151),r.FunctionAssignmentNode=n(150),r.FunctionNode=n(153),r.Node=n(157),r.OperatorNode=n(152),r.RangeNode=n(154),r.SymbolNode=n(155),r.UpdateNode=n(156)},function(e,r,n){r.e=n(161),r.E=n(161),r["false"]=n(162),r.i=n(163),r.Infinity=n(164),r.LN2=n(165),r.LN10=n(166),r.LOG2E=n(167),r.LOG10E=n(168),r.NaN=n(169),r["null"]=n(170),r.pi=n(171),r.PI=n(171),r.phi=n(172),r.SQRT1_2=n(173),r.SQRT2=n(174),r.tau=n(175),r["true"]=n(176),r.version=n(177),r.abs=n(181),r.add=n(182),r.ceil=n(183),r.cube=n(184),r.divide=n(185),r.dotDivide=n(186),r.dotMultiply=n(187),r.dotPow=n(188),r.exp=n(189),r.fix=n(190),r.floor=n(191),r.gcd=n(192),r.lcm=n(193),r.log=n(194),r.log10=n(195),r.mod=n(196),r.multiply=n(197),r.norm=n(198),r.pow=n(199),r.round=n(200),r.sign=n(201),r.sqrt=n(202),r.square=n(203),r.subtract=n(204),r.unaryMinus=n(205),r.unaryPlus=n(206),r.xgcd=n(207),r.compare=n(208),r.deepEqual=n(209),r.equal=n(210),r.larger=n(211),r.largerEq=n(212),r.smaller=n(213),r.smallerEq=n(214),r.unequal=n(215),r.arg=n(216),r.conj=n(217),r.re=n(218),r.im=n(219),r.bignumber=n(220),r["boolean"]=n(221),r.complex=n(222),r.index=n(223),r.matrix=n(224),r.number=n(225),r.string=n(226),r.unit=n(227),r.eval=n(228),r.help=n(229),r.concat=n(230),r.det=n(231),r.diag=n(232),r.eye=n(233),r.flatten=n(234),r.inv=n(235),r.ones=n(236),r.range=n(237),r.resize=n(238),r.size=n(239),r.squeeze=n(240),r.subset=n(241),r.transpose=n(242),r.zeros=n(243),r.combinations=n(244),r.factorial=n(245),r.permutations=n(246),r.pickRandom=n(247),r.random=n(248),r.randomInt=n(249),r.max=n(250),r.mean=n(251),r.median=n(252),r.min=n(253),r.prod=n(254),r.std=n(255),r.sum=n(256),r["var"]=n(257),r.acos=n(258),r.asin=n(259),r.atan=n(260),r.atan2=n(261),r.cos=n(262),r.cosh=n(263),r.cot=n(264),r.coth=n(265),r.csc=n(266),r.csch=n(267),r.sec=n(268),r.sech=n(269),r.sin=n(270),r.sinh=n(271),r.tan=n(272),r.tanh=n(273),r.to=n(274),r.clone=n(275),r.map=n(276),r.filter=n(277),r.forEach=n(278),r.format=n(279),r["import"]=n(280),r.sort=n(281),r["typeof"]=n(282)},function(e,r,n){"use strict";var t=n(139),i=n(158).transform,o=n(4).isNumber,a=n(137).argsToArray;e.exports=function(e){e.concat.transform=function(){var r=a(arguments),n=r.length-1,s=r[n];o(s)?r[n]=s-1:s instanceof t&&(r[n]=s.minus(1));try{return e.concat.apply(e,r)}catch(u){throw i(u)}}}},function(e,r,n){"use strict";var t=n(155),i=(n(159).isBoolean,n(137).argsToArray,n(140));e.exports=function(e){var r=e.filter;r.transform=function(e,n,o){if(2!==e.length)throw new i("filter",arguments.length,2);var a,s=e[0].compile(n).eval(o);if(e[1]instanceof t)a=e[1].compile(n).eval(o);else{var u=o||{},f=e[1].find({type:t}).filter(function(e){return!(e.name in n||e.name in u)})[0],c=Object.create(u),l=e[1].compile(n);if(!f)throw new Error("No undefined variable fou