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 • 223 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 0.20.0
* @date 2014-04-16
*
* @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.mathjs=r():e.mathjs=r()}(this,function(){return function(e){function r(n){if(t[n])return t[n].exports;var i=t[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,r),i.loaded=!0,i.exports}var t={};return r.m=e,r.c=t,r.p="",r(0)}([function(e,r,t){e.exports=t(1)},function(e,r,t){function n(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={},n={matrix:"matrix",number:"number",precision:20,epsilon:1e-14};r.config=function(e){if(e){if(i.deepExtend(n,e),e.precision&&r.type.BigNumber.config({precision:e.precision}),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(n)};var o=t(112).constructor();if("function"!=typeof o.prototype.clone&&(o.prototype.clone=function(){return new o(this)}),"function"==typeof o.convert)throw new Error("Cannot add function convert to BigNumber: function already exists");return o.convert=function(e){return digits(e)>15?e:new o(e)},r.error=t(4),r.type={},r.type.Complex=t(5),r.type.Range=t(6),r.type.Index=t(7),r.type.Matrix=t(8),r.type.Unit=t(9),r.type.Help=t(10),r.type.BigNumber=o,r.collection=t(11),r.expression={},r.expression.node=t(14),r.expression.parse=t(12),r.expression.Scope=function(){throw new Error("Scope is deprecated. Use a regular Object instead")},r.expression.Parser=t(13),r.expression.docs=t(15),t(17)(r,n),t(18)(r,n),t(19)(r,n),t(20)(r,n),t(21)(r,n),t(22)(r,n),t(23)(r,n),t(24)(r,n),t(25)(r,n),t(26)(r,n),t(27)(r,n),t(28)(r,n),t(29)(r,n),t(30)(r,n),t(31)(r,n),t(32)(r,n),t(33)(r,n),t(34)(r,n),t(35)(r,n),t(36)(r,n),t(37)(r,n),t(38)(r,n),t(39)(r,n),t(40)(r,n),t(41)(r,n),t(42)(r,n),t(43)(r,n),t(44)(r,n),t(45)(r,n),t(46)(r,n),t(47)(r,n),t(48)(r,n),t(49)(r,n),t(50)(r,n),t(51)(r,n),t(52)(r,n),t(53)(r,n),t(54)(r,n),t(55)(r,n),t(56)(r,n),t(57)(r,n),t(58)(r,n),t(59)(r,n),t(60)(r,n),t(61)(r,n),t(62)(r,n),t(63)(r,n),t(64)(r,n),t(65)(r,n),t(66)(r,n),t(67)(r,n),t(68)(r,n),t(69)(r,n),t(70)(r,n),t(71)(r,n),t(72)(r,n),t(73)(r,n),t(74)(r,n),t(75)(r,n),t(76)(r,n),t(77)(r,n),t(78)(r,n),t(79)(r,n),t(80)(r,n),t(81)(r,n),t(82)(r,n),t(83)(r,n),t(84)(r,n),t(85)(r,n),t(86)(r,n),t(87)(r,n),t(88)(r,n),t(89)(r,n),t(90)(r,n),t(91)(r,n),t(92)(r,n),t(93)(r,n),t(94)(r,n),t(95)(r,n),t(96)(r,n),t(97)(r,n),t(98)(r,n),t(99)(r,n),t(100)(r,n),t(101)(r,n),t(102)(r,n),t(103)(r,n),t(104)(r,n),t(105)(r,n),t(106)(r,n),t(107)(r,n),t(108)(r,n),t(109)(r,n),t(110)(r,n),t(111)(r,n),t(2)(r,n),r.chaining={},r.chaining.Selector=t(16)(r,n),r.config(e),r}var i=t(3);e.exports=n},function(e,r,t){e.exports=function(e){var r=t(5);e.pi=Math.PI,e.e=Math.E,e.tau=2*Math.PI,e.i=new r(0,1),e.Infinity=1/0,e.NaN=0/0,e["true"]=!0,e["false"]=!1,e.E=Math.E,e.LN2=Math.LN2,e.LN10=Math.LN10,e.LOG2E=Math.LOG2E,e.LOG10E=Math.LOG10E,e.PI=Math.PI,e.SQRT1_2=Math.SQRT1_2,e.SQRT2=Math.SQRT2}},function(e,r){r.clone=function t(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 t(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 n={};for(var i in e)e.hasOwnProperty(i)&&(n[i]=t(e[i]));return n},r.extend=function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t]);return e},r.deepExtend=function n(e,r){if(Array.isArray(r))throw new TypeError("Arrays are not supported by deepExtend");for(var t in r)if(r.hasOwnProperty(t))if(r[t]&&r[t].constructor===Object)void 0===e[t]&&(e[t]={}),e[t].constructor===Object?n(e[t],r[t]):e[t]=r[t];else{if(Array.isArray(r[t]))throw new TypeError("Arrays are not supported by deepExtend");e[t]=r[t]}return e},r.deepEqual=function(e,t){var n,i,o;if(Array.isArray(e)){if(!Array.isArray(t))return!1;if(e.length!=t.length)return!1;for(i=0,o=e.length;o>i;i++)if(!r.deepEqual(e[i],t[i]))return!1;return!0}if(e instanceof Object){if(Array.isArray(t)||!(t instanceof Object))return!1;for(n in e)if(!r.deepEqual(e[n],t[n]))return!1;for(n in t)if(!r.deepEqual(e[n],t[n]))return!1;return!0}return typeof e==typeof t&&e==t}},function(e,r,t){r.ArgumentsError=t(113),r.DimensionError=t(114),r.IndexError=t(115),r.UnsupportedTypeError=t(116)},function(e,r,t){function n(e,r){if(!(this instanceof n))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 t=arguments[0];if("object"==typeof t){if("re"in t&&"im"in t){var i=new n(t.re,t.im);this.re=i.re,this.im=i.im;break}if("r"in t&&"phi"in t){var i=n.fromPolar(t.r,t.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(;" "==v||" "==v;)s()}function o(e){return e>="0"&&"9">=e||"."==e}function a(e){return e>="0"&&"9">=e}function s(){y++,v=w.charAt(y)}function u(e){y=e,v=w.charAt(y)}function f(){var e,r="";if(e=y,"+"==v?s():"-"==v&&(r+=v,s()),!o(v))return u(e),null;if("."==v){if(r+=v,s(),!a(v))return u(e),null}else{for(;a(v);)r+=v,s();"."==v&&(r+=v,s())}for(;a(v);)r+=v,s();if("E"==v||"e"==v){if(r+=v,s(),("+"==v||"-"==v)&&(r+=v,s()),!a(v))return u(e),null;for(;a(v);)r+=v,s()}return r}function c(){var e=w.charAt(y+1);if("I"==v||"i"==v)return s(),"1";if(!("+"!=v&&"-"!=v||"I"!=e&&"i"!=e)){var r="+"==v?"1":"-1";return s(),s(),r}return null}var l=t(117),p=t(9),m=l.number,h=l.number.isNumber,g=p.isUnit,d=l.string.isString;n.isComplex=function(e){return e instanceof n};var w,y,v;n.parse=function(e){if(w=e,y=-1,v="",!d(w))return null;s(),i();var r=f();if(r){if("I"==v||"i"==v)return s(),i(),v?null:new n(0,Number(r));i();var t=v;if("+"!=t&&"-"!=t)return i(),v?null:new n(Number(r),0);s(),i();var o=f();if(o){if("I"!=v&&"i"!=v)return null;s()}else if(o=c(),!o)return null;return"-"==t&&(o="-"==o[0]?"+"+o.substring(1):"-"+o),s(),i(),v?null:new n(Number(r),Number(o))}return(r=c())?(i(),v?null:new n(0,Number(r))):null},n.fromPolar=function(){switch(arguments.length){case 1:var e=arguments[0];if("object"==typeof e)return n.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],t=arguments[1];if(h(r)){if(g(t)&&t.hasBase(p.BASE_UNITS.ANGLE)&&(t=t.toNumber("rad")),h(t))return new n(r*Math.cos(t),r*Math.sin(t));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")}},n.prototype.toPolar=function(){return{r:Math.sqrt(this.re*this.re+this.im*this.im),phi:Math.atan2(this.im,this.re)}},n.prototype.clone=function(){return new n(this.re,this.im)},n.prototype.equals=function(e){return this.re===e.re&&this.im===e.im},n.prototype.format=function(e){var r="",t=m.format(this.re,e),n=m.format(this.im,e);return r=0==this.im?t:0==this.re?1==this.im?"i":-1==this.im?"-i":n+"i":this.im>0?1==this.im?t+" + i":t+" + "+n+"i":-1==this.im?t+" - i":t+" - "+n.substring(1)+"i"},n.prototype.toString=function(){return this.format()},e.exports=n},function(e,r,t){function n(e,r,t){if(!(this instanceof n))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!=t&&!o.isNumber(t))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!=t?parseFloat(t):1}{var i=t(117),o=i.number,a=i.string;i.array}n.parse=function(e){if(!a.isString(e))return null;var r=e.split(":"),t=r.map(function(e){return parseFloat(e)}),i=t.some(function(e){return isNaN(e)});if(i)return null;switch(t.length){case 2:return new n(t[0],t[1]);case 3:return new n(t[0],t[2],t[1]);default:return null}},n.prototype.clone=function(){return new n(this.start,this.end,this.step)},n.isRange=function(e){return e instanceof n},n.prototype.size=function(){var e=0,r=this.start,t=this.step,n=this.end,i=n-r;return o.sign(t)==o.sign(i)?e=Math.ceil(i/t):0==i&&(e=0),isNaN(e)&&(e=0),[e]},n.prototype.min=function(){var e=this.size()[0];return e>0?this.step>0?this.start:this.start+(e-1)*this.step:void 0},n.prototype.max=function(){var e=this.size()[0];return e>0?this.step>0?this.start+(e-1)*this.step:this.start:void 0},n.prototype.forEach=function(e){var r=this.start,t=this.step,n=this.end,i=0;if(t>0)for(;n>r;)e(r,i,this),r+=t,i++;else if(0>t)for(;r>n;)e(r,i,this),r+=t,i++},n.prototype.map=function(e){var r=[];return this.forEach(function(t,n,i){r[n]=e(t,n,i)}),r},n.prototype.toArray=function(){var e=[];return this.forEach(function(r,t){e[t]=r}),e},n.prototype.valueOf=function(){return this.toArray()},n.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)},n.prototype.toString=function(){return this.format()},e.exports=n},function(e,r,t){function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._ranges=[];for(var e=0,r=arguments.length;r>e;e++){var t=arguments[e];if(t instanceof a)this._ranges.push(t);else if(c(t))this._ranges.push(i(t));else{if(!u(t))throw new TypeError("Ranges must be an Array, Number, or Range");this._ranges.push(i([t,t+1]))}}}function i(e){for(var r=e.length,t=0;r>t;t++)if(!u(e[t])||!f(e[t]))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=t(117),a=t(6),s=o.number,u=s.isNumber,f=s.isInteger,c=Array.isArray;o.array.validateIndex}n.prototype.clone=function(){var e=new n;return e._ranges=o.object.clone(this._ranges),e},n.isIndex=function(e){return e instanceof n},n.create=function(e){var r=new n;return n.apply(r,e),r},n.prototype.size=function l(){for(var l=[],e=0,r=this._ranges.length;r>e;e++){var t=this._ranges[e];l[e]=t.size()[0]}return l},n.prototype.max=function(){for(var e=[],r=0,t=this._ranges.length;t>r;r++){var n=this._ranges[r];e[r]=n.max()}return e},n.prototype.min=function(){for(var e=[],r=0,t=this._ranges.length;t>r;r++){var n=this._ranges[r];e[r]=n.min()}return e},n.prototype.forEach=function(e){for(var r=0,t=this._ranges.length;t>r;r++)e(this._ranges[r],r,this)},n.prototype.range=function(e){return this._ranges[e]||null},n.prototype.isScalar=function(){for(var e=this.size(),r=0,t=e.length;t>r;r++)if(1!==e[r])return!1;return!0},n.prototype.toArray=function(){for(var e=[],r=0,t=this._ranges.length;t>r;r++){var n=this._ranges[r],i=[],o=n.start,a=n.end,s=n.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},n.prototype.valueOf=n.prototype.toArray,n.prototype.toString=function(){for(var e=[],r=0,t=this._ranges.length;t>r;r++){var n=this._ranges[r],i=s.format(n.start);1!=n.step&&(i+=":"+s.format(n.step)),i+=":"+s.format(n.end),e.push(i)}return"["+e.join(", ")+"]"},e.exports=n},function(e,r,t){function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(e instanceof n)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 t=r.isScalar();if(t)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=new n(o(e._data,r,i.length,0));d(a._data)&&1==a._data.length;)a._data=a._data[0],a._size.shift();return a}function o(e,r,t,n){var i=n==t-1,a=r.range(n);return a.map(i?function(r){return w(r,e.length),e[r]}:function(i){w(i,e.length);var a=e[i];return o(a,r,t,n+1)})}function a(e,r,t,i){if(!(r instanceof p))throw new TypeError("Invalid index");var o,a=r.size(),f=r.isScalar();if(t instanceof n?(o=t.size(),t=t.valueOf()):o=h.size(t),f){if(0!=o.length)throw new TypeError("Scalar expected");e.set(r.min(),t,i)}else{if(a.length<e._size.length)throw new l(a.length,e._size.length,"<");for(var c=0,m=a.length-o.length;m>c;c++)t=[t],o.unshift(1);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 w=a.length,y=0;s(e._data,r,t,w,y)}return e}function s(e,r,t,n,i){var o=i==n-1,a=r.range(i);a.forEach(o?function(r,n){w(r),e[r]=t[n]}:function(o,a){w(o),s(e[o],r,t[a],n,i+1)})}function u(e,r,t){for(var n=g.clone(e._size),i=!1;n.length<r.length;)n.unshift(0),i=!0;for(var o=0,a=r.length;a>o;o++)r[o]>n[o]&&(n[o]=r[o],i=!0);i&&e.resize(n,t)}function f(e){for(var r=0,t=e.length;t>r;r++){var i=e[r];d(i)?e[r]=f(i):i instanceof n&&(e[r]=f(i._data))}return e}var c=t(117),l=t(114),p=t(7),m=(c.number,c.string),h=c.array,g=c.object,d=Array.isArray,w=h.validateIndex;n.isMatrix=function(e){return e instanceof n},n.prototype.subset=function(e,r,t){switch(arguments.length){case 1:return i(this,e);case 2:case 3:return a(this,e,r,t);default:throw new SyntaxError("Wrong number of arguments")}},n.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,t=0,n=e.length;n>t;t++){var i=e[t];w(i,r.length),r=r[i]}return g.clone(r)},n.prototype.set=function(e,r,t){var n,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,t);var a=this._data;for(n=0,i=e.length-1;i>n;n++){var s=e[n];w(s,a.length),a=a[s]}return s=e[e.length-1],w(s,a.length),a[s]=r,this},n.prototype.resize=function(e,r){return this._size=g.clone(e),this._data=h.resize(this._data,this._size,r),this},n.prototype.clone=function(){var e=new n;return e._data=g.clone(this._data),e._size=g.clone(this._size),e},n.prototype.size=function(){return this._size},n.prototype.map=function(e){var r=this,t=new n,i=[],o=function(t,n){return d(t)?t.map(function(e,r){return i[n]=r,o(e,n+1)}):e(t,i,r)};return t._data=o(this._data,0),t._size=g.clone(this._size),t},n.prototype.forEach=function(e){var r=this,t=[],n=function(i,o){d(i)?i.forEach(function(e,r){t[o]=r,n(e,o+1)}):e(i,t,r)};n(this._data,0)},n.prototype.toArray=function(){return g.clone(this._data)},n.prototype.valueOf=function(){return this._data},n.prototype.format=function(e){return m.format(this._data,e)},n.prototype.toString=function(){return m.format(this._data)},e.exports=n},function(e,r,t){function n(e,r){if(!(this instanceof n))throw new Error("Constructor must be called with the new operator");if(null!=e&&!y(e))throw new TypeError("First parameter in Unit constructor must be a number");if(null!=r&&(!v(r)||""==r))throw new TypeError("Second parameter in Unit constructor must be a string");if(null!=r){var t=l(r);if(!t)throw new SyntaxError('Unknown unit "'+r+'"');this.unit=t.unit,this.prefix=t.prefix}else this.unit=UNIT_NONE,this.prefix=b;null!=e?(this.value=this._normalize(e),this.fixPrefix=!1):(this.value=null,this.fixPrefix=!0)}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 N)if(N.hasOwnProperty(r)&&w.endsWith(e,r)){var t=N[r],n=e.length-r.length,i=e.substring(0,n),o=t.prefixes[i];if(void 0!==o)return{unit:t,prefix:o}}return null}var p,m,h,g=t(117),d=g.number,w=g.string,y=g.number.isNumber,v=g.string.isString;n.parse=function(e){if(p=e,m=-1,h="",!v(p))return null;s(),i();var r,t=f();if(t){if(r=c(),s(),i(),h)return null;if(t&&r)try{return new n(Number(t),r)}catch(o){}}else{if(r=c(),s(),i(),h)return null;if(r)try{return new n(null,r)}catch(o){}}return null},n.isUnit=function(e){return e instanceof n},n.prototype.clone=function(){var e=new n;for(var r in this)this.hasOwnProperty(r)&&(e[r]=this[r]);return e},n.prototype._normalize=function(e){return(e+this.unit.offset)*this.unit.value*this.prefix.value},n.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},n.isValuelessUnit=function(e){return null!=l(e)},n.prototype.hasBase=function(e){return this.unit.base===e},n.prototype.equalBase=function(e){return this.unit.base===e.unit.base},n.prototype.equals=function(e){return this.equalBase(e)&&this.value==e.value},n.prototype.to=function(e){var r;if(v(e)){if(r=new n(null,e),!this.equalBase(r))throw new Error("Units do not match");return r.value=this.value,r}if(e instanceof n){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")},n.prototype.toNumber=function(e){var r=this.to(e);return r._unnormalize(r.value,r.prefix.value)},n.prototype.toString=function(){return this.format()},n.prototype.format=function(e){var r,t;if(this.fixPrefix)r=this._unnormalize(this.value),t=null!=this.value?d.format(r,e)+" ":"",t+=this.prefix.name+this.unit.name;else{var n=this._bestPrefix();r=this._unnormalize(this.value,n.value),t=d.format(r,e)+" ",t+=n.name+this.unit.name}return t},n.prototype._bestPrefix=function(){var e=Math.abs(this.value/this.unit.value),r=b,t=Math.abs(Math.log(e/r.value)/Math.LN10-1.2),n=this.unit.prefixes;for(var i in n)if(n.hasOwnProperty(i)){var o=n[i];if(o.scientific){var a=Math.abs(Math.log(e/o.value)/Math.LN10-1.2);t>a&&(r=o,t=a)}}return r};var x={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:{}};BASE_UNIT_NONE={},UNIT_NONE={name:"",base:BASE_UNIT_NONE,value:1,offset:0};var N={meter:{name:"meter",base:E.LENGTH,prefixes:x.LONG,value:1,offset:0},inch:{name:"inch",base:E.LENGTH,prefixes:x.NONE,value:.0254,offset:0},foot:{name:"foot",base:E.LENGTH,prefixes:x.NONE,value:.3048,offset:0},yard:{name:"yard",base:E.LENGTH,prefixes:x.NONE,value:.9144,offset:0},mile:{name:"mile",base:E.LENGTH,prefixes:x.NONE,value:1609.344,offset:0},link:{name:"link",base:E.LENGTH,prefixes:x.NONE,value:.201168,offset:0},rod:{name:"rod",base:E.LENGTH,prefixes:x.NONE,value:5.02921,offset:0},chain:{name:"chain",base:E.LENGTH,prefixes:x.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:E.LENGTH,prefixes:x.NONE,value:1e-10,offset:0},m:{name:"m",base:E.LENGTH,prefixes:x.SHORT,value:1,offset:0},"in":{name:"in",base:E.LENGTH,prefixes:x.NONE,value:.0254,offset:0},ft:{name:"ft",base:E.LENGTH,prefixes:x.NONE,value:.3048,offset:0},yd:{name:"yd",base:E.LENGTH,prefixes:x.NONE,value:.9144,offset:0},mi:{name:"mi",base:E.LENGTH,prefixes:x.NONE,value:1609.344,offset:0},li:{name:"li",base:E.LENGTH,prefixes:x.NONE,value:.201168,offset:0},rd:{name:"rd",base:E.LENGTH,prefixes:x.NONE,value:5.02921,offset:0},ch:{name:"ch",base:E.LENGTH,prefixes:x.NONE,value:20.1168,offset:0},mil:{name:"mil",base:E.LENGTH,prefixes:x.NONE,value:254e-7,offset:0},m2:{name:"m2",base:E.SURFACE,prefixes:x.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:E.SURFACE,prefixes:x.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:E.SURFACE,prefixes:x.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:E.SURFACE,prefixes:x.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:E.SURFACE,prefixes:x.NONE,value:2589988.110336,offset:0},sqrd:{name:"sqrd",base:E.SURFACE,prefixes:x.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:E.SURFACE,prefixes:x.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:E.SURFACE,prefixes:x.NONE,value:6.4516e-10,offset:0},m3:{name:"m3",base:E.VOLUME,prefixes:x.CUBIC,value:1,offset:0},L:{name:"L",base:E.VOLUME,prefixes:x.SHORT,value:.001,offset:0},l:{name:"l",base:E.VOLUME,prefixes:x.SHORT,value:.001,offset:0},litre:{name:"litre",base:E.VOLUME,prefixes:x.LONG,value:.001,offset:0},cuin:{name:"cuin",base:E.VOLUME,prefixes:x.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:E.VOLUME,prefixes:x.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:E.VOLUME,prefixes:x.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:E.VOLUME,prefixes:x.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:E.VOLUME,prefixes:x.NONE,value:15e-6,offset:0},minim:{name:"minim",base:E.VOLUME,prefixes:x.NONE,value:6.161152e-8,offset:0},fluiddram:{name:"fluiddram",base:E.VOLUME,prefixes:x.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:E.VOLUME,prefixes:x.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:E.VOLUME,prefixes:x.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:E.VOLUME,prefixes:x.NONE,value:1e-6,offset:0},cup:{name:"cup",base:E.VOLUME,prefixes:x.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:E.VOLUME,prefixes:x.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:E.VOLUME,prefixes:x.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:E.VOLUME,prefixes:x.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:E.VOLUME,prefixes:x.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:E.VOLUME,prefixes:x.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:E.VOLUME,prefixes:x.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:E.VOLUME,prefixes:x.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:E.VOLUME,prefixes:x.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:E.VOLUME,prefixes:x.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:E.VOLUME,prefixes:x.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:E.VOLUME,prefixes:x.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:E.VOLUME,prefixes:x.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:E.VOLUME,prefixes:x.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:E.VOLUME,prefixes:x.NONE,value:.1173478,offset:0},obl:{name:"obl",base:E.VOLUME,prefixes:x.NONE,value:.1589873,offset:0},g:{name:"g",base:E.MASS,prefixes:x.SHORT,value:.001,offset:0},gram:{name:"gram",base:E.MASS,prefixes:x.LONG,value:.001,offset:0},ton:{name:"ton",base:E.MASS,prefixes:x.SHORT,value:907.18474,offset:0},tonne:{name:"tonne",base:E.MASS,prefixes:x.SHORT,value:1e3,offset:0},grain:{name:"grain",base:E.MASS,prefixes:x.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:E.MASS,prefixes:x.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:E.MASS,prefixes:x.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:E.MASS,prefixes:x.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:E.MASS,prefixes:x.NONE,value:45.359237,offset:0},stick:{name:"stick",base:E.MASS,prefixes:x.NONE,value:.115,offset:0},gr:{name:"gr",base:E.MASS,prefixes:x.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:E.MASS,prefixes:x.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:E.MASS,prefixes:x.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:E.MASS,prefixes:x.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:E.MASS,prefixes:x.NONE,value:45.359237,offset:0},s:{name:"s",base:E.TIME,prefixes:x.SHORT,value:1,offset:0},min:{name:"min",base:E.TIME,prefixes:x.NONE,value:60,offset:0},h:{name:"h",base:E.TIME,prefixes:x.NONE,value:3600,offset:0},second:{name:"second",base:E.TIME,prefixes:x.LONG,value:1,offset:0},sec:{name:"sec",base:E.TIME,prefixes:x.LONG,value:1,offset:0},minute:{name:"minute",base:E.TIME,prefixes:x.NONE,value:60,offset:0},hour:{name:"hour",base:E.TIME,prefixes:x.NONE,value:3600,offset:0},day:{name:"day",base:E.TIME,prefixes:x.NONE,value:86400,offset:0},rad:{name:"rad",base:E.ANGLE,prefixes:x.NONE,value:1,offset:0},deg:{name:"deg",base:E.ANGLE,prefixes:x.NONE,value:.017453292519943295,offset:0},grad:{name:"grad",base:E.ANGLE,prefixes:x.NONE,value:.015707963267948967,offset:0},cycle:{name:"cycle",base:E.ANGLE,prefixes:x.NONE,value:6.283185307179586,offset:0},A:{name:"A",base:E.CURRENT,prefixes:x.SHORT,value:1,offset:0},ampere:{name:"ampere",base:E.CURRENT,prefixes:x.LONG,value:1,offset:0},K:{name:"K",base:E.TEMPERATURE,prefixes:x.NONE,value:1,offset:0},degC:{name:"degC",base:E.TEMPERATURE,prefixes:x.NONE,value:1,offset:273.15},degF:{name:"degF",base:E.TEMPERATURE,prefixes:x.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:E.TEMPERATURE,prefixes:x.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:E.TEMPERATURE,prefixes:x.NONE,value:1,offset:0},celsius:{name:"celsius",base:E.TEMPERATURE,prefixes:x.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:E.TEMPERATURE,prefixes:x.NONE,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:E.TEMPERATURE,prefixes:x.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:E.AMOUNT_OF_SUBSTANCE,prefixes:x.NONE,value:1,offset:0},mole:{name:"mole",base:E.AMOUNT_OF_SUBSTANCE,prefixes:x.NONE,value:1,offset:0},cd:{name:"cd",base:E.LUMINOUS_INTENSITY,prefixes:x.NONE,value:1,offset:0},candela:{name:"candela",base:E.LUMINOUS_INTENSITY,prefixes:x.NONE,value:1,offset:0},N:{name:"N",base:E.FORCE,prefixes:x.SHORT,value:1,offset:0},newton:{name:"newton",base:E.FORCE,prefixes:x.LONG,value:1,offset:0},lbf:{name:"lbf",base:E.FORCE,prefixes:x.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:E.FORCE,prefixes:x.NONE,value:4.4482216152605,offset:0},b:{name:"b",base:E.BIT,prefixes:x.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:E.BIT,prefixes:x.BINARY_LONG,value:1,offset:0},B:{name:"B",base:E.BIT,prefixes:x.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:E.BIT,prefixes:x.BINARY_LONG,value:8,offset:0}},M={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",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 A in M)if(M.hasOwnProperty(A)){var S=N[M[A]],T=Object.create(S);T.name=A,N[A]=T}N.lt=N.l,N.liter=N.litre,N.liters=N.litres,N.lb=N.lbm,N.lbs=N.lbm,n.PREFIXES=x,n.BASE_UNITS=E,n.UNITS=N,e.exports=n},function(e,r,t){function n(e,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this.math=e,this.doc=r}var i=t(117),o=i.object,a=i.string;n.isHelp=function(e){return e instanceof n},n.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 t=this.math.parser();r+="Examples:\n";for(var i=0;i<e.examples.length;i++){var o,s=e.examples[i];try{o=t.eval(s)}catch(u){o=u}r+=" "+s+"\n",!o||o instanceof n||(r+=" "+a.format(o)+"\n")}r+="\n"}return e.seealso&&(r+="See also: "+e.seealso.join(", ")+"\n"),r},n.prototype.toJSON=function(){return o.clone(this.doc)},e.exports=n},function(e,r,t){function n(e,r,t){var o,a,s,f;if(0>=r){if(u(e[0])){for(f=i(e),a=[],o=0;o<f.length;o++)a[o]=n(f[o],r-1,t);return a}for(s=e[0],o=1;o<e.length;o++)s=t(s,e[o]);return s}for(a=[],o=0;o<e.length;o++)a[o]=n(e[o],r-1,t);return a}function i(e){var r,t,n=e.length,i=e[0].length,o=[];for(t=0;i>t;t++){var a=[];for(r=0;n>r;r++)a.push(e[r][t]);o.push(a)}return o}{var o=t(117),a=t(114),s=t(8),u=o.array.isArray;o.string.isString}r.argsToArray=function(e){var r;return 0==e.length?r=[]:1==e.length?(r=e[0],r instanceof s&&(r=r.valueOf()),u(r)||(r=[r])):r=Array.prototype.slice.apply(e),r},r.isCollection=function(e){return u(e)||e instanceof s},r.deepMap=function f(e,r){return e&&"function"==typeof e.map?e.map(function(e){return f(e,r)}):r(e)},r.deepMap2=function c(e,r,t){var n,i,o;if(u(e))if(u(r)){if(e.length!=r.length)throw new a(e.length,r.length);for(n=[],i=e.length,o=0;i>o;o++)n[o]=c(e[o],r[o],t)}else{if(r instanceof s)return n=c(e,r.valueOf(),t),new s(n);for(n=[],i=e.length,o=0;i>o;o++)n[o]=c(e[o],r,t)}else{if(e instanceof s)return r instanceof s?(n=c(e.valueOf(),r.valueOf(),t),new s(n)):(n=c(e.valueOf(),r,t),new s(n));if(u(r))for(n=[],i=r.length,o=0;i>o;o++)n[o]=c(e,r[o],t);else{if(r instanceof s)return n=c(e,r.valueOf(),t),new s(n);n=t(e,r)}}return n},r.reduce=function(e,r,t){return e instanceof s?new s(n(e.valueOf(),r,t)):n(e,r,t)},r.deepForEach=function l(e,r){e instanceof s&&(e=e.valueOf());for(var t=0,n=e.length;n>t;t++){var i=e[t];u(i)?l(i,r):r(i)}}},function(e,r,t){function n(e,r){if(1!=arguments.length&&2!=arguments.length)throw new SyntaxError("Wrong number of arguments: 1 or 2 expected");if(fr="object"===V(r)?r:{},D(e))return cr=e,p();if(G(e)||e instanceof H)return W.deepMap(e,function(e){if(!D(e))throw new TypeError("String expected");return cr=e,p()});throw new TypeError("String or matrix expected")}function i(){lr=0,pr=cr.charAt(0)}function o(){lr++,pr=cr.charAt(lr)}function a(){return cr.charAt(lr+1)}function s(){for(hr=ar.NULL,mr="";" "==pr||" "==pr;)o();if("#"==pr)for(;"\n"!=pr&&""!=pr;)o();if(""==pr)return void(hr=ar.DELIMITER);var e=pr+a();if(sr[e])return hr=ar.DELIMITER,mr=e,o(),void o();if(sr[pr])return hr=ar.DELIMITER,mr=pr,void o();if(!c(pr)){if(f(pr)){for(;f(pr)||l(pr);)mr+=pr,o();return void(hr=ur[mr]?ar.DELIMITER:ar.SYMBOL)}for(hr=ar.UNKNOWN;""!=pr;)mr+=pr,o();throw k('Syntax error in part "'+mr+'"')}if(hr=ar.NUMBER,"."==pr)mr+=pr,o(),l(pr)||(hr=ar.UNKNOWN);else{for(;l(pr);)mr+=pr,o();"."==pr&&(mr+=pr,o())}for(;l(pr);)mr+=pr,o();if("E"==pr||"e"==pr)for(mr+=pr,o(),("+"==pr||"-"==pr)&&(mr+=pr,o()),l(pr)||(hr=ar.UNKNOWN);l(pr);)mr+=pr,o()}function u(){for(;"\n"==mr;)s()}function f(e){return e>="a"&&"z">=e||e>="A"&&"Z">=e||"_"==e}function c(e){return e>="0"&&"9">=e||"."==e}function l(e){return e>="0"&&"9">=e}function p(){i(),s();var e=m();if(""!=mr)throw hr==ar.DELIMITER?P("Unknown operator "+mr):k('Unexpected part "'+mr+'"');return e}function m(){var e,r,t;if(""==mr)return new Q("undefined","undefined");for("\n"!=mr&&";"!=mr&&(e=h());"\n"==mr||";"==mr;)r||(r=new $,e&&(t=";"!=mr,r.add(e,t))),s(),"\n"!=mr&&";"!=mr&&""!=mr&&(e=h(),t=";"!=mr,r.add(e,t));return r?r:e}function h(){var e=g(),r="ans";return new Z(r,e)}function g(){if(hr==ar.SYMBOL&&"function"==mr)throw new Error('Deprecated keyword "function". Functions can now be assigned without it, like "f(x) = x^2".');return d()}function d(){var e,r,t,n=w();if("="==mr){if(n instanceof tr)return e=n.name,s(),t=d(),new Z(e,t);if(n instanceof K)return s(),t=d(),new or(n,t);if(n instanceof er){var i=!0;if(r=[],n.object instanceof tr?(e=n.object.name,n.params.forEach(function(e,t){e instanceof tr?r[t]=e.name:i=!1})):i=!1,i)return s(),t=d(),new J(e,r,t)}throw k("Invalid left hand side of assignment operator =")}return n}function w(){var e,r=[];if(e=":"==mr?new Q("number","1"):y(),":"==mr){for(r.push(e);":"==mr;)s(),r.push(")"==mr||"]"==mr||","==mr||""==mr?new tr("end"):y());if(3==r.length){var t=r[2];r[2]=r[1],r[1]=t}e=new rr(r)}return e}function y(){var e=v();return e}function v(){for(var e=x();"?"==mr;){s();var r=[e];if(r.push(x()),":"!=mr)throw k("False part of conditional expression expected");s(),r.push(v()),e=new nr(["?",":"],"ifElse",r)}return e}function x(){var e,r,t,n,i;for(e=b(),r={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallereq",">=":"largereq"};mr in r;)t=mr,n=r[t],s(),i=[e,b()],e=new X(t,n,i);return e}function b(){var e,r,t,n,i;for(e=E(),r={to:"to","in":"to"};mr in r;)t=mr,n=r[t],s(),i=[e,E()],e=new X(t,n,i);return e}function E(){var e,r,t,n,i;for(e=N(),r={"+":"add","-":"subtract"};mr in r;)t=mr,n=r[t],s(),i=[e,N()],e=new X(t,n,i);return e}function N(){var e,r,t,n,i;for(e=M(),r={"*":"multiply",".*":"emultiply","/":"divide","./":"edivide","%":"mod",mod:"mod"};mr in r;)t=mr,n=r[t],s(),i=[e,M()],e=new X(t,n,i);return e}function M(){var e,r;return e=A(),(hr==ar.SYMBOL||"in"==mr)&&(r=mr,s(),e=new ir(e,r)),e}function A(){var e,r,t;return"-"==mr?(e=mr,r="unary",s(),t=[A()],new X(e,r,t)):S()}function S(){var e,r,t,n;return e=T(),("^"==mr||".^"==mr)&&(r=mr,t="^"==r?"pow":"epow",s(),n=[e,S()],e=new X(r,t,n)),e}function T(){var e,r,t,n,i;for(e=O(),r={"!":"factorial","'":"transpose"};mr in r;)t=mr,n=r[t],s(),i=[e],e=new X(t,n,i);return e}function O(){var e,r=[];if(hr==ar.SYMBOL&&fr[mr]){if(e=fr[mr],s(),"("==mr){if(r=[],s(),")"!=mr)for(r.push(w());","==mr;)s(),r.push(w());if(")"!=mr)throw k("Parenthesis ) expected");s()}return new e(r)}return C()}function C(){var e,r;return hr==ar.SYMBOL||hr==ar.DELIMITER&&mr in ur?(r=mr,s(),e=new tr(r),_(e)):B()}function _(e){for(var r,t;"("==mr||"["==mr;){if(r=mr,t=[],s(),")"!=mr&&"]"!=mr)for(t.push(w());","==mr;)s(),t.push(w());if("("==r&&")"!=mr)throw k("Parenthesis ) expected");if("["==r&&"]"!=mr)throw k("Parenthesis ] expected");s(),e="("==r?new er(e,t):new K(e,t)}return e}function B(){var e,r,t;if('"'==mr){for(r="",t="";""!=pr&&('"'!=pr||"\\"==t);)r+=pr,t=pr,o();if(s(),'"'!=mr)throw k('End of string " expected');return s(),e=new Q("string",r),e=_(e)}return I()}function I(){var e,r,t,n;if("["==mr){if(s(),u(),"]"!=mr){var i=U();if(";"==mr){for(t=1,r=[i];";"==mr;)s(),u(),r[t]=U(),t++,u();if("]"!=mr)throw k("End of matrix ] expected");s(),n=r[0].nodes.length;for(var o=1;t>o;o++)if(r[o].nodes.length!=n)throw P("Column dimensions mismatch ("+r[o].nodes.length+" != "+n+")");e=new Y(r)}else{if("]"!=mr)throw k("End of matrix ] expected");s(),e=i}}else s(),e=new Y([]);return e=_(e)}return z()}function U(){for(var e=[d()],r=1;","==mr;)s(),u(),e[r]=d(),r++,u();return new Y(e)}function z(){var e,r;return hr==ar.NUMBER?(r=mr,s(),"i"==mr||"I"==mr?(s(),e=new Q("complex",r)):e=new Q("number",r),e=_(e)):q()}function q(){var e;if("("==mr){if(s(),e=d(),")"!=mr)throw k("Parenthesis ) expected");return s(),e=_(e)}return L()}function L(){throw k(""==mr?"Unexpected end of expression":"Value expected")}function j(){return lr-mr.length+1}function R(e){return e+" (char "+j()+")"}function k(e){return new SyntaxError(R(e))}function P(e){return new Error(R(e))}var F=t(117),D=F.string.isString,G=Array.isArray,V=F.types.type,H=(t(5),t(8)),W=(t(9),t(11)),Y=t(118),Z=t(119),$=t(120),Q=t(121),J=t(122),K=t(123),X=t(124),er=t(125),rr=t(126),tr=t(127),nr=t(128),ir=t(129),or=t(130),ar={NULL:0,DELIMITER:1,NUMBER:2,SYMBOL:3,UNKNOWN:4},sr={",":!0,"(":!0,")":!0,"[":!0,"]":!0,'"':!0,"\n":!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"!":!0,"'":!0,"=":!0,":":!0,"?":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0},ur={mod:!0,to:!0,"in":!0},fr={},cr="",lr=0,pr="",mr="",hr=ar.NULL;e.exports=n},function(e,r,t){function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if("object"!=typeof e)throw new TypeError("Object expected as parameter math");this.math=e,this.scope={}}var i=t(12);n.prototype.parse=function(e){return i(e)},n.prototype.compile=function(e){return i(e).compile(this.math)},n.prototype.eval=function(e){return i(e).compile(this.math).eval(this.scope)},n.prototype.get=function(e){return this.scope[e]},n.prototype.set=function(e,r){return this.scope[e]=r},n.prototype.remove=function(e){delete this.scope[e]},n.prototype.clear=function(){for(var e in this.scope)this.scope.hasOwnProperty(e)&&delete this.scope[e]},e.exports=n},function(e,r,t){r.ArrayNode=t(118),r.AssignmentNode=t(119),r.BlockNode=t(120),r.ConstantNode=t(121),r.IndexNode=t(123),r.FunctionNode=t(122),r.Node=t(131),r.OperatorNode=t(124),r.ParamsNode=t(125),r.RangeNode=t(126),r.SymbolNode=t(127),r.TernaryNode=t(128),r.UnitNode=t(129),r.UpdateNode=t(130)},function(e,r,t){r.e=t(133),r.E=t(133),r["false"]=t(134),r.i=t(135),r.Infinity=t(136),r.LN2=t(137),r.LN10=t(138),r.LOG2E=t(139),r.LOG10E=t(140),r.NaN=t(141),r.pi=t(142),r.PI=t(142),r.SQRT1_2=t(143),r.SQRT2=t(144),r.tau=t(145),r["true"]=t(146),r.abs=t(151),r.add=t(152),r.ceil=t(153),r.compare=t(154),r.cube=t(155),r.divide=t(156),r.edivide=t(157),r.emultiply=t(158),r.epow=t(159),r.equal=t(160),r.exp=t(161),r.fix=t(162),r.floor=t(163),r.gcd=t(164),r.larger=t(165),r.largereq=t(166),r.lcm=t(167),r.log=t(168),r.log10=t(169),r.mod=t(170),r.multiply=t(171),r.norm=t(172),r.pow=t(173),r.round=t(174),r.sign=t(175),r.smaller=t(176),r.smallereq=t(177),r.sqrt=t(178),r.square=t(179),r.subtract=t(180),r.unary=t(181),r.unequal=t(182),r.xgcd=t(183),r.arg=t(184),r.conj=t(185),r.re=t(186),r.im=t(187),r.bignumber=t(188),r["boolean"]=t(189),r.complex=t(190),r.index=t(191),r.matrix=t(192),r.number=t(193),r.string=t(194),r.unit=t(195),r.eval=t(196),r.help=t(197),r.concat=t(198),r.det=t(199),r.diag=t(200),r.eye=t(201),r.inv=t(202),r.ones=t(203),r.range=t(204),r.resize=t(205),r.size=t(206),r.squeeze=t(207),r.subset=t(208),r.transpose=t(209),r.zeros=t(210),r.combinations=t(211),r.distribution=t(212),r.factorial=t(213),r.permutations=t(214),r.pickRandom=t(215),r.random=t(216),r.randomInt=t(217),r.max=t(218),r.mean=t(219),r.median=t(220),r.min=t(221),r.prod=t(222),r.std=t(223),r.sum=t(224),r["var"]=t(225),r.acos=t(226),r.asin=t(227),r.atan=t(228),r.atan2=t(229),r.cos=t(230),r.cot=t(231),r.csc=t(232),r.sec=t(233),r.sin=t(234),r.tan=t(235),r.to=t(236),r.clone=t(237),r.map=t(238),r.forEach=t(239),r.format=t(240),r.ifElse=t(241),r["import"]=t(242),r["typeof"]=t(243)},function(e,r,t){e.exports=function(e){function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this.value=e instanceof r?e.value:e}function n(e,t){var n=Array.prototype.slice;r.prototype[e]="function"==typeof t?function(){var e=[this.value].concat(n.call(arguments,0));return new r(t.apply(this,e))}:new r(t)}var i=t(132);r.prototype.done=function(){return this.value},r.prototype.valueOf=function(){return this.value},r.prototype.toString=function(){return i.format(this.value)},r.createProxy=n;for(var o in e)e.hasOwnProperty(o)&&n(o,e[o]);return r}},function(e,r,t){e.exports=function(e){var r=t(117),n=t(12),i=t(11),o=r.string.isString,a=i.isCollection;e.compile=function(r){if(1!=arguments.length)throw new e.error.ArgumentsError("compile",arguments.length,1);if(o(r))return n(r).compile(e);if(a(r))return i.deepMap(r,function(r){return n(r).compile(e)});throw new TypeError("String, array, or matrix expected")}}},function(e,r,t){e.exports=function(e){var r=t(117),n=t(12),i=t(11),o=r.string.isString,a=i.isCollection;e.eval=function(r,t){if(1!=arguments.length&&2!=arguments.length)throw new e.error.ArgumentsError("eval",arguments.length,1,2);if(t=t||{},o(r))return n(r).compile(e).eval(t);if(a(r))return i.deepMap(r,function(r){return n(r).compile(e).eval(t)});throw new TypeError("String, array, or matrix expected")}}},function(e,r,t){e.exports=function(e){var r=t(10);e.help=function(t){if(1!=arguments.length)throw new SyntaxError("Wrong number of arguments in function help ("+arguments.length+" provided, 1 expected)");var n=null;if(t instanceof String||"string"==typeof t)n=t;else{var i;for(i in e)if(e.hasOwnProperty(i)&&t===e[i]){n=i;break}}var o=e.expression.docs[n];if(!n||!o)throw new Error('No documentation found on "'+n+'"');return new r(e,o)}}},function(e,r,t){e.exports=function(e){var r=t(12);e.parse=function(){return r.apply(r,arguments)}}},function(e,r,t){e.exports=function(e){var r=t(117),n=e.type.BigNumber,i=t(5),o=(t(8),t(11)),a=r.number.isNumber,s=r["boolean"].isBoolean,u=i.isComplex,f=o.isCollection;e.abs=function c(r){if(1!=arguments.length)throw new e.error.ArgumentsError("abs",arguments.length,1);if(a(r))return Math.abs(r);if(u(r))return Math.sqrt(r.re*r.re+r.im*r.im);if(r instanceof n)return r.abs();if(f(r))return o.deepMap(r,c);if(s(r))return Math.abs(r);throw new e.error.UnsupportedTypeError("abs",e["typeof"](r))}}},function(e,r,t){e.exports=function(e){var r=t(117),n=e.type.BigNumber,i=t(5),o=(t(8),t(9)),a=t(11),s=r["boolean"].isBoolean,u=r.number.isNumber,f=r.string.isString,c=i.isComplex,l=o.isUnit,p=a.isCollection;e.add=function m(r,t){if(2!=arguments.length)throw new e.error.ArgumentsError("add",arguments.length,2);if(u(r)){if(u(t))return r+t;if(c(t))return new i(r+t.re,t.im)}if(c(r)){if(c(t))return new i(r.re+t.re,r.im+t.im);if(u(t))return new i(r.re+t,r.im)}if(l(r)&&l(t)){if(null==r.value)throw new Error("Parameter x contains a unit with undefined value");if(null==t.value)throw new Error("Parameter y contains a unit with undefined value");if(!r.equalBase(t))throw new Error("Units do not match");var o=r.clone();return o.value+=t.value,o.fixPrefix=!1,o}if(r instanceof n)return u(t)?t=n.convert(t):s(t)&&(t=new n(t?1:0)),t instanceof n?r.plus(t):m(r.toNumber(),t);if(t instanceof n)return u(r)?r=n.convert(r):s(r)&&(r=new n(r?1:0)),r instanceof n?r.plus(t):m(r,t.toNumber());if(f(r)||f(t))return r+t;if(p(r)||p(t))return a.deepMap2(r,t,m);if(s(r))return m(+r,t);if(s(t))return m(r,+t);throw new e.error.UnsupportedTypeError("add",e["typeof"](r),e["typeof"](t))}}},function(e,r,t){e.exports=function(e){var r=t(117),n=e.type.BigNumber,i=t(5),o=t(11),a=r.number.isNumber,s=r["boolean"].isBoolean,u=o.isCollection,f=i.isComplex;e.ceil=function c(r){if(1!=arguments.length)throw new e.error.ArgumentsError("ceil",arguments.length,1);if(a(r))return Math.ceil(r);if(f(r))return new i(Math.ceil(r.re),Math.ceil(r.im));if(r instanceof n)return r.ceil();if(u(r))return o.deepMap(r,c);if(s(r))return Math.ceil(r);throw new e.error.UnsupportedTypeError("ceil",e["typeof"](r))}}},function(e,r,t){e.exports=function(e,r){var n=t(117),i=e.type.BigNumber,o=t(5),a=t(9),s=t(11),u=n.number.isNumber,f=n.number.nearlyEqual,c=n["boolean"].isBoolean,l=n.string.isString,p=o.isComplex,m=a.isUnit,h=s.isCollection;e.compare=function g(t,n){if(2!=arguments.length)throw new e.error.ArgumentsError("compare",arguments.length,2);if(u(t)&&u(n))return f(t,n,r.epsilon)?0:t>n?1:-1;if(t instanceof i)return u(n)?n=i.convert(n):c(n)&&(n=new i(n?1:0)),n instanceof i?new i(t.cmp(n)):g(t.toNumber(),n);if(n instanceof i)return u(t)?t=i.convert(t):c(t)&&(t=new i(t?1:0)),t instanceof i?new i(t.cmp(n)):g(t,n.toNumber());if(m(t)&&m(n)){if(!t.equalBase(n))throw new Error("Cannot compare units with different base");return t.value>n.value?1:t.value<n.value?-1:0}if(h(t)||h(n))return s.deepMap2(t,n,g);if(l(t)||l(n))return t>n?1:n>t?-1:0;if(c(t))return g(+t,n