Files

56 lines
492 KiB
JavaScript
Raw Permalink Normal View History

2026-03-15 17:08:23 +07:00
/**
* 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 3.17.0
* @date 2017-11-18
*
* @license
* Copyright (C) 2013-2017 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,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.math=t():e.math=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=148)}([function(e,t,r){"use strict";function n(e,t,r,n){function i(t,r,n){var i=e.Matrix.storage(r||"default");return new i(t,n)}var a=n("matrix",{"":function(){return i([])},string:function(e){return i([],e)},"string, string":function(e,t){return i([],e,t)},Array:function(e){return i(e)},Matrix:function(e){return i(e,e.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});return a.toTex={0:"\\begin{bmatrix}\\end{bmatrix}",1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},a}t.name="matrix",t.factory=n},function(e,t,r){"use strict";e.exports=function e(t,r,n){return t&&"function"==typeof t.map?t.map(function(t){return e(t,r,n)}):r(t)}},function(e,t,r){"use strict";function n(e,t,r){var i,a=e.length;if(a!=t[r])throw new f(a,t[r]);if(r<t.length-1){var o=r+1;for(i=0;i<a;i++){var s=e[i];if(!Array.isArray(s))throw new f(t.length-1,t.length,"<");n(e[i],t,o)}}else for(i=0;i<a;i++)if(Array.isArray(e[i]))throw new f(t.length+1,t.length,">")}function i(e,r,n,a){var o,s,u=e.length,c=r[n],f=Math.min(u,c);if(e.length=c,n<r.length-1){var l=n+1;for(o=0;o<f;o++)s=e[o],Array.isArray(s)||(s=[s],e[o]=s),i(s,r,l,a);for(o=f;o<c;o++)s=[],e[o]=s,i(s,r,l,a)}else{for(o=0;o<f;o++)for(;Array.isArray(e[o]);)e[o]=e[o][0];if(a!==t.UNINITIALIZED)for(o=f;o<c;o++)e[o]=a}}function a(e,t){var r,n=[];if(0===t.length){if(0===e.length)throw new f(null,null,"!=");return e.shift()}for(r=0;r<t[0];r+=1)n.push(a(e,t.slice(1)));return n}function o(e,t,r){var n,i;if(r<t){var a=r+1;for(n=0,i=e.length;n<i;n++)e[n]=o(e[n],t,a)}else for(;Array.isArray(e);)e=e[0];return e}function s(e,t,r){var n,i;if(Array.isArray(e)){var a=r+1;for(n=0,i=e.length;n<i;n++)e[n]=s(e[n],t,a)}else for(var o=r;o<t;o++)e=[e];return e}var u=r(3),c=r(9),f=(r(5),r(59),r(10)),l=r(51);t.size=function(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t},t.validate=function(e,t){var r=0==t.length;if(r){if(Array.isArray(e))throw new f(e.length,0)}else n(e,t,0)},t.validateIndex=function(e,t){if(!u.isNumber(e)||!u.isInteger(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||"number"==typeof t&&e>=t)throw new l(e,t)},t.UNINITIALIZED={},t.resize=function(e,t,r){if(!Array.isArray(e)||!Array.isArray(t))throw new TypeError("Array expected");if(0===t.length)throw new Error("Resizing to scalar is not supported");t.forEach(function(e){if(!u.isNumber(e)||!u.isInteger(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+c.format(t)+")")});var n=void 0!==r?r:0;return i(e,t,0,n),e},t.reshape=function(e,r){var n,i=t.flatten(e),o=function(e){return e.reduce(function(e,t){return e*t})};if(!Array.isArray(e)||!Array.isArray(r))throw new TypeError("Array expected");if(0===r.length)throw new f(0,o(t.size(e)),"!=");try{n=a(i,r)}catch(n){if(n instanceof f)throw new f(o(r),o(t.size(e)),"!=");throw n}if(i.length>0)throw new f(o(r),o(t.size(e)),"!=");return n},t.squeeze=function(e,r){for(var n=r||t.size(e);Array.isArray(e)&&1===e.length;)e=e[0],n.shift();for(var i=n.length;1===n[i-1];)i--;return i<n.length&&(e=o(e,i,0),n.length=i),e},t.unsqueeze=function(e,r,n,i){var a=i||t.size(e);if(n)for(var o=0;o<n;o++)e=[e],a.unshift(1);for(e=s(e,r,0);a.length<r;)a.push(1);return e},t.flatten=function(e){if(!Array.isArray(e))return e;var t=[];return e.forEach(function e(r){Array.isArray(r)?r.forEach(e):t.push(r)}),t},t.map=function(e,t){return Array.prototype.map.call(e,t)},t.fo
},function(e,t,r){"use strict";function n(e,t,n,a){var o=r(4),s=n(r(0)),u=n(r(20)),c=n(r(37)),f=n(r(33)),l=n(r(15)),p=n(r(60)),h=n(r(36)),m=n(r(8)),d=n(r(6)),v=a("subtract",{"number, number":function(e,t){return e-t},"Complex, Complex":function(e,t){return e.sub(t)},"BigNumber, BigNumber":function(e,t){return e.minus(t)},"Fraction, Fraction":function(e,t){return e.sub(t)},"Unit, Unit":function(e,t){if(null==e.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(!e.equalBase(t))throw new Error("Units do not match");var r=e.clone();return r.value=v(r.value,t.value),r.fixPrefix=!1,r},"Matrix, Matrix":function(e,t){var r=e.size(),n=t.size();if(r.length!==n.length)throw new i(r.length,n.length);var a;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":a=p(e,t,v);break;default:a=l(t,e,v,!0)}break;default:switch(t.storage()){case"sparse":a=f(e,t,v,!1);break;default:a=m(e,t,v)}}return a},"Array, Array":function(e,t){return v(s(e),s(t)).valueOf()},"Array, Matrix":function(e,t){return v(s(e),t)},"Matrix, Array":function(e,t){return v(e,s(t))},"Matrix, any":function(e,t){var r;switch(e.storage()){case"sparse":r=h(e,c(t),u);break;default:r=d(e,t,v)}return r},"any, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":r=h(t,e,v,!0);break;default:r=d(t,e,v,!0)}return r},"Array, any":function(e,t){return d(s(e),t,v,!1).valueOf()},"any, Array":function(e,t){return d(s(t),e,v,!0).valueOf()}});return v.toTex={2:"\\left(${args[0]}"+o.operators.subtract+"${args[1]}\\right)"},v}var i=r(10);t.name="subtract",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,u){function c(t,r){if(!e.isIndex(r))throw new TypeError("Index expected");if(1!=r.size().length)throw new f(r.size().length,1);var n=t.length;s(r.min()[0],n),s(r.max()[0],n);var i=r.dimension(0),a="";return i.forEach(function(e){a+=t.charAt(e)}),a}function l(e,t,r,n){if(!t||t.isIndex!==!0)throw new TypeError("Index expected");if(1!=t.size().length)throw new f(t.size().length,1);if(void 0!==n){if("string"!=typeof n||1!==n.length)throw new TypeError("Single character expected as defaultValue")}else n=" ";var i=t.dimension(0),a=i.size()[0];if(a!=r.length)throw new f(i.size()[0],r.length);var o=e.length;s(t.min()[0]),s(t.max()[0]);for(var u=[],c=0;c<o;c++)u[c]=e.charAt(c);if(i.forEach(function(e,t){u[e]=r.charAt(t[0])}),u.length>o)for(c=o-1,a=u.length;c<a;c++)u[c]||(u[c]=n);return u.join("")}var p=n(r(0)),h=u("subset",{"Array, Index":function(e,t){var r=p(e),n=r.subset(t);return t.isScalar()?n:n.valueOf()},"Matrix, Index":function(e,t){return e.subset(t)},"Object, Index":i,"string, Index":c,"Array, Index, any":function(e,t,r){return p(o(e)).subset(t,r,void 0).valueOf()},"Array, Index, any, any":function(e,t,r,n){return p(o(e)).subset(t,r,n).valueOf()},"Matrix, Index, any":function(e,t,r){return e.clone().subset(t,r)},"Matrix, Index, any, any":function(e,t,r,n){return e.clone().subset(t,r,n)},"string, Index, string":l,"string, Index, string, string":l,"Object, Index, any":a});return h.toTex=void 0,h}function i(e,t){if(1!==t.size().length)throw new f(t.size(),1);var r=t.dimension(0);if("string"!=typeof r)throw new TypeError("String expected as index to retrieve an object property");return u(e,r)}function a(e,t,r){if(1!==t.size().length)throw new f(t.size(),1);var n=t.dimension(0);if("string"!=typeof n)throw new TypeError("String expected as index to retrieve an object property");var i=o(e);return c(i,n,r),i}var o=r(5).clone,s=r(2).validateIndex,u=r(13).getSafeProperty,c=r(13).setSafeProperty,f=r(10);t.name="subset",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var i=n("multiplyScalar",{"number, number":function(e,t){return e*t},"Complex, Complex":function(e,t){return e.mul(t)},"BigNumber, BigNumber":function(e,t){return e.times(t)},"Fraction, Fraction":function(e,t){return e.mul(t)},"number | Fraction | BigNumber | Complex, Unit":function(e,t){var r=t.clone();return r.value=null===r.value?r._normalize(e):i(r.value,e),r},"Unit, number | Fracti
u[o]=t,this},d.prototype.resize=function(e,t,r){if(!f(e))throw new TypeError("Array expected");var n=r?this.clone():this;return E(n,e,t)};var E=function(e,t,r){if(0===t.length){for(var n=e._data;f(n);)n=n[0];return n}return e._size=t.slice(0),e._data=s.resize(e._data,e._size,r),e};return d.prototype.reshape=function(e,t){var r=t?this.clone():this;return r._data=s.reshape(r._data,e),r._size=e.slice(0),r},d.prototype.clone=function(){var e=new d({data:u.clone(this._data),size:u.clone(this._size),datatype:this._datatype});return e},d.prototype.size=function(){return this._size.slice(0)},d.prototype.map=function(e){var t=this,r=function(n,i){return f(n)?n.map(function(e,t){return r(e,i.concat(t))}):e(n,i,t)};return new d({data:r(this._data,[]),size:u.clone(this._size),datatype:this._datatype})},d.prototype.forEach=function(e){var t=this,r=function(n,i){f(n)?n.forEach(function(e,t){r(e,i.concat(t))}):e(n,i,t)};r(this._data,[])},d.prototype.toArray=function(){return u.clone(this._data)},d.prototype.valueOf=function(){return this._data},d.prototype.format=function(e){return o.format(this._data,e)},d.prototype.toString=function(){return o.format(this._data)},d.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},d.prototype.diagonal=function(t){if(t){if(e.isBigNumber(t)&&(t=t.toNumber()),!l(t)||!p(t))throw new TypeError("The parameter k must be an integer number")}else t=0;for(var r=t>0?t:0,n=t<0?-t:0,i=this._size[0],a=this._size[1],o=Math.min(i-n,a-r),s=[],u=0;u<o;u++)s[u]=this._data[u+n][u+r];return new d({data:s,size:[o],datatype:this._datatype})},d.diagonal=function(t,r,n,i,a){if(!f(t))throw new TypeError("Array expected, size parameter");if(2!==t.length)throw new Error("Only two dimensions matrix are supported");if(t=t.map(function(t){if(e.isBigNumber(t)&&(t=t.toNumber()),!l(t)||!p(t)||t<1)throw new Error("Size values must be positive integers");return t}),n){if(e.isBigNumber(n)&&(n=n.toNumber()),!l(n)||!p(n))throw new TypeError("The parameter k must be an integer number")}else n=0;i&&h(a)&&(i=c.convert(i,a));var o,u=n>0?n:0,m=n<0?-n:0,v=t[0],g=t[1],y=Math.min(v-m,g-u);if(f(r)){if(r.length!==y)throw new Error("Invalid value array length");o=function(e){return r[e]}}else if(e.isMatrix(r)){var x=r.size();if(1!==x.length||x[0]!==y)throw new Error("Invalid matrix length");o=function(e){return r.get([e])}}else o=function(){return r};i||(i=e.isBigNumber(o(0))?new e.BigNumber(0):0);var w=[];if(t.length>0){w=s.resize(w,t,i);for(var b=0;b<y;b++)w[b+m][b+u]=o(b)}return new d({data:w,size:[v,g]})},d.fromJSON=function(e){return new d(e)},d.prototype.swapRows=function(e,t){if(!(l(e)&&p(e)&&l(t)&&p(t)))throw new Error("Row index must be positive integers");if(2!==this._size.length)throw new Error("Only two dimensional matrix is supported");return m(e,this._size[0]),m(t,this._size[0]),d._swapRows(e,t,this._data),this},d._swapRows=function(e,t,r){var n=r[e];r[e]=r[t],r[t]=n},e.Matrix._storage.dense=d,e.Matrix._storage.default=d,d}var i=r(25),a=r(10),o=(r(13).getSafeProperty,r(13).setSafeProperty,i.string),s=i.array,u=i.object,c=i.number,f=Array.isArray,l=c.isNumber,p=c.isInteger,h=o.isString,m=s.validateIndex;t.name="DenseMatrix",t.path="type",t.factory=n,t.lazy=!1},function(e,t,r){"use strict";function n(e,t,n,o){var s=n(r(0)),u=n(r(15)),c=n(r(26)),f=n(r(16)),l=n(r(8)),p=n(r(6)),h=r(4),m=o("smaller",{"boolean, boolean":function(e,t){return e<t},"number, number":function(e,r){return e<r&&!i(e,r,t.epsilon)},"BigNumber, BigNumber":function(e,r){return e.lt(r)&&!a(e,r,t.epsilon)},"Fraction, Fraction":function(e,t){return e.compare(t)===-1},"Complex, Complex":function(e,t){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return m(e.value,t.value)},"string, string":function(e,t){return e<t},"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=c(e,t,m);break;default:r=u(t,e,m,!0)}break;default:switc
return t=t.toTex(e),a[r]&&(t="\\left("+t+"\\right)"),t});return"OperatorNode:multiply"===this.getIdentifier()&&this.implicit?v.join("~"):v.join(o)}return"\\mathrm{"+this.fn+"}\\left("+n.map(function(t){return t.toTex(e)}).join(",")+"\\right)"},p.prototype.getIdentifier=function(){return this.type+":"+this.fn},p}var i=r(4),a=r(2).map,o=r(2).join,s=r(9).stringify,u=r(9).escape,c=r(13).isSafeMethod,f=r(52);t.name="OperatorNode",t.path="expression.node",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function a(t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!e.isNode(t))throw new TypeError('Node expected for parameter "content"');this.content=t}function o(e,t,r){if(!(e instanceof a))throw new TypeError("No valid ParenthesisNode");return u(e.content,t,r)}var s=n(r(7)).register,u=n(r(7)).compile,c=n(r(14));return a.prototype=new c,a.prototype.type="ParenthesisNode",a.prototype.isParenthesisNode=!0,s(a.prototype.type,o),a.prototype.getContent=function(){return this.content.getContent()},a.prototype.forEach=function(e){e(this.content,"content",this)},a.prototype.map=function(e){var t=e(this.content,"content",this);return new a(t)},a.prototype.clone=function(){return new a(this.content)},a.prototype._toString=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"("+this.content.toString(e)+")":this.content.toString(e)},a.prototype.toHTML=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?'<span class="math-parenthesis math-round-parenthesis">(</span>'+this.content.toHTML(e)+'<span class="math-parenthesis math-round-parenthesis">)</span>':this.content.toHTML(e)},a.prototype._toTex=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"\\left("+this.content.toTex(e)+"\\right)":this.content.toTex(e)},a}t.name="ParenthesisNode",t.path="expression.node",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,f){var l=n(r(0)),p=f("concat",{"...Array | Matrix | number | BigNumber":function(t){var r,n,f=t.length,p=-1,h=!1,m=[];for(r=0;r<f;r++){var d=t[r];if(e.isMatrix(d)&&(h=!0),e.isNumber(d)||e.isBigNumber(d)){if(r!==f-1)throw new Error("Dimension must be specified as last argument");if(n=p,p=d.valueOf(),!o(p))throw new TypeError("Integer number expected for dimension");if(p<0||r>0&&p>n)throw new u(p,n+1)}else{var v=a(d).valueOf(),g=s.size(v);if(m[r]=v,n=p,p=g.length-1,r>0&&p!=n)throw new c(n+1,p+1)}}if(0==m.length)throw new SyntaxError("At least one matrix expected");for(var y=m.shift();m.length;)y=i(y,m.shift(),p,0);return h?l(y):y},"...string":function(e){return e.join("")}});return p.toTex=void 0,p}function i(e,t,r,n){if(n<r){if(e.length!=t.length)throw new c(e.length,t.length);for(var a=[],o=0;o<e.length;o++)a[o]=i(e[o],t[o],r,n+1);return a}return e.concat(t)}var a=r(5).clone,o=r(3).isInteger,s=r(2),u=r(51),c=r(10);t.name="concat",t.factory=n},function(e,t,r){"use strict";function n(e,t,r){var a,o,s,u;if(t<=0){if(Array.isArray(e[0])){for(u=i(e),o=[],a=0;a<u.length;a++)o[a]=n(u[a],t-1,r);return o}for(s=e[0],a=1;a<e.length;a++)s=r(s,e[a]);return s}for(o=[],a=0;a<e.length;a++)o[a]=n(e[a],t-1,r);return o}function i(e){var t,r,n=e.length,i=e[0].length,a=[];for(r=0;r<i;r++){var o=[];for(t=0;t<n;t++)o.push(e[t][r]);a.push(o)}return a}var a=r(2).size,o=r(58),s=r(51);e.exports=function(e,t,r){var i=Array.isArray(e)?a(e):e.size();if(t<0||t>=i.length)throw new s(t,i.length);return o(e)?e.create(n(e.valueOf(),t,r)):n(e,t,r)}},function(e,t,r){"use strict";var n=r(46);e.exports=function(e){for(var t=0;t<e.length;t++)if(n(e[t]))return!0;return!1}},function(e,t,r){"use strict";function n(e,t,n,o){var s=r(4),u=n(r(0)),c=e.DenseMatrix,f=e.SparseMatrix,l=o("transpose",{Array:function(e){return l(u(e)).valueOf()},Matrix:function(e){var t,r=e.size();switch(r.length){case 1:t=e.clone();break;case 2:var n=r[0],i=r[1];if(0===i)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+a(r)+")");switch(e.storage()){case"dense":t=p(e,n,i);break;case"sparse":t=h(e,n,i)}break;default:throw new RangeError("Matrix must be a
e[r[0]]=t}),e},a.prototype.valueOf=function(){return this.toArray()},a.prototype.format=function(e){var t=i.format(this.start,e);return 1!=this.step&&(t+=":"+i.format(this.step,e)),t+=":"+i.format(this.end,e)},a.prototype.toString=function(){return this.format()},a.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},a.fromJSON=function(e){return new a(e.start,e.end,e.step)},a}var i=r(3);t.name="Range",t.path="type",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){function i(e){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");this.entries=e||[]}return i.prototype.type="ResultSet",i.prototype.isResultSet=!0,i.prototype.valueOf=function(){return this.entries},i.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},i.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},i.fromJSON=function(e){return new i(e.entries)},i}t.name="ResultSet",t.path="type",t.factory=n},function(e,t,r){function n(e){return e[0].precision}var i=r(32).memoize;t.e=i(function(e){return new e(1).exp()},n),t.phi=i(function(e){return new e(1).plus(new e(5).sqrt()).div(2)},n),t.pi=i(function(e){return e.acos(-1)},n),t.tau=i(function(e){return t.pi(e).times(2)},n)},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("fix",{number:function(e){return e>0?Math.floor(e):Math.ceil(e)},Complex:function(t){return new e.Complex(t.re>0?Math.floor(t.re):Math.ceil(t.re),t.im>0?Math.floor(t.im):Math.ceil(t.im))},BigNumber:function(e){return e.isNegative()?e.ceil():e.floor()},Fraction:function(e){return e.s<0?e.ceil():e.floor()},"Array | Matrix":function(e){return i(e,a,!0)}});return a.toTex={1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},a}var i=r(1);t.name="fix",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var c=n(r(0)),f=n(r(11)),l=n(r(38)),p=n(r(17)),h=n(r(16)),m=n(r(6)),d=o("round",{number:Math.round,"number, number":function(e,t){if(!a(t))throw new TypeError(u);if(t<0||t>15)throw new Error("Number of decimals in function round must be in te range of 0-15");return i(e,t)},Complex:function(e){return e.round()},"Complex, number":function(e,t){if(t%1)throw new TypeError(u);return e.round(t)},"Complex, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(u);var r=t.toNumber();return e.round(r)},"number, BigNumber":function(t,r){if(!r.isInteger())throw new TypeError(u);return new e.BigNumber(t).toDecimalPlaces(r.toNumber())},BigNumber:function(e){return e.toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(u);return e.toDecimalPlaces(t.toNumber())},Fraction:function(e){return e.round()},"Fraction, number":function(e,t){if(t%1)throw new TypeError(u);return e.round(t)},"Array | Matrix":function(e){return s(e,d,!0)},"Matrix, number | BigNumber":function(e,t){var r;switch(e.storage()){case"sparse":r=p(e,t,d,!1);break;default:r=m(e,t,d,!1)}return r},"number | Complex | BigNumber, Matrix":function(e,t){if(!f(e,0)){var r;switch(t.storage()){case"sparse":r=h(t,e,d,!0);break;default:r=m(t,e,d,!0)}return r}return l(t.size(),t.storage())},"Array, number | BigNumber":function(e,t){return m(c(e),t,d,!1).valueOf()},"number | Complex | BigNumber, Array":function(e,t){return m(c(t),e,d,!0).valueOf()}});return d.toTex={1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},d}function i(e,t){return parseFloat(o(e,t))}var a=r(3).isInteger,o=r(3).toFixed,s=r(1),u="Number of decimals in function round must be an integer";t.name="round",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("format",{any:i.format,"any, Object | function | number":i.format});return a.toTex=void 0,a}var i=r(9);t.name="format",t.factory=n},function(e,t,r){function n(e,t,n,i){var a={};return a.bignumber=r(192),a.boolean=r(193),a.complex=r(194),a.createUnit=r(195),a.fraction=r(196),a.index=r(197),a.matrix=r(198),a.number=r(199),a.sparse=r(200),a.splitUnit=r(201),a.string=r(202),a.unit=r(203),a.e=r(100),a.E=r(100),a.false=r(204),a.i=r(205),a.Infinity=r(206),a.LN2=r(207),a.LN10=r
var w=d[n],b=v[n];if(n!=g){if(0!=w[g]){for(a=u(l(w[g]),y[g]),i=g;i<r;i++)w[i]=c(w[i],f(a,y[i]));for(i=0;i<r;i++)b[i]=c(b[i],f(a,x[i]))}}else{for(a=y[g],i=g;i<r;i++)w[i]=u(w[i],a);for(i=0;i<r;i++)b[i]=u(b[i],a)}}}return v}var s=n(r(0)),u=n(r(19)),c=n(r(20)),f=n(r(12)),l=n(r(37)),p=n(r(115)),h=n(r(61)),m=a("inv",{"Array | Matrix":function(t){var r=e.isMatrix(t)?t.size():i.array.size(t);switch(r.length){case 1:if(1==r[0])return e.isMatrix(t)?s([u(1,t.valueOf()[0])]):[u(1,t[0])];throw new RangeError("Matrix must be square (size: "+i.string.format(r)+")");case 2:var n=r[0],a=r[1];if(n==a)return e.isMatrix(t)?s(o(t.valueOf(),n,a),t.storage()):o(t,n,a);throw new RangeError("Matrix must be square (size: "+i.string.format(r)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+i.string.format(r)+")")}},any:function(e){return u(1,e)}});return m.toTex={1:"\\left(${args[0]}\\right)^{-1}"},m}var i=r(25);t.name="inv",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function s(e,t,r){if(1==t)return a.clone(e[0][0]);if(2==t)return f(l(e[0][0],e[1][1]),l(e[1][0],e[0][1]));for(var n=function(e){var t,r,n=new Array(e.length),i=0;for(t=1;t<e.length;t++)i=c(i,e[t][t]);for(t=0;t<e.length;t++){for(n[t]=new Array(e.length),n[t][t]=p(i),r=0;r<t;r++)n[t][r]=0;for(r=t+1;r<e.length;r++)n[t][r]=e[t][r];t+1<e.length&&(i=f(i,e[t+1][t+1]))}return n},i=e,o=0;o<t-1;o++)i=l(n(i),e);return t%2==0?p(i[0][0]):i[0][0]}var u=n(r(0)),c=n(r(18)),f=n(r(21)),l=n(r(12)),p=n(r(37)),h=i("det",{any:function(e){return a.clone(e)},"Array | Matrix":function(t){var r;switch(e.isMatrix(t)?r=t.size():Array.isArray(t)?(t=u(t),r=t.size()):r=[],r.length){case 0:return a.clone(t);case 1:if(1==r[0])return a.clone(t.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+o.format(r)+")");case 2:var n=r[0],i=r[1];if(n==i)return s(t.clone().valueOf(),n,i);throw new RangeError("Matrix must be square (size: "+o.format(r)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+o.format(r)+")")}}});return h.toTex={1:"\\det\\left(${args[0]}\\right)"},h}var i=r(25),a=i.object,o=i.string;t.name="det",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,s){function u(e,t){return f(e,t)?e:t}function c(e){var t=void 0;if(i(e,function(e){(void 0===t||f(e,t))&&(t=e)}),void 0===t)throw new Error("Cannot calculate min of an empty array");return t}var f=n(r(44)),l=s("min",{"Array | Matrix":c,"Array | Matrix, number | BigNumber":function(e,t){return a(e,t.valueOf(),u)},"...":function(e){if(o(e))throw new TypeError("Scalar values expected in function min");return c(e)}});return l.toTex="\\min\\left(${args}\\right)",l}var i=r(42),a=r(65),o=r(66);t.name="min",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function a(e){return"Array"===t.matrix?e:p(e)}function o(r,n){var i=l(r);if(!i)throw new SyntaxError('String "'+r+'" is no valid range');var o;return"BigNumber"===t.number?(o=n?f:c,a(o(new e.BigNumber(i.start),new e.BigNumber(i.end),new e.BigNumber(i.step)))):(o=n?u:s,a(o(i.start,i.end,i.step)))}function s(e,t,r){var n=[],i=e;if(r>0)for(;i<t;)n.push(i),i+=r;else if(r<0)for(;i>t;)n.push(i),i+=r;return n}function u(e,t,r){var n=[],i=e;if(r>0)for(;i<=t;)n.push(i),i+=r;else if(r<0)for(;i>=t;)n.push(i),i+=r;return n}function c(e,t,r){var n=[],i=e;if(r.gt(h))for(;i.lt(t);)n.push(i),i=i.plus(r);else if(r.lt(h))for(;i.gt(t);)n.push(i),i=i.plus(r);return n}function f(e,t,r){var n=[],i=e;if(r.gt(h))for(;i.lte(t);)n.push(i),i=i.plus(r);else if(r.lt(h))for(;i.gte(t);)n.push(i),i=i.plus(r);return n}function l(e){var t=e.split(":"),r=t.map(function(e){return Number(e)}),n=r.some(function(e){return isNaN(e)});if(n)return null;switch(r.length){case 2:return{start:r[0],end:r[1],step:1};case 3:return{start:r[0],end:r[2],step:r[1]};default:return null}}var p=n(r(0)),h=new e.BigNumber(0),m=new e.BigNumber(1),d=i("range",{string:o,"string, boolean":o,"number, number":function(e,t){return a(s(e,t,1))},"number, number, number":function(e,t,r){return a(s(e,t,r))},"number, number, boolean":function(e,t,r){return a(r?u(e,t,1):s(e,t,1))
throw new Error("median(A, dim) is not yet supported")},"...":function(e){if(a(e))throw new TypeError("Scalar values expected in function median");return s(e)}}),h=o({"number | BigNumber | Complex | Unit":function(e){return e}}),m=o({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(e,t){return c(u(e,t),2)}});return p.toTex=void 0,p}var i=r(2).flatten,a=(r(65),r(66));t.name="median",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function s(t,r){var n=0,i=0;if(0==t.length)throw new SyntaxError("Function var requires one or more parameters (0 provided)");if(a(t,function(e){n=u(n,e),i++}),0===i)throw new Error("Cannot calculate var of an empty array");var o=l(n,i);switch(n=0,a(t,function(e){var t=c(e,o);n=u(n,f(t,t))}),r){case"uncorrected":return l(n,i);case"biased":return l(n,i+1);case"unbiased":var s=e.isBigNumber(n)?new e.BigNumber(0):0;return 1==i?s:l(n,i-1);default:throw new Error('Unknown normalization "'+r+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}var u=n(r(20)),c=n(r(21)),f=n(r(23)),l=n(r(19)),p=o("variance",{"Array | Matrix":function(e){return s(e,i)},"Array | Matrix, string":s,"...":function(e){return s(e,i)}});return p.toTex="\\mathrm{Var}\\left(${args}\\right)",p}var i="unbiased",a=r(42);t.name="var",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var o=n("acosh",{number:function(r){return r>=1||t.predictable?a(r):r<=-1?new e.Complex(Math.log(Math.sqrt(r*r-1)-r),Math.PI):new e.Complex(r,0).acosh()},Complex:function(e){return e.acosh()},BigNumber:function(e){return e.acosh()},"Array | Matrix":function(e){return i(e,o)}});return o.toTex={1:"\\cosh^{-1}\\left(${args[0]}\\right)"},o}var i=r(1),a=Math.acosh||function(e){return Math.log(Math.sqrt(e*e-1)+e)};t.name="acosh",t.factory=n},function(e,t,r){function n(e){var t=i.create(e);return t.create=n,t.import(r(156)),t}var i=r(149);e.exports=n()},function(e,t,r){e.exports=r(150)},function(e,t,r){var n=r(5).isFactory,i=r(151),a=r(90),o=r(154),s=r(155);t.create=function(e){function t(e){if(!n(e))throw new Error("Factory object with properties `type`, `name`, and `factory` expected");var i,a=r.indexOf(e);return a===-1?(i=e.math===!0?e.factory(c.type,f,t,c.typed,c):e.factory(c.type,f,t,c.typed),r.push(e),u.push(i)):i=u[a],i}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=[],u=[],c=a.mixin({});c.type={},c.expression={transform:{},mathWithTransform:{}},c.typed=i.create(c.type);var f={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};return c.import=t(o),c.config=t(s),c.expression.mathWithTransform.config=c.config,e&&c.config(e),c}},function(e,t,r){var n=r(152),i=r(3).digits,a=r(71),o=r(58),s=function(){return s=n.create,n};t.create=function(e){e.isNumber=function(e){return"number"==typeof e},e.isComplex=function(t){return e.Complex&&t instanceof e.Complex||!1},e.isBigNumber=a,e.isFraction=function(t){return e.Fraction&&t instanceof e.Fraction||!1},e.isUnit=function(e){return e&&e.constructor.prototype.isUnit||!1},e.isString=function(e){return"string"==typeof e},e.isArray=Array.isArray,e.isMatrix=o,e.isDenseMatrix=function(e){return e&&e.isDenseMatrix&&e.constructor.prototype.isMatrix||!1},e.isSparseMatrix=function(e){return e&&e.isSparseMatrix&&e.constructor.prototype.isMatrix||!1},e.isRange=function(e){return e&&e.constructor.prototype.isRange||!1},e.isIndex=function(e){return e&&e.constructor.prototype.isIndex||!1},e.isBoolean=function(e){return"boolean"==typeof e},e.isResultSet=function(e){return e&&e.constructor.prototype.isResultSet||!1},e.isHelp=function(e){return e&&e.constructor.prototype.isHelp||!1},e.isFunction=function(e){return"function"==typeof e},e.isDate=function(e){return e instanceof Date},e.isRegExp=function(e){return e instanceof RegExp},e.isObject=function(e){return"object"==typeof e},e.isNull=function(e){return null===e},e.isUndefined=function(e){return void 0===e},e.isAccessorNode=function(e){return
v=f(x.times(x),m,1),i=c=1}l=p,i+=2}}function N(e){return String(e.s*e.s/0)}function E(e,t){var r,n,i;for((r=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),n=0;48===t.charCodeAt(n);n++);for(i=t.length;48===t.charCodeAt(i-1);--i);if(t=t.slice(n,i)){if(i-=n,e.e=r=r-n-1,e.d=[],n=(r+1)%Be,r<0&&(n+=Be),n<i){for(n&&e.d.push(+t.slice(0,n)),i-=Be;n<i;)e.d.push(+t.slice(n,n+=Be));t=t.slice(n),n=Be-t.length}else n-=i;for(;n--;)t+="0";e.d.push(+t),Ne&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function M(e,t){var r,n,i,a,o,s,c,f,l;if("Infinity"===t||"NaN"===t)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(Ce.test(t))r=16,t=t.toLowerCase();else if(Se.test(t))r=2;else{if(!ze.test(t))throw Error(Me+t);r=8}for(a=t.search(/p/i),a>0?(c=+t.slice(a+1),t=t.substring(2,a)):t=t.slice(2),a=t.indexOf("."),o=a>=0,n=e.constructor,o&&(t=t.replace(".",""),s=t.length,a=s-a,i=g(n,new n(r),a,2*a)),f=u(t,r,Ie),l=f.length-1,a=l;0===f[a];--a)f.pop();return a<0?new n(0*e.s):(e.e=p(f,l),e.d=f,Ne=!1,o&&(e=Le(e,i,4*s)),c&&(e=e.times(Math.abs(c)<54?Math.pow(2,c):be.pow(2,c))),Ne=!0,e)}function A(e,t){var r,n=t.d.length;if(n<3)return O(e,2,t,t);r=1.4*Math.sqrt(n),r=r>16?16:0|r,t=t.times(Math.pow(5,-r)),t=O(e,2,t,t);for(var i,a=new e(5),o=new e(16),s=new e(20);r--;)i=t.times(t),t=t.times(a.plus(i.times(o.times(i).minus(s))));return t}function O(e,t,r,n,i){var a,o,s,u,c=1,f=e.precision,l=Math.ceil(f/Be);for(Ne=!1,u=r.times(r),s=new e(n);;){if(o=Le(s.times(u),new e(t++*t++),f,1),s=i?n.plus(o):n.minus(o),n=Le(o.times(u),new e(t++*t++),f,1),o=s.plus(n),void 0!==o.d[l]){for(a=l;o.d[a]===s.d[a]&&a--;);if(a==-1)break}a=s,s=n,n=o,o=a,c++}return Ne=!0,o.d.length=l+1,o}function T(e,t){var r,n=t.s<0,i=m(e,e.precision,1),a=i.times(.5);if(t=t.abs(),t.lte(a))return de=n?4:1,t;if(r=t.divToInt(i),r.isZero())de=n?3:2;else{if(t=t.minus(r.times(i)),t.lte(a))return de=y(r)?n?2:3:n?4:1,t;de=y(r)?n?1:4:n?3:2}return t.minus(i).abs()}function _(e,t,r,n){var i,a,s,c,f,p,h,m,d,v=e.constructor,g=void 0!==r;if(g?(o(r,1,ge),void 0===n?n=v.rounding:o(n,0,8)):(r=v.precision,n=v.rounding),e.isFinite()){for(h=l(e),s=h.indexOf("."),g?(i=2,16==t?r=4*r-3:8==t&&(r=3*r-2)):i=t,s>=0&&(h=h.replace(".",""),d=new v(1),d.e=h.length-s,d.d=u(l(d),10,i),d.e=d.d.length),m=u(h,10,i),a=f=m.length;0==m[--f];)m.pop();if(m[0]){if(s<0?a--:(e=new v(e),e.d=m,e.e=a,e=Le(e,d,r,n,0,i),m=e.d,a=e.e,p=me),s=m[r],c=i/2,p=p||void 0!==m[r+1],p=n<4?(void 0!==s||p)&&(0===n||n===(e.s<0?3:2)):s>c||s===c&&(4===n||p||6===n&&1&m[r-1]||n===(e.s<0?8:7)),m.length=r,p)for(;++m[--r]>i-1;)m[r]=0,r||(++a,m.unshift(1));for(f=m.length;!m[f-1];--f);for(s=0,h="";s<f;s++)h+=ye.charAt(m[s]);if(g){if(f>1)if(16==t||8==t){for(s=16==t?4:3,--f;f%s;f++)h+="0";for(m=u(h,i,t),f=m.length;!m[f-1];--f);for(s=1,h="1.";s<f;s++)h+=ye.charAt(m[s])}else h=h.charAt(0)+"."+h.slice(1);h=h+(a<0?"p":"p+")+a}else if(a<0){for(;++a;)h="0"+h;h="0."+h}else if(++a>f)for(a-=f;a--;)h+="0";else a<f&&(h=h.slice(0,a)+"."+h.slice(a))}else h=g?"0p+0":"0";h=(16==t?"0x":2==t?"0b":8==t?"0o":"")+h}else h=N(e);return e.s<0?"-"+h:h}function S(e,t){if(e.length>t)return e.length=t,!0}function C(e){return new this(e).abs()}function z(e){return new this(e).acos()}function k(e){return new this(e).acosh()}function I(e,t){return new this(e).plus(t)}function B(e){return new this(e).asin()}function P(e){return new this(e).asinh()}function R(e){return new this(e).atan()}function U(e){return new this(e).atanh()}function q(e,t){e=new this(e),t=new this(t);var r,n=this.precision,i=this.rounding,a=n+4;return e.s&&t.s?e.d||t.d?!t.d||e.isZero()?(r=t.s<0?m(this,n,i):new this(0),r.s=e.s):!e.d||t.isZero()?(r=m(this,a,1).times(.5),r.s=e.s):t.s<0?(this.precision=a,this.rounding=1,r=this.atan(Le(e,t,a,1)),t=m(this,a,1),this.precision=n,this.rounding=i,r=e.s<0?r.minus(t):r.plus(t)):r=this.atan(Le(e,t,a,1)):(r=m(this,a,1).times(t.s>0?.25:.75),r.s=e.s):r=new this(NaN),r}function L(e){return new this(e).cbrt()}function j(e){return f(e=new this(e),e.e+1,2)}func
* @license Complex.js v2.0.3 11/02/2016
*
* Copyright (c) 2016, Robert Eisele (robert@xarg.org)
* Dual licensed under the MIT or GPL Version 2 licenses.
**/
!function(r){"use strict";function a(e,t){var r=Math.abs(e),n=Math.abs(t);return 0===e?Math.log(n):0===t?Math.log(r):r<3e3&&n<3e3?.5*Math.log(e*e+t*t):Math.log(e/Math.cos(Math.atan2(t,e)))}function o(e,t){return this instanceof o?(p(e,t),this.re=s.re,void(this.im=s.im)):new o(e,t)}var s={re:0,im:0},u=function(e){return.5*(Math.exp(e)+Math.exp(-e))},c=function(e){return.5*(Math.exp(e)-Math.exp(-e))},f=function(e,t){var r=Math.abs(e),n=Math.abs(t);return r<3e3&&n<3e3?Math.sqrt(r*r+n*n):(r<n?(r=n,n=e/t):n=t/e,r*Math.sqrt(1+n*n))},l=function(){throw SyntaxError("Invalid Param")},p=function(e,t){if(void 0===e||null===e)s.re=s.im=0;else if(void 0!==t)s.re=e,s.im=t;else switch(typeof e){case"object":"im"in e&&"re"in e?(s.re=e.re,s.im=e.im):"abs"in e&&"arg"in e?(s.re=e.abs*Math.cos(e.arg),s.im=e.abs*Math.sin(e.arg)):"r"in e&&"phi"in e?(s.re=e.r*Math.cos(e.phi),s.im=e.r*Math.sin(e.phi)):2===e.length?(s.re=e[0],s.im=e[1]):l();break;case"string":s.im=s.re=0;var r=e.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),n=1,i=0;null===r&&l();for(var a=0;a<r.length;a++){var o=r[a];" "===o||"\t"===o||"\n"===o||("+"===o?n++:"-"===o?i++:"i"===o||"I"===o?(n+i===0&&l()," "===r[a+1]||isNaN(r[a+1])?s.im+=parseFloat((i%2?"-":"")+"1"):(s.im+=parseFloat((i%2?"-":"")+r[a+1]),a++),n=i=0):((n+i===0||isNaN(o))&&l(),"i"===r[a+1]||"I"===r[a+1]?(s.im+=parseFloat((i%2?"-":"")+o),a++):s.re+=parseFloat((i%2?"-":"")+o),n=i=0))}n+i>0&&l();break;case"number":s.im=0,s.re=e;break;default:l()}isNaN(s.re)||isNaN(s.im)};o.prototype={re:0,im:0,sign:function(){var e=this.abs();return new o(this.re/e,this.im/e)},add:function(e,t){return p(e,t),new o(this.re+s.re,this.im+s.im)},sub:function(e,t){return p(e,t),new o(this.re-s.re,this.im-s.im)},mul:function(e,t){return p(e,t),0===s.im&&0===this.im?new o(this.re*s.re,0):new o(this.re*s.re-this.im*s.im,this.re*s.im+this.im*s.re)},div:function(e,t){p(e,t),e=this.re,t=this.im;var r,n,i=s.re,a=s.im;return 0===a?0===i?new o(0!==e?e/0:0,0!==t?t/0:0):new o(e/i,t/i):Math.abs(i)<Math.abs(a)?(n=i/a,r=i*n+a,new o((e*n+t)/r,(t*n-e)/r)):(n=a/i,r=a*n+i,new o((e+t*n)/r,(t-e*n)/r))},pow:function(e,t){if(p(e,t),e=this.re,t=this.im,0===e&&0===t)return o.ZERO;if(0===s.im){if(0===t&&e>=0)return new o(Math.pow(e,s.re),0);if(0===e)switch((s.re%4+4)%4){case 0:return new o(Math.pow(t,s.re),0);case 1:return new o(0,Math.pow(t,s.re));case 2:return new o(-Math.pow(t,s.re),0);case 3:return new o(0,-Math.pow(t,s.re))}}var r=Math.atan2(t,e),n=a(e,t);return e=Math.exp(s.re*n-s.im*r),t=s.im*n+s.re*r,new o(e*Math.cos(t),e*Math.sin(t))},sqrt:function(){var e,t,r=this.re,n=this.im,i=this.abs();if(r>=0){if(0===n)return new o(Math.sqrt(r),0);e=.5*Math.sqrt(2*(i+r))}else e=Math.abs(n)/Math.sqrt(2*(i-r));return t=r<=0?.5*Math.sqrt(2*(i-r)):Math.abs(n)/Math.sqrt(2*(i+r)),new o(e,n<0?-t:t)},exp:function(){var e=Math.exp(this.re);return 0===this.im,new o(e*Math.cos(this.im),e*Math.sin(this.im))},log:function(){var e=this.re,t=this.im;return new o(a(e,t),Math.atan2(t,e))},abs:function(){return f(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var e=this.re,t=this.im;return new o(Math.sin(e)*u(t),Math.cos(e)*c(t))},cos:function(){var e=this.re,t=this.im;return new o(Math.cos(e)*u(t),-Math.sin(e)*c(t))},tan:function(){var e=2*this.re,t=2*this.im,r=Math.cos(e)+u(t);return new o(Math.sin(e)/r,c(t)/r)},cot:function(){var e=2*this.re,t=2*this.im,r=Math.cos(e)-u(t);return new o(-Math.sin(e)/r,c(t)/r)},sec:function(){var e=this.re,t=this.im,r=.5*u(2*t)+.5*Math.cos(2*e);return new o(Math.cos(e)*u(t)/r,Math.sin(e)*c(t)/r)},csc:function(){var e=this.re,t=this.im,r=.5*u(2*t)-.5*Math.cos(2*e);return new o(Math.sin(e)*u(t)/r,-Math.cos(e)*c(t)/r)},asin:function(){var e=this.re,t=this.im,r=new o(t*t-e*e+1,-2*e*t).sqrt(),n=new o(r.re-t,r.im+e).log();return new o(n.im,-n.re)},acos:function(){var e=this.re,t=this.im,r=new o(t*t-e*e+1,-2*e*t).sqrt(),n=new o(r.re-t,r.im+e).log();return new o(Math.PI/2-n.im,n.re)},atan:function(){var e=this.re,t=this.im;if(0===e){if(1===t)return new o(0,1/0);if(t===-1)return new o(0,-(1/0))}var r=e*e+(1-t)*(1-t),n=new o
* @license Fraction.js v4.0.2 09/09/2015
* http://www.xarg.org/2014/03/rational-numbers-in-javascript/
*
* Copyright (c) 2015, Robert Eisele (robert@xarg.org)
* Dual licensed under the MIT or GPL Version 2 licenses.
**/
!function(r){"use strict";function a(e){var t=function(){var t=Error.apply(this,arguments);t.name=this.name=e,this.stack=t.stack,this.message=t.message},r=function(){};return r.prototype=Error.prototype,t.prototype=new r,t}function o(e,t){return isNaN(e=parseInt(e,10))&&s(),e*t}function s(){throw new p}function u(e,t){return this instanceof u?(h(e,t),e=u.REDUCE?g(f.d,f.n):1,this.s=f.s,this.n=f.n/e,void(this.d=f.d/e)):new u(e,t)}var c=2e3,f={s:1,n:0,d:1},l=u.DivisionByZero=a("DivisionByZero"),p=u.InvalidParameter=a("InvalidParameter"),h=function(e,t){var r,n=0,i=1,a=1,u=0,c=0,p=0,h=1,m=1,d=0,v=1,g=1,y=1,x=1e7;if(void 0===e||null===e);else if(void 0!==t)n=e,i=t,a=n*i;else switch(typeof e){case"object":"d"in e&&"n"in e?(n=e.n,i=e.d,"s"in e&&(n*=e.s)):0 in e?(n=e[0],1 in e&&(i=e[1])):s(),a=n*i;break;case"number":if(e<0&&(a=e,e=-e),e%1===0)n=e;else if(e>0){for(e>=1&&(m=Math.pow(10,Math.floor(1+Math.log(e)/Math.LN10)),e/=m);v<=x&&y<=x;){if(r=(d+g)/(v+y),e===r){v+y<=x?(n=d+g,i=v+y):y>v?(n=g,i=y):(n=d,i=v);break}e>r?(d+=g,v+=y):(g+=d,y+=v),v>x?(n=g,i=y):(n=d,i=v)}n*=m}else(isNaN(e)||isNaN(t))&&(i=n=NaN);break;case"string":if(v=e.match(/\d+|./g),"-"===v[d]?(a=-1,d++):"+"===v[d]&&d++,v.length===d+1?c=o(v[d++],a):"."===v[d+1]||"."===v[d]?("."!==v[d]&&(u=o(v[d++],a)),d++,(d+1===v.length||"("===v[d+1]&&")"===v[d+3]||"'"===v[d+1]&&"'"===v[d+3])&&(c=o(v[d],a),h=Math.pow(10,v[d].length),d++),("("===v[d]&&")"===v[d+2]||"'"===v[d]&&"'"===v[d+2])&&(p=o(v[d+1],a),m=Math.pow(10,v[d+1].length)-1,d+=3)):"/"===v[d+1]||":"===v[d+1]?(c=o(v[d],a),h=o(v[d+2],1),d+=3):"/"===v[d+3]&&" "===v[d+1]&&(u=o(v[d],a),c=o(v[d+2],a),h=o(v[d+4],1),d+=5),v.length<=d){i=h*m,a=n=p+i*u+m*c;break}default:s()}if(0===i)throw new l;f.s=a<0?-1:1,f.n=Math.abs(n),f.d=Math.abs(i)},m=function(e,t,r){for(var n=1;t>0;e=e*e%r,t>>=1)1&t&&(n=n*e%r);return n},d=function(e,t){for(;t%2===0;t/=2);for(;t%5===0;t/=5);if(1===t)return 0;for(var r=10%t,n=1;1!==r;n++)if(r=10*r%t,n>c)return 0;return n},v=function(e,t,r){for(var n=1,i=m(10,r,t),a=0;a<300;a++){if(n===i)return a;n=10*n%t,i=10*i%t}return 0},g=function(e,t){if(!e)return t;if(!t)return e;for(;;){if(e%=t,!e)return t;if(t%=e,!t)return e}};u.REDUCE=1,u.prototype={s:1,n:0,d:1,abs:function(){return new u(this.n,this.d)},neg:function(){return new u(-this.s*this.n,this.d)},add:function(e,t){return h(e,t),new u(this.s*this.n*f.d+f.s*this.d*f.n,this.d*f.d)},sub:function(e,t){return h(e,t),new u(this.s*this.n*f.d-f.s*this.d*f.n,this.d*f.d)},mul:function(e,t){return h(e,t),new u(this.s*f.s*this.n*f.n,this.d*f.d)},div:function(e,t){return h(e,t),new u(this.s*f.s*this.n*f.d,this.d*f.n)},clone:function(){return new u(this)},mod:function(e,t){return isNaN(this.n)||isNaN(this.d)?new u(NaN):void 0===e?new u(this.s*this.n%this.d,1):(h(e,t),0===f.n&&0===this.d&&u(0,0),new u(this.s*f.d*this.n%(f.n*this.d),f.d*this.d))},gcd:function(e,t){return h(e,t),new u(g(f.n,this.n),f.d*this.d/g(f.d,this.d))},lcm:function(e,t){return h(e,t),0===f.n&&0===this.n?new u:new u(f.n*this.n/g(f.n,this.n),g(f.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new u(NaN):new u(Math.ceil(e*this.s*this.n/this.d),e)},floor:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new u(NaN):new u(Math.floor(e*this.s*this.n/this.d),e)},round:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new u(NaN):new u(Math.round(e*this.s*this.n/this.d),e)},inverse:function(){return new u(this.s*this.d,this.n)},pow:function(e){return e<0?new u(Math.pow(this.s*this.d,-e),Math.pow(this.n,-e)):new u(Math.pow(this.s*this.n,e),Math.pow(this.d,e))},equals:function(e,t){return h(e,t),this.s*this.n*f.d===f.s*f.n*this.d},compare:function(e,t){h(e,t);var r=this.s*this.n*f.d-f.s*f.n*this.d;return(0<r)-(r<0)},divisible:function(e,t){return h(e,t),!(!(f.n*this.d)||this.n*f.d%(f.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(e){var t,r="",n=this.n,i=this.d;return this.s<0&&(r+="-"),1===i?r+=n:(e&&(t=Math.floor(n/i))>0&&(r+=t,r+=" ",n%=i),r+=n,r+="/",r+=i),r},toLatex:function(e){var t,r="",n=this.n,i=this.d
return this.format()},c.prototype.toJSON=function(){return{mathjs:"Unit",value:this._denormalize(this.value),unit:this.formatUnits(),fixPrefix:this.fixPrefix}},c.fromJSON=function(e){var t=new c(e.value,e.unit);return t.fixPrefix=e.fixPrefix||!1,t},c.prototype.valueOf=c.prototype.toString,c.prototype.simplifyUnitListLazy=function(){if(!this.isUnitListSimplified&&null!=this.value){var e,t=[];for(var r in W)if(this.hasBase(D[r])){e=r;break}if("NONE"===e)this.units=[];else{var n;e&&W.hasOwnProperty(e)&&(n=W[e]);if(n)this.units=[{unit:n.unit,prefix:n.prefix,power:1}];else{for(var i=!1,a=0;a<F.length;a++){var o=F[a];Math.abs(this.dimensions[a]||0)>1e-12&&(W.hasOwnProperty(o)?t.push({unit:W[o].unit,prefix:W[o].prefix,power:this.dimensions[a]||0}):i=!0)}t.length<this.units.length&&!i&&(this.units=t)}}this.isUnitListSimplified=!0}},c.prototype.toSI=function(){for(var e=this.clone(),t=[],r=0;r<F.length;r++){var n=F[r];if(Math.abs(e.dimensions[r]||0)>1e-12){if(!V.si.hasOwnProperty(n))throw new Error("Cannot express custom unit "+n+" in SI units");t.push({unit:V.si[n].unit,prefix:V.si[n].prefix,power:e.dimensions[r]||0})}}return e.units=t,e.isUnitListSimplified=!0,e},c.prototype.formatUnits=function(){this.simplifyUnitListLazy();for(var e="",t="",r=0,n=0,i=0;i<this.units.length;i++)this.units[i].power>0?(r++,e+=" "+this.units[i].prefix.name+this.units[i].unit.name,Math.abs(this.units[i].power-1)>1e-15&&(e+="^"+this.units[i].power)):this.units[i].power<0&&n++;if(n>0)for(var i=0;i<this.units.length;i++)this.units[i].power<0&&(r>0?(t+=" "+this.units[i].prefix.name+this.units[i].unit.name,Math.abs(this.units[i].power+1)>1e-15&&(t+="^"+-this.units[i].power)):(t+=" "+this.units[i].prefix.name+this.units[i].unit.name,t+="^"+this.units[i].power));e=e.substr(1),t=t.substr(1),r>1&&n>0&&(e="("+e+")"),n>1&&r>0&&(t="("+t+")");var a=e;return r>0&&n>0&&(a+=" / "),a+=t},c.prototype.format=function(t){this.simplifyUnitListLazy();var r=!1,n=!0;"undefined"!=typeof this.value&&null!==this.value&&e.isComplex(this.value)&&(r=Math.abs(this.value.re)<1e-14,n=Math.abs(this.value.im)<1e-14);for(var i in this.units)this.units[i].unit&&("VA"===this.units[i].unit.name&&r?this.units[i].unit=G.VAR:"VAR"!==this.units[i].unit.name||r||(this.units[i].unit=G.VA));1!==this.units.length||this.fixPrefix||Math.abs(this.units[0].power-Math.round(this.units[0].power))<1e-14&&(this.units[0].prefix=this._bestPrefix());var a=this._denormalize(this.value),o=null!==this.value?z(a,t||{}):"",s=this.formatUnits();return this.value&&e.isComplex(this.value)&&(o="("+o+")"),s.length>0&&o.length>0&&(o+=" "),o+=s},c.prototype._bestPrefix=function(){if(1!==this.units.length)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");if(Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var e=O(this.value),t=O(this.units[0].unit.value),r=this.units[0].prefix;if(0===e)return r;var n=this.units[0].power,i=Math.log(e/Math.pow(r.value*t,n))/Math.LN10-1.2;if(i>-2.200001&&i<1.800001)return r;i=Math.abs(i);var a=this.units[0].unit.prefixes;for(var o in a)if(a.hasOwnProperty(o)){var s=a[o];if(s.scientific){var u=Math.abs(Math.log(e/Math.pow(s.value*t,n))/Math.LN10-1.2);(u<i||u===i&&s.name.length<r.name.length)&&(r=s,i=u)}}return r},c.prototype.splitUnit=function(e){for(var t=this.clone(),r=[],n=0;n<e.length&&(t=t.to(e[n]),n!=e.length-1);n++){var i,a=t.toNumeric(),o=_(a),s=S(o,a);i=s?o:T(t.toNumeric());var u=new c(i,e[n].toString());r.push(u),t=N(t,u)}for(var f=0,n=0;n<r.length;n++)f=b(f,r[n].value);return S(f,this.value)&&(t.value=0),r.push(t),r};var L={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
return o("5.67037321e-8 W m^-2 K^-4")}),i(a,"wienDisplacement",function(){return o("2.897772126e-3 m K")}),i(a,"molarMass",function(){return o("1e-3 kg mol^-1")}),i(a,"molarMassC12",function(){return o("1.2e-2 kg mol^-1")}),i(a,"gravity",function(){return o("9.80665 m s^-2")}),i(a,"planckLength",function(){return o("1.61619997e-35 m")}),i(a,"planckMass",function(){return o("2.1765113e-8 kg")}),i(a,"planckTime",function(){return o("5.3910632e-44 s")}),i(a,"planckCharge",function(){return o("1.87554595641e-18 C")}),i(a,"planckTemperature",function(){return o("1.41683385e+32 K")})}function i(e,t,r){a(e,t,r),a(e.expression.mathWithTransform,t,r)}var a=r(5).lazy;t.factory=n,t.lazy=!1,t.math=!0},function(e,t,r){"use strict";function n(e,t,o,u,c){c.on("config",function(r,i){r.number!==i.number&&n(e,t,o,u,c)}),i(c,"true",!0),i(c,"false",!1),i(c,"null",null),i(c,"uninitialized",r(2).UNINITIALIZED),"BigNumber"===t.number?(i(c,"Infinity",new e.BigNumber(1/0)),i(c,"NaN",new e.BigNumber(NaN)),a(c,"pi",function(){return s.pi(e.BigNumber)}),a(c,"tau",function(){return s.tau(e.BigNumber)}),a(c,"e",function(){return s.e(e.BigNumber)}),a(c,"phi",function(){return s.phi(e.BigNumber)}),a(c,"E",function(){return c.e}),a(c,"LN2",function(){return new e.BigNumber(2).ln()}),a(c,"LN10",function(){return new e.BigNumber(10).ln()}),a(c,"LOG2E",function(){return new e.BigNumber(1).div(new e.BigNumber(2).ln())}),a(c,"LOG10E",function(){return new e.BigNumber(1).div(new e.BigNumber(10).ln())}),a(c,"PI",function(){return c.pi}),a(c,"SQRT1_2",function(){return new e.BigNumber("0.5").sqrt()}),a(c,"SQRT2",function(){return new e.BigNumber(2).sqrt()})):(i(c,"Infinity",1/0),i(c,"NaN",NaN),i(c,"pi",Math.PI),i(c,"tau",2*Math.PI),i(c,"e",Math.E),i(c,"phi",1.618033988749895),i(c,"E",c.e),i(c,"LN2",Math.LN2),i(c,"LN10",Math.LN10),i(c,"LOG2E",Math.LOG2E),i(c,"LOG10E",Math.LOG10E),i(c,"PI",c.pi),i(c,"SQRT1_2",Math.SQRT1_2),i(c,"SQRT2",Math.SQRT2)),i(c,"i",e.Complex.I),i(c,"version",r(190))}function i(e,t,r){e[t]=r,e.expression.mathWithTransform[t]=r}function a(e,t,r){o.lazy(e,t,r),o.lazy(e.expression.mathWithTransform,t,r)}var o=r(5),s=r(95);t.factory=n,t.lazy=!1,t.math=!0},function(e,t){e.exports="3.17.0"},function(e,t,r){e.exports=[r(99),r(383),r(389),r(391),r(402),r(39),r(111)]},function(e,t){e.exports={name:"bignumber",category:"Construction",syntax:["bignumber(x)"],description:"Create a big number from a number or string.",examples:["0.1 + 0.2","bignumber(0.1) + bignumber(0.2)",'bignumber("7.2")','bignumber("7.2e500")',"bignumber([0.1, 0.2, 0.3])"],seealso:["boolean","complex","fraction","index","matrix","string","unit"]}},function(e,t){e.exports={name:"boolean",category:"Construction",syntax:["x","boolean(x)"],description:"Convert a string or number into a boolean.",examples:["boolean(0)","boolean(1)","boolean(3)",'boolean("true")','boolean("false")',"boolean([1, 0, 1, 1])"],seealso:["bignumber","complex","index","matrix","number","string","unit"]}},function(e,t){e.exports={name:"complex",category:"Construction",syntax:["complex()","complex(re, im)","complex(string)"],description:"Create a complex number.",examples:["complex()","complex(2, 3)",'complex("7 - 2i")'],seealso:["bignumber","boolean","index","matrix","number","string","unit"]}},function(e,t){e.exports={name:"createUnit",category:"Construction",syntax:["createUnit(definitions)","createUnit(name, definition)"],description:"Create a user-defined unit and register it with the Unit type.",examples:['createUnit("foo")','createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})','createUnit("mph", "1 mile/hour")'],seealso:["unit","splitUnit"]}},function(e,t){e.exports={name:"fraction",category:"Construction",syntax:["fraction(num)","fraction(num,den)"],description:"Create a fraction from a number or from a numerator and denominator.",examples:["fraction(0.125)","fraction(1, 3) + fraction(2, 5)"],seealso:["bignumber","boolean","complex","index","matrix","string","unit"]}},function(e,t){e.exports={name:"index",category:"Construction",syntax:["[start]","[start:end]","[start:
}},function(e,t){e.exports={name:"flatten",category:"Matrix",syntax:["flatten(x)"],description:"Flatten a multi dimensional matrix into a single dimensional matrix.",examples:["a = [1, 2, 3; 4, 5, 6]","size(a)","b = flatten(a)","size(b)"],seealso:["concat","resize","size","squeeze"]}},function(e,t){e.exports={name:"forEach",category:"Matrix",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:["forEach([1, 2, 3], function(val) { console.log(val) })"],seealso:["map","sort","filter"]}},function(e,t){e.exports={name:"inv",category:"Matrix",syntax:["inv(x)"],description:"Calculate the inverse of a matrix",examples:["inv([1, 2; 3, 4])","inv(4)","1 / 4"],seealso:["concat","det","diag","eye","ones","range","size","squeeze","subset","trace","transpose","zeros"]}},function(e,t){e.exports={name:"kron",category:"Matrix",syntax:["kron(x, y)"],description:"Calculates the kronecker product of 2 matrices or vectors.",examples:["kron([[1, 0], [0, 1]], [[1, 2], [3, 4]])","kron([1,1], [2,3,4])"],seealso:["multiply","dot","cross"]}},function(e,t){e.exports={name:"map",category:"Matrix",syntax:["map(x, callback)"],description:"Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.",examples:["map([1, 2, 3], square)"],seealso:["filter","forEach"]}},function(e,t){e.exports={name:"ones",category:"Matrix",syntax:["ones(m)","ones(m, n)","ones(m, n, p, ...)","ones([m])","ones([m, n])","ones([m, n, p, ...])"],description:"Create a matrix containing ones.",examples:["ones(3)","ones(3, 5)","ones([2,3]) * 4.5","a = [1, 2, 3; 4, 5, 6]","ones(size(a))"],seealso:["concat","det","diag","eye","inv","range","size","squeeze","subset","trace","transpose","zeros"]}},function(e,t){e.exports={name:"partitionSelect",category:"Matrix",syntax:["partitionSelect(x, k)","partitionSelect(x, k, compare)"],description:"Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.",examples:["partitionSelect([5, 10, 1], 2)",'partitionSelect(["C", "B", "A", "D"], 1)'],seealso:["sort"]}},function(e,t){e.exports={name:"range",category:"Type",syntax:["start:end","start:step:end","range(start, end)","range(start, end, step)","range(string)"],description:"Create a range. Lower bound of the range is included, upper bound is excluded.",examples:["1:5","3:-1:-3","range(3, 7)","range(0, 12, 2)",'range("4:10")',"a = [1, 2, 3, 4; 5, 6, 7, 8]","a[1:2, 1:2]"],seealso:["concat","det","diag","eye","inv","ones","size","squeeze","subset","trace","transpose","zeros"]}},function(e,t){e.exports={name:"resize",category:"Matrix",syntax:["resize(x, size)","resize(x, size, defaultValue)"],description:"Resize a matrix.",examples:["resize([1,2,3,4,5], [3])","resize([1,2,3], [5])","resize([1,2,3], [5], -1)","resize(2, [2, 3])",'resize("hello", [8], "!")'],seealso:["size","subset","squeeze","reshape"]}},function(e,t){e.exports={name:"reshape",category:"Matrix",syntax:["reshape(x, sizes)"],description:"Reshape a multi dimensional array to fit the specified dimensions.",examples:["reshape([1, 2, 3, 4, 5, 6], [2, 3])","reshape([[1, 2], [3, 4]], [1, 4])","reshape([[1, 2], [3, 4]], [4])"],seealso:["size","squeeze","resize"]}},function(e,t){e.exports={name:"size",category:"Matrix",syntax:["size(x)"],description:"Calculate the size of a matrix.",examples:["size(2.3)",'size("hello world")',"a = [1, 2; 3, 4; 5, 6]","size(a)","size(1:6)"],seealso:["concat","det","diag","eye","inv","ones","range","squeeze","subset","trace","transpose","zeros"]}},function(e,t){e.exports={name:"sort",category:"Matrix",syntax:["sort(x)","sort(x, compare)"],description:'Sort the items in a matrix. Compare can be a string "asc", "desc", "natural", or a custom sort function.',examples:["sort([5, 10, 1])",'sort(["C", "B", "A", "D"])',"sortByLength(a, b) = size(a)[1] - size(b)[1]",'sort(["Langdon", "Tom", "Sara"], sortByLength)','sort(["10", "1", "2"], "natural")'],seealso:["map","filter","forEach"]}},function(e,t){
function i(){throw new Error("UpdateNode is deprecated. Use AssignmentNode instead.")}return i}t.name="UpdateNode",t.path="expression.node",t.factory=n},function(e,t,r){e.exports=[r(392),r(393),r(394),r(395),r(396),r(397),r(398),r(399),r(400),r(401)]},function(e,t,r){"use strict";function n(e,t,n,a){var o=n(r(64));return a("concat",{"...any":function(t){var r=t.length-1,n=t[r];e.isNumber(n)?t[r]=n-1:e.isBigNumber(n)&&(t[r]=n.minus(1));try{return o.apply(null,t)}catch(e){throw i(e)}}})}var i=r(41).transform;t.name="concat",t.path="expression.transform",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){function s(t,r,n){var i,a;return t[0]&&(i=t[0].compile().eval(n)),t[1]&&(a=e.isSymbolNode(t[1])||e.isFunctionAssignmentNode(t[1])?t[1].compile().eval(n):u(t[1],r,n)),f(i,a)}var u=n(r(81)),c=n(r(0));s.rawArgs=!0;var f=a("filter",{"Array, function":i,"Matrix, function":function(e,t){return c(i(e.toArray(),t))},"Array, RegExp":o,"Matrix, RegExp":function(e,t){return c(o(e.toArray(),t))}});return f.toTex=void 0,s}function i(e,t){var r=s(t);return a(e,function(e,n,i){return 1===r?t(e):2===r?t(e,[n+1]):t(e,[n+1],i)})}var a=r(2).filter,o=r(2).filterRegExp,s=r(32).maxArgumentCount;t.name="filter",t.path="expression.transform",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function s(t,r,n){var i,a;return t[0]&&(i=t[0].compile().eval(n)),t[1]&&(a=e.isSymbolNode(t[1])||e.isFunctionAssignmentNode(t[1])?t[1].compile().eval(n):u(t[1],r,n)),c(i,a)}var u=n(r(81));s.rawArgs=!0;var c=o("forEach",{"Array | Matrix, function":function(e,t){var r=i(t),n=function(i,o){Array.isArray(i)?a(i,function(e,t){n(e,o.concat(t+1))}):1===r?t(i):2===r?t(i,o):t(i,o,e)};n(e.valueOf(),[])}});return s}var i=r(32).maxArgumentCount,a=r(2).forEach;t.name="forEach",t.path="expression.transform",t.factory=n},function(e,t,r){"use strict";function n(e,t,r){return function(){for(var t=[],r=0,n=arguments.length;r<n;r++){var i=arguments[r];if(e.isRange(i))i.start--,i.end-=i.step>0?0:2;else if(i&&i.isSet===!0)i=i.map(function(e){return e-1});else if(e.isArray(i)||e.isMatrix(i))i=i.map(function(e){return e-1});else if(e.isNumber(i))i--;else if(e.isBigNumber(i))i=i.toNumber()-1;else if("string"!=typeof i)throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");t[r]=i}var a=new e.Index;return e.Index.apply(a,t),a}}t.name="index",t.path="expression.transform",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){function o(t,r,n){var i,a;return t[0]&&(i=t[0].compile().eval(n)),t[1]&&(a=e.isSymbolNode(t[1])||e.isFunctionAssignmentNode(t[1])?t[1].compile().eval(n):s(t[1],r,n)),c(i,a)}var s=n(r(81)),u=n(r(0));o.rawArgs=!0;var c=a("map",{"Array, function":function(e,t){return i(e,t,e)},"Matrix, function":function(e,t){return u(i(e.valueOf(),t,e))}});return o}function i(e,t,r){function n(e,a){return Array.isArray(e)?o(e,function(e,t){return n(e,a.concat(t+1))}):1===i?t(e):2===i?t(e,a):t(e,a,r)}var i=a(t);return n(e,[])}var a=r(32).maxArgumentCount,o=r(2).map;t.name="map",t.path="expression.transform",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var s=n(r(112));return o("max",{"...any":function(t){if(2==t.length&&a(t[0])){var r=t[1];e.isNumber(r)?t[1]=r-1:e.isBigNumber(r)&&(t[1]=r.minus(1))}try{return s.apply(null,t)}catch(e){throw i(e)}}})}var i=r(41).transform,a=r(46);t.name="max",t.path="expression.transform",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var s=n(r(113));return o("mean",{"...any":function(t){if(2==t.length&&a(t[0])){var r=t[1];e.isNumber(r)?t[1]=r-1:e.isBigNumber(r)&&(t[1]=r.minus(1))}try{return s.apply(null,t)}catch(e){throw i(e)}}})}var i=r(41).transform,a=r(46);t.name="mean",t.path="expression.transform",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var s=n(r(116));return o("min",{"...any":function(t){if(2==t.length&&a(t[0])){var r=t[1];e.isNumber(r)?t[1]=r-1:e.isBigNumber(r)&&(t[1]=r.minus(1))}try{return s.apply(null,t)}catch(e){throw i(e)}}})}var i=r(41).transform,a=r(46);t.name="min",t.path="expression.transform",t.factory=n},function(e,t,r){"u
},Unit:u,"Array | Matrix":function(e){return i(e,p,!0)}});return p.toTex={1:"\\sqrt[3]{${args[0]}}"},p}var i=r(1),a=Math.cbrt||function(e){if(0===e)return e;var t,r=e<0;return r&&(e=-e),isFinite(e)?(t=Math.exp(Math.log(e)/3),t=(e/(t*t)+2*t)/3):t=e,r?-t:t};t.name="cbrt",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("ceil",{number:Math.ceil,Complex:function(e){return e.ceil()},BigNumber:function(e){return e.ceil()},Fraction:function(e){return e.ceil()},"Array | Matrix":function(e){return i(e,a,!0)}});return a.toTex={1:"\\left\\lceil${args[0]}\\right\\rceil"},a}var i=r(1);t.name="ceil",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("cube",{number:function(e){return e*e*e},Complex:function(e){return e.mul(e).mul(e)},BigNumber:function(e){return e.times(e).times(e)},Fraction:function(e){return e.pow(3)},"Array | Matrix":function(e){return i(e,a,!0)},Unit:function(e){return e.pow(3)}});return a.toTex={1:"\\left(${args[0]}\\right)^3"},a}var i=r(1);t.name="cube",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(0)),o=n(r(23)),s=r(4),u=n(r(24)),c=n(r(133)),f=n(r(17)),l=n(r(8)),p=n(r(6)),h=i("dotMultiply",{"any, any":o,"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=c(e,t,o,!1);break;default:r=u(t,e,o,!0)}break;default:switch(t.storage()){case"sparse":r=u(e,t,o,!1);break;default:r=l(e,t,o)}}return r},"Array, Array":function(e,t){return h(a(e),a(t)).valueOf()},"Array, Matrix":function(e,t){return h(a(e),t)},"Matrix, Array":function(e,t){return h(e,a(t))},"Matrix, any":function(e,t){var r;switch(e.storage()){case"sparse":r=f(e,t,o,!1);break;default:r=p(e,t,o,!1)}return r},"any, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":r=f(t,e,o,!0);break;default:r=p(t,e,o,!0)}return r},"Array, any":function(e,t){return p(a(e),t,o,!1).valueOf()},"any, Array":function(e,t){return p(a(t),e,o,!0).valueOf()}});return h.toTex={2:"\\left(${args[0]}"+s.operators.dotMultiply+"${args[1]}\\right)"},h}t.name="dotMultiply",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(0)),o=n(r(45)),s=r(4),u=n(r(15)),c=n(r(26)),f=n(r(17)),l=n(r(16)),p=n(r(8)),h=n(r(6)),m=i("dotPow",{"any, any":o,"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=c(e,t,o,!1);break;default:r=u(t,e,o,!0)}break;default:switch(t.storage()){case"sparse":r=u(e,t,o,!1);break;default:r=p(e,t,o)}}return r},"Array, Array":function(e,t){return m(a(e),a(t)).valueOf()},"Array, Matrix":function(e,t){return m(a(e),t)},"Matrix, Array":function(e,t){return m(e,a(t))},"Matrix, any":function(e,t){var r;switch(e.storage()){case"sparse":r=f(e,t,m,!1);break;default:r=h(e,t,m,!1)}return r},"any, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":r=l(t,e,m,!0);break;default:r=h(t,e,m,!0)}return r},"Array, any":function(e,t){return h(a(e),t,m,!1).valueOf()},"any, Array":function(e,t){return h(a(t),e,m,!0).valueOf()}});return m.toTex={2:"\\left(${args[0]}"+s.operators.dotPow+"${args[1]}\\right)"},m}t.name="dotPow",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("exp",{number:Math.exp,Complex:function(e){return e.exp()},BigNumber:function(e){return e.exp()},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\exp\\left(${args[0]}\\right)"},a}var i=r(1);t.name="exp",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("floor",{number:Math.floor,Complex:function(e){return e.floor()},BigNumber:function(e){return e.floor()},Fraction:function(e){return e.floor()},"Array | Matrix":function(e){return i(e,a,!0)}});return a.toTex={1:"\\left\\lfloor${args[0]}\\right\\rfloor"},a}var i=r(1);t.name="floor",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){function o(t,r){if(!t.isInt()||!r.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var n=new e.BigNumber(0);!r.isZero();){var i=t.mod(r);t=r,r=i}return t.lt(n)?t.neg():t}var s=n(r(0)),u=n(r(33)),c=n(r(73)),f=n(r(36)),l=n(r(8)),p=n(r(6)),h=a("gcd",{"num
if(e.hasOwnProperty("pointX")&&e.hasOwnProperty("pointY")&&t.hasOwnProperty("lineOnePtX")&&t.hasOwnProperty("lineOnePtY")&&r.hasOwnProperty("lineTwoPtX")&&r.hasOwnProperty("lineTwoPtY")){var n=(r.lineTwoPtY-r.lineTwoPtX)/(t.lineOnePtY-t.lineOnePtX),a=n*n*t.lineOnePtX,o=-1*(n*t.lineOnePtX),s=e.pointX;return c(e.pointX,e.pointY,a,o,s)}throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},"Array, Array":function(e,t){if(2==e.length&&3==t.length){if(!i(e))throw new TypeError("Array with 2 numbers expected for first argument");if(!a(t))throw new TypeError("Array with 3 numbers expected for second argument");return c(e[0],e[1],t[0],t[1],t[2])}if(3==e.length&&6==t.length){if(!a(e))throw new TypeError("Array with 3 numbers expected for first argument");if(!o(t))throw new TypeError("Array with 6 numbers expected for second argument");return f(e[0],e[1],e[2],t[0],t[1],t[2],t[3],t[4],t[5])}if(2==e.length&&2==t.length){if(!i(e))throw new TypeError("Array with 2 numbers expected for first argument");if(!i(t))throw new TypeError("Array with 2 numbers expected for second argument");return l(e[0],e[1],t[0],t[1])}if(3==e.length&&3==t.length){if(!a(e))throw new TypeError("Array with 3 numbers expected for first argument");if(!a(t))throw new TypeError("Array with 3 numbers expected for second argument");return p(e[0],e[1],e[2],t[0],t[1],t[2])}throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(e,t){if(2==Object.keys(e).length&&3==Object.keys(t).length){if(!i(e))throw new TypeError("Values of pointX and pointY should be numbers");if(!a(t))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers");if(e.hasOwnProperty("pointX")&&e.hasOwnProperty("pointY")&&t.hasOwnProperty("xCoeffLine")&&t.hasOwnProperty("yCoeffLine")&&t.hasOwnProperty("yCoeffLine"))return c(e.pointX,e.pointY,t.xCoeffLine,t.yCoeffLine,t.constant);throw new TypeError("Key names do not match")}if(3==Object.keys(e).length&&6==Object.keys(t).length){if(!a(e))throw new TypeError("Values of pointX, pointY and pointZ should be numbers");if(!o(t))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers");if(e.hasOwnProperty("pointX")&&e.hasOwnProperty("pointY")&&t.hasOwnProperty("x0")&&t.hasOwnProperty("y0")&&t.hasOwnProperty("z0")&&t.hasOwnProperty("a")&&t.hasOwnProperty("b")&&t.hasOwnProperty("c"))return f(e.pointX,e.pointY,e.pointZ,t.x0,t.y0,t.z0,t.a,t.b,t.c);throw new TypeError("Key names do not match")}if(2==Object.keys(e).length&&2==Object.keys(t).length){if(!i(e))throw new TypeError("Values of pointOneX and pointOneY should be numbers");if(!i(t))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers");if(e.hasOwnProperty("pointOneX")&&e.hasOwnProperty("pointOneY")&&t.hasOwnProperty("pointTwoX")&&t.hasOwnProperty("pointTwoY"))return l(e.pointOneX,e.pointOneY,t.pointTwoX,t.pointTwoY);throw new TypeError("Key names do not match")}if(3==Object.keys(e).length&&3==Object.keys(t).length){if(!a(e))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers");if(!a(t))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers");if(e.hasOwnProperty("pointOneX")&&e.hasOwnProperty("pointOneY")&&e.hasOwnProperty("pointOneZ")&&t.hasOwnProperty("pointTwoX")&&t.hasOwnProperty("pointTwoY")&&t.hasOwnProperty("pointTwoZ"))return p(e.pointOneX,e.pointOneY,e.pointOneZ,t.pointTwoX,t.pointTwoY,t.pointTwoZ);throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},Array:function(e){if(!u(e))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return h(e)}}));return m}function i(e){return e.constructor!==Array&&(e=s(e)),"number"==typeof e[0]&&"number"==typeof e[1]}function a(e){return e.constructor!==Array&&(e=s(e)),"number"==typeof e[0]&&"number"==typeof e[1]&&"number"==typeof e[2]}function o(e){return e.constructor!==Array&&(e=s(e)),"number"==typeof e[0]&&"number"==typeof e[1]&&"number"==typeof e[2]&&"number"==typeof e[3]&&"number"==type
return o}}if(Array.isArray(r)){o=new Array(r.length);for(var p=0;p<o.length;++p){var m=r[p];if(a(m)){if(m<0||m>1)throw new Error("Probability must be between 0 and 1, inclusive")}else{if(!e.isBigNumber(m))throw new TypeError("Unexpected type of argument in function quantileSeq");if(c=new m.constructor(1),m.isNegative()||m.gt(c))throw new Error("Probability must be between 0 and 1, inclusive")}o[p]=f(u,m,n)}return o}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}function f(e,t,r){var n=o(e),i=n.length;if(0===i)throw new Error("Cannot calculate quantile of an empty sequence");if(a(t)){var s=t*(i-1),u=s%1;if(0===u){var c=r?n[s]:h(n,s);return d(c),c}var f,v,g=Math.floor(s);if(r)f=n[g],v=n[g+1];else{v=h(n,g+1),f=n[g];for(var y=0;y<g;++y)m(n[y],f)>0&&(f=n[y])}return d(f),d(v),l(p(f,1-u),p(v,u))}var s=t.times(i-1);if(s.isInteger()){s=s.toNumber();var c=r?n[s]:h(n,s);return d(c),c}var f,v,g=s.floor(),u=s.minus(g),x=g.toNumber();if(r)f=n[x],v=n[x+1];else{v=h(n,x+1),f=n[x];for(var y=0;y<x;++y)m(n[y],f)>0&&(f=n[y])}d(f),d(v);var w=new u.constructor(1);return l(p(f,w.minus(u)),p(v,u))}var l=n(r(18)),p=n(r(12)),h=n(r(88)),m=n(r(49)),d=u({"number | BigNumber | Unit":function(e){return e}});return c}var i=r(3).isInteger,a=r(3).isNumber,o=r(2).flatten,s=r(46);t.name="quantileSeq",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function a(e,t){if(0==e.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");return o(s.apply(null,arguments))}var o=n(r(56)),s=n(r(146)),u=i("std",{"Array | Matrix":a,"Array | Matrix, string":a,"...":function(e){return a(e)}});return u.toTex=void 0,u}t.name="std",t.factory=n},function(e,t,r){e.exports=[r(98),r(515)]},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("print",{"string, Object":i,"string, Object, number | Object":i});return a.toTex=void 0,a}function i(e,t,r){return e.replace(/\$([\w\.]+)/g,function(e,n){for(var i=n.split("."),s=t[i.shift()];i.length&&void 0!==s;){var u=i.shift();s=u?s[u]:s+"."}return void 0!==s?a(s)?s:o(s,r):e})}var a=r(9).isString,o=r(9).format;t.name="print",t.factory=n},function(e,t,r){e.exports=[r(517),r(147),r(518),r(519),r(520),r(521),r(522),r(523),r(524),r(525),r(526),r(527),r(528),r(529),r(530),r(531),r(532),r(533),r(534),r(535),r(536),r(537),r(538),r(539),r(540)]},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("acos",{number:function(r){return r>=-1&&r<=1||t.predictable?Math.acos(r):new e.Complex(r,0).acos()},Complex:function(e){return e.acos()},BigNumber:function(e){return e.acos()},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\cos^{-1}\\left(${args[0]}\\right)"},a}var i=r(1);t.name="acos",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("acot",{number:function(e){return Math.atan(1/e)},Complex:function(e){return e.acot()},BigNumber:function(t){return new e.BigNumber(1).div(t).atan()},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\cot^{-1}\\left(${args[0]}\\right)"},a}var i=r(1);t.name="acot",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("acoth",{number:function(r){return r>=1||r<=-1||t.predictable?isFinite(r)?(Math.log((r+1)/r)+Math.log(r/(r-1)))/2:0:new e.Complex(r,0).acoth()},Complex:function(e){return e.acoth()},BigNumber:function(t){return new e.BigNumber(1).div(t).atanh()},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\coth^{-1}\\left(${args[0]}\\right)"},a}var i=r(1);t.name="acoth",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("acsc",{number:function(r){return r<=-1||r>=1||t.predictable?Math.asin(1/r):new e.Complex(r,0).acsc()},Complex:function(e){return e.acsc()},BigNumber:function(t){return new e.BigNumber(1).div(t).asin()},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\csc^{-1}\\left(${args[0]}\\right)"},a}var i=r(1);t.name="acsc",t.factory=n},function(e,t,r){"use stric
//# sourceMappingURL=math.map