/** * 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 7.1.0 * @date 2020-07-13 * * @license * Copyright (C) 2013-2020 Jos de Jong * * 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 * * https://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 n={},i.m=r=[function(e,t,r){"use strict";r.d(t,"a",function(){return n}),r.d(t,"b",function(){return i}),r.d(t,"c",function(){return o});r(2);var a=r(3);function n(r,n,i,e){function t(e){var t=Object(a.j)(e,n.map(o));return function(e,t,r){if(!t.filter(function(e){return!((t=e)&&"?"===t[0]);var t}).every(function(e){return void 0!==r[e]})){var n=t.filter(function(e){return void 0===r[e]});throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(n.map(function(e){return'"'.concat(e,'"')}).join(", "),"."))}}(r,n,e),i(t)}return t.isFactory=!0,t.fn=r,t.dependencies=n.slice().sort(),e&&(t.meta=e),t}function i(e){return"function"==typeof e&&"string"==typeof e.fn&&Array.isArray(e.dependencies)}function o(e){return e&&"?"===e[0]?e.slice(1):e}},function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e){return"number"==typeof e}function a(e){return e&&!0===e.constructor.prototype.isBigNumber||!1}function o(e){return e&&"object"===n(e)&&!0===Object.getPrototypeOf(e).isComplex||!1}function s(e){return e&&"object"===n(e)&&!0===Object.getPrototypeOf(e).isFraction||!1}function u(e){return e&&!0===e.constructor.prototype.isUnit||!1}function c(e){return"string"==typeof e}r.d(t,"y",function(){return i}),r.d(t,"e",function(){return a}),r.d(t,"j",function(){return o}),r.d(t,"o",function(){return s}),r.d(t,"L",function(){return u}),r.d(t,"I",function(){return c}),r.d(t,"b",function(){return f}),r.d(t,"v",function(){return l}),r.d(t,"i",function(){return p}),r.d(t,"n",function(){return m}),r.d(t,"H",function(){return h}),r.d(t,"D",function(){return d}),r.d(t,"t",function(){return y}),r.d(t,"g",function(){return g}),r.d(t,"G",function(){return v}),r.d(t,"s",function(){return b}),r.d(t,"p",function(){return x}),r.d(t,"m",function(){return w}),r.d(t,"F",function(){return N}),r.d(t,"z",function(){return O}),r.d(t,"x",function(){return M}),r.d(t,"K",function(){return j}),r.d(t,"a",function(){return E}),r.d(t,"c",function(){return S}),r.d(t,"d",function(){return A}),r.d(t,"f",function(){return C}),r.d(t,"k",function(){return T}),r.d(t,"l",function(){return _}),r.d(t,"q",function(){return q}),r.d(t,"r",function(){return I}),r.d(t,"u",function(){return k}),r.d(t,"w",function(){return B}),r.d(t,"A",function(){return z}),r.d(t,"B",function(){return D}),r.d(t,"C",function(){return R}),r.d(t,"E",function(){return P}),r.d(t,"J",function(){return U}),r.d(t,"h",function(){return F}),r.d(t,"M",function(){return L});var f=Array.isArray;function l(e){return e&&!0===e.constructor.prototype.isMatrix||!1}function p(e){return Array.isArray(e)||l(e)}function m(e){return e&&e.isDenseMatrix&&!0===e.constructor.prototype.isMatrix||!1}function h(e){return e&&e.isSparseMatrix&&!0===e.constructor.prototype.isMatrix||!1}function d(e){return e&&!0===e.constructor.prototype.isRange||!1}function y(e){return e&&!0===e.constructor.prototype.isIndex||!1}function g(e){return"boolean"==typeof e}function v(e){return e&&!0===e.constructor.prototype.isResultSet||!1}function b(e){return e&&!0===e.constructor.prototype.isHelp||!1}function x(e){return"function"==typeof e}function w(e){return e instanceof Date}function N(e){return e instanceof RegExp}function O(e){return!(!e||"object"!==n(e)||e.constructor!==Object||o(e)||s(e))}function M(e){return null===e}function j(e){return void 0===e}function E(e){return e&&!0===e.isAccessorNode&&!0===e.constructor.prototype.isNode||!1}function S(e){return e&&!0===e.isArrayNode&&!0===e.constructor.prototype.isNode||!1}function A(e){return e&&!0===e.isAssignmentNode&&!0===e.constructor.prototype.isNode||!1}function C(e){return e&&!0===e.isBlockNode&&!0===e.constructor.prototype.isNode||!1}function T(e){return e&&!0===e.isConditionalNode&&!0===e.constructor.prototype.isNode||!1}function _(e){return e&&!0===e.isConstantNode&&!0===e.constructor.prototype.isNode||!1}function q(e){return e&&!0===e.isFunctionAssignmentNode&&!0===e.constructor.prototype.isNode||!1}function I(e){return e&&!0===e.isFunctionNode&&!0===e.constructor.prototype.isNode||!1}function k(e){return e&&!0===e.isIndexNode&&!0===e.constructor.prototype.isNode||!1}function B(e){return e&&!0===e.isNode&&!0===e.constructor.prototype.isNode||!1}function z(e){return e&&!0===e.isObjectNode&&!0===e.constructor.prototype.isNode||!1}function D(e){return e&&!0===e.isOperatorNode&&!0===e.constructor.prototype.isNode||!1}function R(e){return e&&!0===e.isParenthesisNode&&!0===e.constructor.prototype.isNode||!1}function P(e){return e&&!0===e.isRangeNode&&!0===e.constructor.prototype.isNode||!1}function U(e){return e&&!0===e.isSymbolNode&&!0===e.constructor.prototype.isNode||!1}function F(e){return e&&!0===e.constructor.prototype.isChain||!1}function L(e){var t=n(e);return"object"===t?null===e?"null":Array.isArray(e)?"Array":e instanceof Date?"Date":e instanceof RegExp?"RegExp":a(e)?"BigNumber":o(e)?"Complex":s(e)?"Fraction":l(e)?"Matrix":u(e)?"Unit":y(e)?"Index":d(e)?"Range":v(e)?"ResultSet":B(e)?e.type:F(e)?"Chain":b(e)?"Help":"Object":"function"===t?"Function":t}},function(e,t,r){"use strict";r.d(t,"a",function(){return s}),r.d(t,"p",function(){return c}),r.d(t,"q",function(){return f}),r.d(t,"m",function(){return l}),r.d(t,"l",function(){return p}),r.d(t,"n",function(){return m}),r.d(t,"o",function(){return h}),r.d(t,"e",function(){return d}),r.d(t,"k",function(){return y}),r.d(t,"f",function(){return g}),r.d(t,"c",function(){return v}),r.d(t,"d",function(){return b}),r.d(t,"j",function(){return x}),r.d(t,"i",function(){return w}),r.d(t,"g",function(){return N}),r.d(t,"h",function(){return O}),r.d(t,"b",function(){return M});var n=r(4),i=r(1),a=r(5),u=r(6),o=r(9);function s(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function c(e,t){if(0===t.length){if(Array.isArray(e))throw new u.a(e.length,0)}else!function e(t,r,n){var i=t.length;if(i!==r[n])throw new u.a(i,r[n]);if(n")}(e,t,0)}function f(e,t){if(!Object(i.y)(e)||!Object(n.i)(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||"number"==typeof t&&t<=e)throw new o.a(e,t)}function l(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");return t.forEach(function(e){if(!Object(i.y)(e)||!Object(n.i)(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Object(a.d)(t)+")")}),function e(t,r,n,i){var a;var o;var s=t.length;var u=r[n];var c=Math.min(s,u);t.length=u;if(ni.length||n-a+1>i.length;)i.push(0);else for(var o=Math.abs(n-a)-(i.length-1),s=0;s=i)return p(e,t);var s=o.coefficients,u=o.exponent;s.lengtht&&5<=n.splice(t,n.length-t)[0]){var i=t-1;for(n[i]++;10===n[i];)n.pop(),0===i&&(n.unshift(0),r.exponent++,i++),n[--i]++}return r}function y(e){for(var t=[],r=0;r/g,">")}function p(e,t){if(!Object(n.I)(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+Object(n.M)(e)+", index: 0)");if(!Object(n.I)(t))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+Object(n.M)(t)+", index: 1)");return e===t?0:t=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=(new Error).stack}r.d(t,"a",function(){return n}),(n.prototype=new RangeError).constructor=RangeError,n.prototype.name="IndexError",n.prototype.isIndexError=!0},function(r,i,e){var a; /** * @license Fraction.js v4.0.12 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(){"use strict";var d={s:1,n:0,d:1};function e(t){function e(){var e=Error.apply(this,arguments);e.name=this.name=t,this.stack=e.stack,this.message=e.message}function r(){}return r.prototype=Error.prototype,e.prototype=new r,e}var y=f.DivisionByZero=e("DivisionByZero"),t=f.InvalidParameter=e("InvalidParameter");function g(e,t){return isNaN(e=parseInt(e,10))&&v(),e*t}function v(){throw new t}var n=function(e,t){var r,n=0,i=1,a=1,o=0,s=0,u=0,c=1,f=1,l=0,p=1,m=1,h=1;if(null!=e)if(void 0!==t)a=(n=e)*(i=t);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])):v(),a=n*i;break;case"number":if(e<0&&(e=-(a=e)),e%1==0)n=e;else if(0>=1)1&t&&(n=n*e%r);return n}(10,r,t),a=0;a<300;a++){if(n===i)return a;n=10*n%t,i=10*i%t}return 0}function c(e,t){if(!e)return t;if(!t)return e;for(;;){if(!(e%=t))return t;if(!(t%=e))return e}}function f(e,t){if(!(this instanceof f))return new f(e,t);n(e,t),e=f.REDUCE?c(d.d,d.n):1,this.s=d.s,this.n=d.n/e,this.d=d.d/e}f.REDUCE=1,f.prototype={s:1,n:0,d:1,abs:function(){return new f(this.n,this.d)},neg:function(){return new f(-this.s*this.n,this.d)},add:function(e,t){return n(e,t),new f(this.s*this.n*d.d+d.s*this.d*d.n,this.d*d.d)},sub:function(e,t){return n(e,t),new f(this.s*this.n*d.d-d.s*this.d*d.n,this.d*d.d)},mul:function(e,t){return n(e,t),new f(this.s*d.s*this.n*d.n,this.d*d.d)},div:function(e,t){return n(e,t),new f(this.s*d.s*this.n*d.d,this.d*d.n)},clone:function(){return new f(this)},mod:function(e,t){return isNaN(this.n)||isNaN(this.d)?new f(NaN):void 0===e?new f(this.s*this.n%this.d,1):(n(e,t),0===d.n&&0===this.d&&f(0,0),new f(this.s*(d.d*this.n)%(d.n*this.d),d.d*this.d))},gcd:function(e,t){return n(e,t),new f(c(d.n,this.n)*c(d.d,this.d),d.d*this.d)},lcm:function(e,t){return n(e,t),0===d.n&&0===this.n?new f:new f(d.n*this.n,c(d.n,this.n)*c(d.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new f(NaN):new f(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 f(NaN):new f(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 f(NaN):new f(Math.round(e*this.s*this.n/this.d),e)},inverse:function(){return new f(this.s*this.d,this.n)},pow:function(e){return e<0?new f(Math.pow(this.s*this.d,-e),Math.pow(this.n,-e)):new f(Math.pow(this.s*this.n,e),Math.pow(this.d,e))},equals:function(e,t){return n(e,t),this.s*this.n*d.d==d.s*d.n*this.d},compare:function(e,t){n(e,t);var r=this.s*this.n*d.d-d.s*d.n*this.d;return(03?e.slice(3):"any";var i=n.split("|").map(O).filter(M).filter(N);var a=b(r,i);var o=i.map(function(e){var t=u(e);return{name:e,typeIndex:c(t),test:t.test,conversion:null,conversionIndex:-1}});var s=a.map(function(e){var t=u(e.from);return{name:e.from,typeIndex:c(t),test:t.test,conversion:e,conversionIndex:r.indexOf(e)}});return{types:o.concat(s),restParam:t}}function H(e,t,i){var r=[];if(e.trim()!==""){r=e.split(",").map(O).map(function(e,t,r){var n=o(e,i);if(n.restParam&&t!==r.length-1){throw new SyntaxError('Unexpected rest parameter "'+e+'": '+"only allowed for the last parameter")}return n})}if(r.some(j)){return null}return{params:r,fn:t}}function $(e){var t=S(e);return t?t.restParam:false}function s(e){return e.types.some(function(e){return e.conversion!=null})}function G(e){if(!e||e.types.length===0){return k}else if(e.types.length===1){return u(e.types[0].name).test}else if(e.types.length===2){var r=u(e.types[0].name).test;var n=u(e.types[1].name).test;return function e(t){return r(t)||n(t)}}else{var i=e.types.map(function(e){return u(e.name).test});return function e(t){for(var r=0;r=a+1}}else{if(e.length===0){return function e(t){return t.length===0}}else if(e.length===1){r=G(e[0]);return function e(t){return r(t[0])&&t.length===1}}else if(e.length===2){r=G(e[0]);i=G(e[1]);return function e(t){return r(t[0])&&i(t[1])&&t.length===2}}else{n=e.map(G);return function e(t){for(var r=0;r0){var c=p(r[s]);n=new TypeError("Unexpected type of argument in function "+a+" (expected: "+i.join(" or ")+", actual: "+c+", index: "+s+")");n.data={category:"wrongType",fn:a,index:s,actual:c,expected:i};return n}}else{o=u}}var f=o.map(function(e){return $(e.params)?Infinity:e.params.length});if(r.lengthl){n=new TypeError("Too many arguments in function "+a+" (expected: "+l+", actual: "+r.length+")");n.data={category:"tooManyArgs",fn:a,index:r.length,expectedLength:l};return n}n=new TypeError('Arguments of type "'+r.join(", ")+'" do not match any of the defined signatures of function '+a+".");n.data={category:"mismatch",actual:r.map(p)};return n}function y(e){var t=999;for(var r=0;r=o:c?o>=s:o===s}function w(r,t){if(Object.keys(t).length===0){throw new SyntaxError("No signatures provided")}var n=[];Object.keys(t).map(function(e){return H(e,t[e],F.conversions)}).filter(K).forEach(function(t){var e=ee(n,function(e){return Q(e,t)});if(e){throw new TypeError('Conflicting signatures "'+L(e.params)+'" and "'+L(t.params)+'".')}n.push(t)});var i=te(n,function(t){var e=t?X(t.params,false):[];return e.map(function(e){return{params:e,fn:t.fn}})}).filter(K);i.sort(J);var e=i[0]&&i[0].params.length<=2&&!$(i[0].params);var a=i[1]&&i[1].params.length<=2&&!$(i[1].params);var o=i[2]&&i[2].params.length<=2&&!$(i[2].params);var s=i[3]&&i[3].params.length<=2&&!$(i[3].params);var u=i[4]&&i[4].params.length<=2&&!$(i[4].params);var c=i[5]&&i[5].params.length<=2&&!$(i[5].params);var f=e&&a&&o&&s&&u&&c;var l=i.map(function(e){return Z(e.params)});var p=e?G(i[0].params[0]):re;var m=a?G(i[1].params[0]):re;var h=o?G(i[2].params[0]):re;var d=s?G(i[3].params[0]):re;var y=u?G(i[4].params[0]):re;var g=c?G(i[5].params[0]):re;var v=e?G(i[0].params[1]):re;var b=a?G(i[1].params[1]):re;var x=o?G(i[2].params[1]):re;var w=s?G(i[3].params[1]):re;var N=u?G(i[4].params[1]):re;var O=c?G(i[5].params[1]):re;var M=i.map(function(e){return W(e.params,e.fn)});var j=e?M[0]:ne;var E=a?M[1]:ne;var S=o?M[2]:ne;var A=s?M[3]:ne;var C=u?M[4]:ne;var T=c?M[5]:ne;var _=e?i[0].params.length:-1;var q=a?i[1].params.length:-1;var I=o?i[2].params.length:-1;var k=s?i[3].params.length:-1;var B=u?i[4].params.length:-1;var z=c?i[5].params.length:-1;var D=f?6:0;var R=i.length;var P=function e(){"use strict";for(var t=D;t>>=1;return(e+r)/t}},m.exports.resetGlobal=function(){Math.random=t},l(Math.random(),i)}).call(this,t(19))},function(t,De,Re){var Pe;!function(){"use strict";var l,T,o,s=9e15,d=1e9,y="0123456789abcdef",n="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",i="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",u={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-s,maxE:s,crypto:!1},b=!0,c="[DecimalError] ",g=c+"Invalid argument: ",a=c+"Precision limit exceeded",f=c+"crypto unavailable",_=Math.floor,v=Math.pow,p=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,m=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,h=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,x=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,q=1e7,I=7,w=n.length-1,N=i.length-1,O={name:"[object Decimal]"};function M(e){var t,r,n,i=e.length-1,a="",o=e[0];if(0r-1&&(void 0===a[n+1]&&(a[n+1]=0),a[n+1]+=a[n]/r|0,a[n]%=r)}return a.reverse()}O.absoluteValue=O.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),D(e)},O.ceil=function(){return D(new this.constructor(this),this.e+1,2)},O.comparedTo=O.cmp=function(e){var t,r,n,i,a=this,o=a.d,s=(e=new a.constructor(e)).d,u=a.s,c=e.s;if(!o||!s)return u&&c?u!==c?u:o===s?0:!o^u<0?1:-1:NaN;if(!o[0]||!s[0])return o[0]?u:s[0]?-c:0;if(u!==c)return u;if(a.e!==e.e)return a.e>e.e^u<0?1:-1;for(t=0,r=(n=o.length)<(i=s.length)?n:i;ts[t]^u<0?1:-1;return n===i?0:ithis.d.length-2},O.isNaN=function(){return!this.s},O.isNegative=O.isNeg=function(){return this.s<0},O.isPositive=O.isPos=function(){return 0t&&(t=this.e+1)):t=NaN,t},O.round=function(){var e=this.constructor;return D(new e(this),this.e+1,e.rounding)},O.sine=O.sin=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+I,n.rounding=1,r=function(e,t){var r,n=t.d.length;if(n<3)return W(e,2,t,t);r=16<(r=1.4*Math.sqrt(n))?16:0|r,t=t.times(1/Y(5,r)),t=W(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}(n,X(n,r)),n.precision=e,n.rounding=t,D(2=e.d.length-1&&(r=c<0?-c:c)<=9007199254740991)return i=H(u,s,r,n),e.s<0?new u(1).div(i):D(i,n,a);if((o=s.s)<0){if(tu.maxE+1||t=n.toExpPos):(j(e,1,d),void 0===t?t=n.rounding:j(t,0,8),C(r=D(new n(r),e,t),e<=r.e||r.e<=n.toExpNeg,e));return r.isNeg()&&!r.isZero()?"-"+i:i},O.toSignificantDigits=O.toSD=function(e,t){var r=this.constructor;return void 0===e?(e=r.precision,t=r.rounding):(j(e,1,d),void 0===t?t=r.rounding:j(t,0,8)),D(new r(this),e,t)},O.toString=function(){var e=this,t=e.constructor,r=C(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+r:r},O.truncated=O.trunc=function(){return D(new this.constructor(this),this.e+1,1)},O.valueOf=O.toJSON=function(){var e=this,t=e.constructor,r=C(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+r:r};var A=function(e,t,r,n,i,a){var o,s,u,c,f,l,p,m,h,d,y,g,v,b,x,w,N,O,M,j,E=e.constructor,S=e.s==t.s?1:-1,A=e.d,C=t.d;if(!(A&&A[0]&&C&&C[0]))return new E(e.s&&t.s&&(A?!C||A[0]!=C[0]:C)?A&&0==A[0]||!C?0*S:S/0:NaN);for(s=a?(f=1,e.e-t.e):(a=q,f=I,_(e.e/f)-_(t.e/f)),M=C.length,N=A.length,d=(h=new E(S)).d=[],u=0;C[u]==(A[u]||0);u++);if(C[u]>(A[u]||0)&&s--,null==r?(b=r=E.precision,n=E.rounding):b=i?r+(e.e-t.e)+1:r,b<0)d.push(1),l=!0;else{if(b=b/f+2|0,u=0,1==M){for(C=C[c=0],b++;(u=a/2&&++O;c=0,(o=B(C,y,M,g))<0?(v=y[0],M!=g&&(v=v*a+(y[1]||0)),1<(c=v/O|0)?(a<=c&&(c=a-1),1==(o=B(p=k(C,c,a),y,m=p.length,g=y.length))&&(c--,z(p,Mt[i]?1:-1;break}return a}function z(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]m.maxE?(e.d=null,e.e=NaN):e.ee.constructor.maxE?(e.d=null,e.e=NaN):e.ei-1;)l[r]=0,r||(++a,l.unshift(1));for(u=l.length;!l[u-1];--u);for(o=0,f="";ou)for(a-=u;a--;)f+="0";else at&&(e.length=t,1)}function K(e){return new this(e).abs()}function ee(e){return new this(e).acos()}function te(e){return new this(e).acosh()}function re(e,t){return new this(e).plus(t)}function ne(e){return new this(e).asin()}function ie(e){return new this(e).asinh()}function ae(e){return new this(e).atan()}function oe(e){return new this(e).atanh()}function se(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?U(this,n,i):new this(0)).s=e.s:!e.d||t.isZero()?(r=U(this,a,1).times(.5)).s=e.s:r=t.s<0?(this.precision=a,this.rounding=1,r=this.atan(A(e,t,a,1)),t=U(this,a,1),this.precision=n,this.rounding=i,e.s<0?r.minus(t):r.plus(t)):this.atan(A(e,t,a,1)):(r=U(this,a,1).times(0a.maxE?(i.e=NaN,i.d=null):e.e=e.length&&o.slice(0,e.length)===e&&(s+=u[c[t]],o=o.slice(e.length,o.length),r=!0)}),r||(s+=o.slice(0,1),o=o.slice(1,o.length))}();return s}},function(e,t){function r(){}r.prototype={on:function(e,t,r){var n=this.e||(this.e={});return(n[e]||(n[e]=[])).push({fn:t,ctx:r}),this},once:function(e,t,r){var n=this;function i(){n.off(e,i),t.apply(r,arguments)}return i._=t,this.on(e,i,r)},emit:function(e){for(var t=[].slice.call(arguments,1),r=((this.e||(this.e={}))[e]||[]).slice(),n=0,i=r.length;n15 significant digits to BigNumber (value: "+e+"). Use function bignumber(x) to convert to BigNumber.");return new r(e)}},{from:"number",to:"Complex",convert:function(e){return n||f(e),new n(e,0)}},{from:"number",to:"string",convert:function(e){return e+""}},{from:"BigNumber",to:"Complex",convert:function(e){return n||f(e),new n(e.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(e){return n||f(e),new n(e.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(e){i||l(e);var t=new i(e);if(t.valueOf()!==e)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+e+"). Use function fraction(x) to convert to Fraction.");return t}},{from:"string",to:"number",convert:function(e){var t=Number(e);if(isNaN(t))throw new Error('Cannot convert "'+e+'" to a number');return t}},{from:"string",to:"BigNumber",convert:function(t){r||c(t);try{return new r(t)}catch(e){throw new Error('Cannot convert "'+t+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(t){i||l(t);try{return new i(t)}catch(e){throw new Error('Cannot convert "'+t+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(t){n||f(t);try{return new n(t)}catch(e){throw new Error('Cannot convert "'+t+'" to Complex')}}},{from:"boolean",to:"number",convert:function(e){return+e}},{from:"boolean",to:"BigNumber",convert:function(e){return r||c(e),new r(+e)}},{from:"boolean",to:"Fraction",convert:function(e){return i||l(e),new i(+e)}},{from:"boolean",to:"string",convert:function(e){return String(e)}},{from:"Array",to:"Matrix",convert:function(e){return t||function(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}(),new t(e)}},{from:"Matrix",to:"Array",convert:function(e){return e.valueOf()}}],a});function c(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function f(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function l(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var p=[],m=Object(s.a)("ResultSet",p,function(){function t(e){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");this.entries=e||[]}return t.prototype.type="ResultSet",t.prototype.isResultSet=!0,t.prototype.valueOf=function(){return this.entries},t.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},t.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},t.fromJSON=function(e){return new t(e.entries)},t},{isClass:!0}),h=r(15),d=r.n(h),y=["?on","config"],g=Object(s.a)("BigNumber",y,function(e){var t=e.on,r=e.config,n=d.a.clone({precision:r.precision});return n.prototype.type="BigNumber",n.prototype.isBigNumber=!0,n.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},n.fromJSON=function(e){return new n(e.value)},t&&t("config",function(e,t){e.precision!==t.precision&&n.config({precision:e.precision})}),n},{isClass:!0}),v=r(8),b=r.n(v);function x(e){return(x="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var w=[],N=Object(s.a)("Complex",w,function(){return b.a.prototype.type="Complex",b.a.prototype.isComplex=!0,b.a.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},b.a.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},b.a.prototype.format=function(e){var t,r=this.im,n=this.re,i=Object(E.h)(this.re,e),a=Object(E.h)(this.im,e),o=Object(ie.y)(e)?e:e?e.precision:null;return null!==o&&(t=Math.pow(10,-o),Math.abs(n/r)t.re?1:e.ret.im?1:e.imn[a]&&(n[a]=t[a],i=!0);i&&s(e,n,r)}return(m.prototype=new t).createDenseMatrix=function(e,t){return new m(e,t)},m.prototype.type="DenseMatrix",m.prototype.isDenseMatrix=!0,m.prototype.getDataType=function(){return Object(q.h)(this._data,ie.M)},m.prototype.storage=function(){return"dense"},m.prototype.datatype=function(){return this._datatype},m.prototype.create=function(e,t){return new m(e,t)},m.prototype.subset=function(e,t,r){switch(arguments.length){case 1:return function(e,t){if(!Object(ie.t)(t))throw new TypeError("Invalid index");{if(t.isScalar())return e.get(t.min());var r=t.size();if(r.length!==e._size.length)throw new z.a(r.length,e._size.length);for(var n=t.min(),i=t.max(),a=0,o=e._size.length;a");var c=t.max().map(function(e){return e+1});l(e,c,n);var f=a.length;!function r(n,i,a,o,s){var e=s===o-1;var t=i.dimension(s);e?t.forEach(function(e,t){Object(q.q)(e),n[e]=a[t[0]]}):t.forEach(function(e,t){Object(q.q)(e),r(n[e],i,a[t[0]],o,s+1)})}(e._data,t,r,f,0)}return e}(this,e,t,r);default:throw new SyntaxError("Wrong number of arguments")}},m.prototype.get=function(e){if(!Object(ie.b)(e))throw new TypeError("Array expected");if(e.length!==this._size.length)throw new z.a(e.length,this._size.length);for(var t=0;t=n.length)throw new R.a(t,n.length);return Object(ie.v)(e)?e.create(L(e.valueOf(),t,r)):L(e,t,r)}function L(e,t,r){var n,i,a,o;if(t<=0){if(Array.isArray(e[0])){for(o=function(e){var t,r,n=e.length,i=e[0].length,a=[];for(r=0;r");for(var c=t.min()[0],f=t.min()[1],l=i[0],p=i[1],m=0;m "+(this._values?Object(V.d)(this._values[u],e):"X")}return i},j.prototype.toString=function(){return Object(V.d)(this.toArray())},j.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},j.prototype.diagonal=function(e){if(e){if(Object(ie.e)(e)&&(e=e.toNumber()),!Object(ie.y)(e)||!Object(E.i)(e))throw new TypeError("The parameter k must be an integer number")}else e=0;var t=0=n.length)throw new R.a(t,n.length);return Object(ie.v)(e)?e.create(Mt(e.valueOf(),t,r)):Mt(e,t,r)}})});function Mt(e,t,r){var n,i,a;if(t<=0){if(Array.isArray(e[0])){for(a=function(e){var t,r,n=e.length,i=e[0].length,a=[];for(r=0;rc)for(s-=c;s--;)u+="0";else s>1,f[m]&=1)}return f.reverse()}function Yr(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitXor");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(NaN);if(e.isZero())return t;if(t.isZero())return e;if(e.eq(t))return new r(0);var n=new r(-1);return e.eq(n)?Zr(t):t.eq(n)?Zr(e):e.isFinite()&&t.isFinite()?Jr(e,t,function(e,t){return e^t}):e.isFinite()||t.isFinite()?new r(e.isNegative()===t.isNegative()?1/0:-1/0):n}function Xr(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function leftShift");var r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(NaN):e.isZero()||t.isZero()?e:e.isFinite()||t.isFinite()?t.lt(55)?e.times(Math.pow(2,t.toNumber())+""):e.times(new r(2).pow(t)):new r(NaN)}function Qr(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function rightArithShift");var r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(NaN):e.isZero()||t.isZero()?e:t.isFinite()?t.lt(55)?e.div(Math.pow(2,t.toNumber())+"").floor():e.div(new r(2).pow(t)).floor():e.isNegative()?new r(-1):e.isFinite()?new r(0):new r(NaN)}var Kr="number, number";function en(e,t){if(!Object(E.i)(e)||!Object(E.i)(t))throw new Error("Integers expected in function bitAnd");return e&t}function tn(e){if(!Object(E.i)(e))throw new Error("Integer expected in function bitNot");return~e}function rn(e,t){if(!Object(E.i)(e)||!Object(E.i)(t))throw new Error("Integers expected in function bitOr");return e|t}function nn(e,t){if(!Object(E.i)(e)||!Object(E.i)(t))throw new Error("Integers expected in function bitXor");return e^t}function an(e,t){if(!Object(E.i)(e)||!Object(E.i)(t))throw new Error("Integers expected in function leftShift");return e<>t}function sn(e,t){if(!Object(E.i)(e)||!Object(E.i)(t))throw new Error("Integers expected in function rightLogShift");return e>>>t}en.signature=Kr,tn.signature="number",sn.signature=on.signature=an.signature=nn.signature=rn.signature=Kr;var un=["typed","matrix","equalScalar"],cn=Object(s.a)("bitAnd",un,function(e){var t=e.typed,r=e.matrix,n=e.equalScalar,i=tr({typed:t,equalScalar:n}),a=nr({typed:t,equalScalar:n}),o=ar({typed:t,equalScalar:n}),s=Wt({typed:t}),u=Xt({typed:t});return t("bitAnd",{"number, number":en,"BigNumber, BigNumber":Gr,"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return s(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(r(t),e,this,!0).valueOf()}})}),fn=["typed"],ln=Object(s.a)("bitNot",fn,function(e){return(0,e.typed)("bitNot",{number:tn,BigNumber:Zr,"Array | Matrix":function(e){return oe(e,this)}})}),pn=["typed","matrix","equalScalar","DenseMatrix"],mn=Object(s.a)("bitOr",pn,function(e){var t=e.typed,r=e.matrix,n=e.equalScalar,i=e.DenseMatrix,a=Ht({typed:t}),o=Gt({typed:t,equalScalar:n}),s=Vt({typed:t,DenseMatrix:i}),u=Wt({typed:t}),c=Xt({typed:t});return t("bitOr",{"number, number":rn,"BigNumber, BigNumber":Vr,"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, any":function(e,t){return c(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return c(r(t),e,this,!0).valueOf()}})}),hn=["typed","DenseMatrix"],dn=Object(s.a)("algorithm07",hn,function(e){var N=e.typed,O=e.DenseMatrix;return function(e,t,r){var n=e._size,i=e._datatype,a=t._size,o=t._datatype;if(n.length!==a.length)throw new z.a(n.length,a.length);if(n[0]!==a[0]||n[1]!==a[1])throw new RangeError("Dimension mismatch. Matrix A ("+n+") must match Matrix B ("+a+")");var s,u=n[0],c=n[1],f=0,l=r;"string"==typeof i&&i===o&&(s=i,f=N.convert(0,s),l=N.find(r,[s,s]));for(var p=[],m=0;mn)return e.substring(0,n);if(e.lengtha)for(var u=a-1,c=o.length;un&&(n=t[a],r=[a])}return r}});function la(e,t,r){var n;return-1!==String(e).indexOf("Unexpected type")?(n=2>=1,i=o(i,i);return n}function l(e,t){return r(f(e.valueOf(),t))}});function _a(t,e){var r,n=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)),n}function qa(i){for(var e=1;et.re)return 1;if(e.ret.im)return 1;if(e.imr.length?1:t.length=e.length)throw new Error("k out of bounds");for(var n=0;n=e&&(c(s.value,0)||r(s.key,s.value,this)),(s=n.extractMinimum())&&a.push(s);for(var o=0;oe[n+1].length&&(t=e[n],e[n]=e[n+1],e[n+1]=t);return e}(r)}})}),lc="setSize",pc=["typed","compareNatural"],mc=Object(s.a)(lc,pc,function(e){var t=e.typed,a=e.compareNatural;return t(lc,{"Array | Matrix":function(e){return Array.isArray(e)?Object(q.e)(e).length:Object(q.e)(e.toArray()).length},"Array | Matrix, boolean":function(e,t){if(!1===t||0===e.length)return Array.isArray(e)?Object(q.e)(e).length:Object(q.e)(e.toArray()).length;for(var r=Object(q.e)(Array.isArray(e)?e:e.toArray()).sort(a),n=1,i=1;i)'),t+this.index.toHTML(e)},n.prototype._toTex=function(e){var t=this.object.toTex(e);return i(this.object)&&(t="\\left(' + object + '\\right)"),t+this.index.toTex(e)},n.prototype.toJSON=function(){return{mathjs:"AccessorNode",object:this.object,index:this.index}},n.fromJSON=function(e){return new n(e.object,e.index)},n},{isClass:!0,isNode:!0}),Fc=["Node"],Lc=Object(s.a)("ArrayNode",Fc,function(e){var t=e.Node;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(this.items=e||[],!Array.isArray(this.items)||!this.items.every(ie.w))throw new TypeError("Array containing Nodes expected")}return(n.prototype=new t).type="ArrayNode",n.prototype.isArrayNode=!0,n.prototype._compile=function(t,r){var e=Object(q.k)(this.items,function(e){return e._compile(t,r)});if("Array"===t.config.matrix)return function(t,r,n){return Object(q.k)(e,function(e){return e(t,r,n)})};var i=t.matrix;return function(t,r,n){return i(Object(q.k)(e,function(e){return e(t,r,n)}))}},n.prototype.forEach=function(e){for(var t=0;t['+this.items.map(function(e){return e.toHTML(t)}).join(',')+']'},n.prototype._toTex=function(t){var r="\\begin{bmatrix}";return this.items.forEach(function(e){e.items?r+=e.items.map(function(e){return e.toTex(t)}).join("&"):r+=e.toTex(t),r+="\\\\"}),r+="\\end{bmatrix}"},n},{isClass:!0,isNode:!0});function Hc(e){return(Hc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var $c=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{associativity:"left",associativeWith:[]}},{"OperatorNode:and":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitXor":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{associativity:"left",associativeWith:[]},"OperatorNode:unequal":{associativity:"left",associativeWith:[]},"OperatorNode:smaller":{associativity:"left",associativeWith:[]},"OperatorNode:larger":{associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{associativity:"left",associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{associativity:"left",associativeWith:[]}},{"OperatorNode:to":{associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{associativity:"left",associativeWith:[]},"OperatorNode:mod":{associativity:"left",associativeWith:[]}},{"OperatorNode:unaryPlus":{associativity:"right"},"OperatorNode:unaryMinus":{associativity:"right"},"OperatorNode:bitNot":{associativity:"right"},"OperatorNode:not":{associativity:"right"}},{"OperatorNode:pow":{associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{associativity:"right",associativeWith:[]}},{"OperatorNode:factorial":{associativity:"left"}},{"OperatorNode:transpose":{associativity:"left"}}];function Gc(e,t){var r=e;"keep"!==t&&(r=e.getContent());for(var n=r.getIdentifier(),i=0;i<$c.length;i++)if(n in $c[i])return i;return null}function Zc(e,t){var r=e;"keep"!==t&&(r=e.getContent());var n=r.getIdentifier(),i=Gc(r,t);if(null===i)return null;var a=$c[i][n];if(Object(ae.f)(a,"associativity")){if("left"===a.associativity)return"left";if("right"===a.associativity)return"right";throw Error("'"+n+"' has the invalid associativity '"+a.associativity+"'.")}return null}function Vc(e,t,r){var n="keep"!==r?e.getContent():e,i="keep"!==r?e.getContent():t,a=n.getIdentifier(),o=i.getIdentifier(),s=Gc(n,r);if(null===s)return null;var u=$c[s][a];if(Object(ae.f)(u,"associativeWith")&&u.associativeWith instanceof Array){for(var c=0;c)'),t+r+'='+n},s.prototype._toTex=function(e){var t=this.object.toTex(e),r=this.index?this.index.toTex(e):"",n=this.value.toTex(e);return u(this,e&&e.parenthesis)&&(n="\\left(".concat(n,"\\right)")),t+r+":="+n},s},{isClass:!0,isNode:!0}),Yc=["ResultSet","Node"],Xc=Object(s.a)("BlockNode",Yc,function(e){var o=e.ResultSet,t=e.Node;function a(e){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new Error("Array expected");this.blocks=e.map(function(e){var t=e&&e.node,r=!e||void 0===e.visible||e.visible;if(!Object(ie.w)(t))throw new TypeError('Property "node" must be a Node');if("boolean"!=typeof r)throw new TypeError('Property "visible" must be a boolean');return{node:t,visible:r}})}return(a.prototype=new t).type="BlockNode",a.prototype.isBlockNode=!0,a.prototype._compile=function(t,r){var e=Object(q.k)(this.blocks,function(e){return{evaluate:e.node._compile(t,r),visible:e.visible}});return function(r,n,i){var a=[];return Object(q.f)(e,function(e){var t=e.evaluate(r,n,i);e.visible&&a.push(t)}),new o(a)}},a.prototype.forEach=function(e){for(var t=0;t;')}).join('
')},a.prototype._toTex=function(t){return this.blocks.map(function(e){return e.node.toTex(t)+(e.visible?"":";")}).join("\\;\\;\n")},a},{isClass:!0,isNode:!0}),Qc=["Node"],Kc=Object(s.a)("ConditionalNode",Qc,function(e){var t=e.Node;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!Object(ie.w)(e))throw new TypeError("Parameter condition must be a Node");if(!Object(ie.w)(t))throw new TypeError("Parameter trueExpr must be a Node");if(!Object(ie.w)(r))throw new TypeError("Parameter falseExpr must be a Node");this.condition=e,this.trueExpr=t,this.falseExpr=r}return(n.prototype=new t).type="ConditionalNode",n.prototype.isConditionalNode=!0,n.prototype._compile=function(e,t){var n=this.condition._compile(e,t),i=this.trueExpr._compile(e,t),a=this.falseExpr._compile(e,t);return function(e,t,r){return(function(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e)return!!e;if(e){if(Object(ie.e)(e))return!e.isZero();if(Object(ie.j)(e))return!(!e.re&&!e.im);if(Object(ie.L)(e))return!!e.value}if(null!=e)throw new TypeError('Unsupported type of condition "'+Object(ie.M)(e)+'"');return!1}(n(e,t,r))?i:a)(e,t,r)}},n.prototype.forEach=function(e){e(this.condition,"condition",this),e(this.trueExpr,"trueExpr",this),e(this.falseExpr,"falseExpr",this)},n.prototype.map=function(e){return new n(this._ifNode(e(this.condition,"condition",this)),this._ifNode(e(this.trueExpr,"trueExpr",this)),this._ifNode(e(this.falseExpr,"falseExpr",this)))},n.prototype.clone=function(){return new n(this.condition,this.trueExpr,this.falseExpr)},n.prototype._toString=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=Gc(this,t),n=this.condition.toString(e),i=Gc(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n="("+n+")");var a=this.trueExpr.toString(e),o=Gc(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==o&&o<=r)&&(a="("+a+")");var s=this.falseExpr.toString(e),u=Gc(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=r)&&(s="("+s+")"),n+" ? "+a+" : "+s},n.prototype.toJSON=function(){return{mathjs:"ConditionalNode",condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}},n.fromJSON=function(e){return new n(e.condition,e.trueExpr,e.falseExpr)},n.prototype.toHTML=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=Gc(this,t),n=this.condition.toHTML(e),i=Gc(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n='('+n+')');var a=this.trueExpr.toHTML(e),o=Gc(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==o&&o<=r)&&(a='('+a+')');var s=this.falseExpr.toHTML(e),u=Gc(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=r)&&(s='('+s+')'),n+'?'+a+':'+s},n.prototype._toTex=function(e){return"\\begin{cases} {"+this.trueExpr.toTex(e)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(e)+"}\\\\{"+this.falseExpr.toTex(e)+"}, &\\quad{\\text{otherwise}}\\end{cases}"},n},{isClass:!0,isNode:!0}),ef=r(16),tf=r.n(ef),rf={Alpha:"A",alpha:"\\alpha",Beta:"B",beta:"\\beta",Gamma:"\\Gamma",gamma:"\\gamma",Delta:"\\Delta",delta:"\\delta",Epsilon:"E",epsilon:"\\epsilon",varepsilon:"\\varepsilon",Zeta:"Z",zeta:"\\zeta",Eta:"H",eta:"\\eta",Theta:"\\Theta",theta:"\\theta",vartheta:"\\vartheta",Iota:"I",iota:"\\iota",Kappa:"K",kappa:"\\kappa",varkappa:"\\varkappa",Lambda:"\\Lambda",lambda:"\\lambda",Mu:"M",mu:"\\mu",Nu:"N",nu:"\\nu",Xi:"\\Xi",xi:"\\xi",Omicron:"O",omicron:"o",Pi:"\\Pi",pi:"\\pi",varpi:"\\varpi",Rho:"P",rho:"\\rho",varrho:"\\varrho",Sigma:"\\Sigma",sigma:"\\sigma",varsigma:"\\varsigma",Tau:"T",tau:"\\tau",Upsilon:"\\Upsilon",upsilon:"\\upsilon",Phi:"\\Phi",phi:"\\phi",varphi:"\\varphi",Chi:"X",chi:"\\chi",Psi:"\\Psi",psi:"\\psi",Omega:"\\Omega",omega:"\\omega",true:"\\mathrm{True}",false:"\\mathrm{False}",i:"i",inf:"\\infty",Inf:"\\infty",infinity:"\\infty",Infinity:"\\infty",oo:"\\infty",lim:"\\lim",undefined:"\\mathbf{?}"},nf={transpose:"^\\top",ctranspose:"^H",factorial:"!",pow:"^",dotPow:".^\\wedge",unaryPlus:"+",unaryMinus:"-",bitNot:"\\~",not:"\\neg",multiply:"\\cdot",divide:"\\frac",dotMultiply:".\\cdot",dotDivide:".:",mod:"\\mod",add:"+",subtract:"-",to:"\\rightarrow",leftShift:"<<",rightArithShift:">>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},af={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(nf.add,"${args[1]}\\right)")},cbrt:{1:"\\sqrt[3]{${args[0]}}"},ceil:{1:"\\left\\lceil${args[0]}\\right\\rceil"},cube:{1:"\\left(${args[0]}\\right)^3"},divide:{2:"\\frac{${args[0]}}{${args[1]}}"},dotDivide:{2:"\\left(${args[0]}".concat(nf.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(nf.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(nf.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(nf.pow,"{${args[0]}}-1\\right)"),fix:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},floor:{1:"\\left\\lfloor${args[0]}\\right\\rfloor"},gcd:"\\gcd\\left(${args}\\right)",hypot:"\\hypot\\left(${args}\\right)",log:{1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},log10:{1:"\\log_{10}\\left(${args[0]}\\right)"},log1p:{1:"\\ln\\left(${args[0]}+1\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}+1\\right)"},log2:"\\log_{2}\\left(${args[0]}\\right)",mod:{2:"\\left(${args[0]}".concat(nf.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(nf.multiply,"${args[1]}\\right)")},norm:{1:"\\left\\|${args[0]}\\right\\|",2:void 0},nthRoot:{2:"\\sqrt[${args[1]}]{${args[0]}}"},nthRoots:{2:"\\{y : $y^{args[1]} = {${args[0]}}\\}"},pow:{2:"\\left(${args[0]}\\right)".concat(nf.pow,"{${args[1]}}")},round:{1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},sign:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},sqrt:{1:"\\sqrt{${args[0]}}"},square:{1:"\\left(${args[0]}\\right)^2"},subtract:{2:"\\left(${args[0]}".concat(nf.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(nf.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(nf.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(nf.bitAnd,"${args[1]}\\right)")},bitNot:{1:nf.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(nf.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(nf.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(nf.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(nf.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(nf.rightLogShift,"${args[1]}\\right)")},bellNumbers:{1:"\\mathrm{B}_{${args[0]}}"},catalan:{1:"\\mathrm{C}_{${args[0]}}"},stirlingS2:{2:"\\mathrm{S}\\left(${args}\\right)"},arg:{1:"\\arg\\left(${args[0]}\\right)"},conj:{1:"\\left(${args[0]}\\right)^*"},im:{1:"\\Im\\left\\lbrace${args[0]}\\right\\rbrace"},re:{1:"\\Re\\left\\lbrace${args[0]}\\right\\rbrace"},and:{2:"\\left(${args[0]}".concat(nf.and,"${args[1]}\\right)")},not:{1:nf.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(nf.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(nf.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(nf.ctranspose)},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},sqrtm:{1:"{${args[0]}}".concat(nf.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(nf.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(nf.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(nf.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(nf.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(nf.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(nf.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(nf.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(nf.unequal,"${args[1]}\\right)")},erf:{1:"erf\\left(${args[0]}\\right)"},max:"\\max\\left(${args}\\right)",min:"\\min\\left(${args}\\right)",variance:"\\mathrm{Var}\\left(${args}\\right)",acos:{1:"\\cos^{-1}\\left(${args[0]}\\right)"},acosh:{1:"\\cosh^{-1}\\left(${args[0]}\\right)"},acot:{1:"\\cot^{-1}\\left(${args[0]}\\right)"},acoth:{1:"\\coth^{-1}\\left(${args[0]}\\right)"},acsc:{1:"\\csc^{-1}\\left(${args[0]}\\right)"},acsch:{1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},asec:{1:"\\sec^{-1}\\left(${args[0]}\\right)"},asech:{1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},asin:{1:"\\sin^{-1}\\left(${args[0]}\\right)"},asinh:{1:"\\sinh^{-1}\\left(${args[0]}\\right)"},atan:{1:"\\tan^{-1}\\left(${args[0]}\\right)"},atan2:{2:"\\mathrm{atan2}\\left(${args}\\right)"},atanh:{1:"\\tanh^{-1}\\left(${args[0]}\\right)"},cos:{1:"\\cos\\left(${args[0]}\\right)"},cosh:{1:"\\cosh\\left(${args[0]}\\right)"},cot:{1:"\\cot\\left(${args[0]}\\right)"},coth:{1:"\\coth\\left(${args[0]}\\right)"},csc:{1:"\\csc\\left(${args[0]}\\right)"},csch:{1:"\\mathrm{csch}\\left(${args[0]}\\right)"},sec:{1:"\\sec\\left(${args[0]}\\right)"},sech:{1:"\\mathrm{sech}\\left(${args[0]}\\right)"},sin:{1:"\\sin\\left(${args[0]}\\right)"},sinh:{1:"\\sinh\\left(${args[0]}\\right)"},tan:{1:"\\tan\\left(${args[0]}\\right)"},tanh:{1:"\\tanh\\left(${args[0]}\\right)"},to:{2:"\\left(${args[0]}".concat(nf.to,"${args[1]}\\right)")},numeric:function(e){return e.args[0].toTex()},number:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},string:{0:'\\mathtt{""}',1:"\\mathrm{string}\\left(${args[0]}\\right)"},bignumber:{0:"0",1:"\\left(${args[0]}\\right)"},complex:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)+".concat(rf.i,"\\cdot\\left(${args[1]}\\right)\\right)")},matrix:{0:"\\begin{bmatrix}\\end{bmatrix}",1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},sparse:{0:"\\begin{bsparse}\\end{bsparse}",1:"\\left(${args[0]}\\right)"},unit:{1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"}},of={deg:"^\\circ"};function sf(e){return tf()(e,{preserveFormatting:!0})}function uf(e,t){return(t=void 0!==t&&t)?Object(ae.f)(of,e)?of[e]:"\\mathrm{"+sf(e)+"}":Object(ae.f)(rf,e)?rf[e]:sf(e)}var cf=["Node"],ff=Object(s.a)("ConstantNode",cf,function(e){var t=e.Node;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");this.value=e}return(r.prototype=new t).type="ConstantNode",r.prototype.isConstantNode=!0,r.prototype._compile=function(e,t){var r=this.value;return function(){return r}},r.prototype.forEach=function(e){},r.prototype.map=function(e){return this.clone()},r.prototype.clone=function(){return new r(this.value)},r.prototype._toString=function(e){return Object(V.d)(this.value,e)},r.prototype.toHTML=function(e){var t=this._toString(e);switch(Object(ie.M)(this.value)){case"number":case"BigNumber":case"Fraction":return''+t+"";case"string":return''+t+"";case"boolean":return''+t+"";case"null":return''+t+"";case"undefined":return''+t+"";default:return''+t+""}},r.prototype.toJSON=function(){return{mathjs:"ConstantNode",value:this.value}},r.fromJSON=function(e){return new r(e.value)},r.prototype._toTex=function(e){var t=this._toString(e);switch(Object(ie.M)(this.value)){case"string":return"\\mathtt{"+sf(t)+"}";case"number":case"BigNumber":if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var r=t.toLowerCase().indexOf("e");return-1!==r?t.substring(0,r)+"\\cdot10^{"+t.substring(r+1)+"}":t;case"Fraction":return this.value.toLatex();default:return t}},r},{isClass:!0,isNode:!0}),lf=["typed","Node"],pf=Object(s.a)("FunctionAssignmentNode",lf,function(e){var f=e.typed,t=e.Node;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');if(!Array.isArray(t))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!Object(ie.w)(r))throw new TypeError('Node expected for parameter "expr"');if(e in qc)throw new Error('Illegal function name, "'+e+'" is a reserved keyword');this.name=e,this.params=t.map(function(e){return e&&e.name||e}),this.types=t.map(function(e){return e&&e.type||"any"}),this.expr=r}function a(e,t){var r=Gc(e,t),n=Gc(e.expr,t);return"all"===t||null!==n&&n<=r}return(n.prototype=new t).type="FunctionAssignmentNode",n.prototype.isFunctionAssignmentNode=!0,n.prototype._compile=function(e,t){var r=Object.create(t);Object(q.f)(this.params,function(e){r[e]=!0});var a=this.expr._compile(e,r),o=this.name,s=this.params,u=Object(q.j)(this.types,","),c=o+"("+Object(q.j)(this.params,", ")+")";return function(r,n,i){var e={};e[u]=function(){for(var e=Object.create(n),t=0;t'+Object(V.c)(this.params[n])+"");var i=this.expr.toHTML(e);return a(this,t)&&(i='('+i+')'),''+Object(V.c)(this.name)+'('+r.join(',')+')='+i},n.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=this.expr.toTex(e);return a(this,t)&&(r="\\left(".concat(r,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(uf).join(",")+"\\right):="+r},n},{isClass:!0,isNode:!0});function mf(e){return function(e){if(Array.isArray(e))return hf(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return hf(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return hf(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function hf(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r.'+Object(V.c)(this.getObjectProperty())+"":'['+t.join(',')+']'},i.prototype._toTex=function(t){var e=this.dimensions.map(function(e){return e.toTex(t)});return this.dotNotation?"."+this.getObjectProperty():"_{"+e.join(",")+"}"},i},{isClass:!0,isNode:!0});function gf(e){return(gf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var vf=["Node"],bf=Object(s.a)("ObjectNode",vf,function(e){var t=e.Node;function n(t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(this.properties=t||{},t&&("object"!==gf(t)||!Object.keys(t).every(function(e){return Object(ie.w)(t[e])})))throw new TypeError("Object containing Nodes expected")}return(n.prototype=new t).type="ObjectNode",n.prototype.isObjectNode=!0,n.prototype._compile=function(e,t){var a={};for(var r in this.properties)if(Object(ae.f)(this.properties,r)){var n=Object(V.e)(r),i=JSON.parse(n);if(!Ri(this.properties,i))throw new Error('No access to property "'+i+'"');a[i]=this.properties[r]._compile(e,t)}return function(e,t,r){var n={};for(var i in a)Object(ae.f)(a,i)&&(n[i]=a[i](e,t,r));return n}},n.prototype.forEach=function(e){for(var t in this.properties)Object(ae.f)(this.properties,t)&&e(this.properties[t],"properties["+Object(V.e)(t)+"]",this)},n.prototype.map=function(e){var t={};for(var r in this.properties)Object(ae.f)(this.properties,r)&&(t[r]=this._ifNode(e(this.properties[r],"properties["+Object(V.e)(r)+"]",this)));return new n(t)},n.prototype.clone=function(){var e={};for(var t in this.properties)Object(ae.f)(this.properties,t)&&(e[t]=this.properties[t]);return new n(e)},n.prototype._toString=function(e){var t=[];for(var r in this.properties)Object(ae.f)(this.properties,r)&&t.push(Object(V.e)(r)+": "+this.properties[r].toString(e));return"{"+t.join(", ")+"}"},n.prototype.toJSON=function(){return{mathjs:"ObjectNode",properties:this.properties}},n.fromJSON=function(e){return new n(e.properties)},n.prototype.toHTML=function(e){var t=[];for(var r in this.properties)Object(ae.f)(this.properties,r)&&t.push(''+Object(V.c)(r)+':'+this.properties[r].toHTML(e));return'{'+t.join(',')+'}'},n.prototype._toTex=function(e){var t=[];for(var r in this.properties)Object(ae.f)(this.properties,r)&&t.push("\\mathbf{"+r+":} & "+this.properties[r].toTex(e)+"\\\\");return"\\left\\{\\begin{array}{ll}".concat(t.join("\n"),"\\end{array}\\right\\}")},n},{isClass:!0,isNode:!0}),xf=["Node"],wf=Object(s.a)("OperatorNode",xf,function(e){var t=e.Node;function i(e,t,r,n){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('string expected for parameter "op"');if("string"!=typeof t)throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(r)||!r.every(ie.w))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=!0===n,this.op=e,this.fn=t,this.args=r||[]}function m(i,a,e,t,r){var n,o=Gc(i,a),s=Zc(i,a);if("all"===a||2)'),"right"===a?''+Object(V.c)(this.op)+""+o:o+''+Object(V.c)(this.op)+""}if(2===n.length){var s=n[0].toHTML(r),u=n[1].toHTML(r);return i[0]&&(s='('+s+')'),i[1]&&(u='('+u+')'),this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===t?s+''+u:s+''+Object(V.c)(this.op)+""+u}var c=n.map(function(e,t){return e=e.toHTML(r),i[t]&&(e='('+e+')'),e});return 2'):c.join(''+Object(V.c)(this.op)+""):''+Object(V.c)(this.fn)+'('+c.join(',')+')'},i.prototype._toTex=function(r){var e=r&&r.parenthesis?r.parenthesis:"keep",t=r&&r.implicit?r.implicit:"hide",n=this.args,i=m(this,e,t,n,!0),a=void 0===(a=nf[this.fn])?this.op:a;if(1===n.length){var o=Zc(this,e),s=n[0].toTex(r);return i[0]&&(s="\\left(".concat(s,"\\right)")),"right"===o?a+s:s+a}if(2===n.length){var u=n[0],c=u.toTex(r);i[0]&&(c="\\left(".concat(c,"\\right)"));var f,l=n[1].toTex(r);switch(i[1]&&(l="\\left(".concat(l,"\\right)")),f="keep"===e?u.getIdentifier():u.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return a+"{"+c+"}{"+l+"}";case"OperatorNode:pow":switch(c="{"+c+"}",l="{"+l+"}",f){case"ConditionalNode":case"OperatorNode:divide":c="\\left(".concat(c,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&"hide"===t)return c+"~"+l}return c+a+l}if(2('+this.content.toHTML(e)+')':this.content.toHTML(e)},r.prototype._toTex=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"\\left(".concat(this.content.toTex(e),"\\right)"):this.content.toTex(e)},r},{isClass:!0,isNode:!0}),Mf=["Node"],jf=Object(s.a)("RangeNode",Mf,function(e){var t=e.Node;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!Object(ie.w)(e))throw new TypeError("Node expected");if(!Object(ie.w)(t))throw new TypeError("Node expected");if(r&&!Object(ie.w)(r))throw new TypeError("Node expected");if(3('+i+')'),t=i,this.step&&(r=this.step.toHTML(e),n.step&&(r='('+r+')'),t+=':'+r);var a=this.end.toHTML(e);return n.end&&(a='('+a+')'),t+=':'+a},n.prototype._toTex=function(e){var t,r=o(this,e&&e.parenthesis?e.parenthesis:"keep"),n=this.start.toTex(e);r.start&&(n="\\left(".concat(n,"\\right)")),this.step&&(t=this.step.toTex(e),r.step&&(t="\\left(".concat(t,"\\right)")),n+=":"+t);var i=this.end.toTex(e);return r.end&&(i="\\left(".concat(i,"\\right)")),n+=":"+i},n},{isClass:!0,isNode:!0}),Ef=["Node"],Sf=Object(s.a)("RelationalNode",Ef,function(e){var t=e.Node;function i(e,t){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(t))throw new TypeError("Parameter params must be an array");if(e.length!==t.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=e,this.params=t}return(i.prototype=new t).type="RelationalNode",i.prototype.isRelationalNode=!0,i.prototype._compile=function(o,t){var s=this,u=this.params.map(function(e){return e._compile(o,t)});return function(e,t,r){for(var n=u[0](e,t,r),i=0;i",smallerEq:"<=",largerEq:">="},r=e[0],o=0;o('+e.toHTML(n)+')':e.toHTML(n)}),t={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},r=e[0],o=0;o'+Object(V.c)(t[this.conditionals[o]])+""+e[o+1];return r},i.prototype._toTex=function(n){for(var i=n&&n.parenthesis?n.parenthesis:"keep",a=Gc(this,i),e=this.params.map(function(e,t){var r=Gc(e,i);return"all"===i||null!==r&&r<=a?"\\left("+e.toTex(n)+"\right)":e.toTex(n)}),t=e[0],r=0;r'+t+"":"i"===t?''+t+"":"Infinity"===t?''+t+"":"NaN"===t?''+t+"":"null"===t?''+t+"":"undefined"===t?''+t+"":''+t+""},r.prototype.toJSON=function(){return{mathjs:"SymbolNode",name:this.name}},r.fromJSON=function(e){return new r(e.name)},r.prototype._toTex=function(e){var t=!1;void 0===n[this.name]&&s(this.name)&&(t=!0);var r=uf(this.name,t);return"\\"===r[0]?r:" "+r},r},{isClass:!0,isNode:!0});function Tf(e){return(Tf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _f(){return(_f=Object.assign||function(e){for(var t=1;t'+Object(V.c)(this.fn)+'('+e.join(',')+')'};var o=d.prototype.toTex;return d.prototype.toTex=function(e){var t;return e&&"object"===Tf(e.handler)&&Object(ae.f)(e.handler,this.name)&&(t=e.handler[this.name](this,e)),void 0!==t?t:o.call(this,e)},d.prototype._toTex=function(t){var e,r,n=this.args.map(function(e){return e.toTex(t)});switch(af[this.name]&&(e=af[this.name]),!i[this.name]||"function"!=typeof i[this.name].toTex&&"object"!==Tf(i[this.name].toTex)&&"string"!=typeof i[this.name].toTex||(e=i[this.name].toTex),Tf(e)){case"function":r=e(this,t);break;case"string":r=a(e,this,t);break;case"object":switch(Tf(e[n.length])){case"function":r=e[n.length](this,t);break;case"string":r=a(e[n.length],this,t)}}return void 0!==r?r:a("\\mathrm{${name}}\\left(${args}\\right)",this,t)},d.prototype.getIdentifier=function(){return this.type+":"+this.name},d},{isClass:!0,isNode:!0});function kf(){return(kf=Object.assign||function(e){for(var t=1;t":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},O={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},M={true:!0,false:!1,null:null,undefined:void 0},j=["NaN","Infinity"];function E(e,t){return e.expression.substr(e.index,t)}function S(e){return E(e,1)}function A(e){e.index++}function C(e){return e.expression.charAt(e.index-1)}function T(e){return e.expression.charAt(e.index+1)}function _(e){for(e.tokenType=w.NULL,e.token="",e.comment="";x.isWhitespace(S(e),e.nestingLevel);)A(e);if("#"===S(e))for(;"\n"!==S(e)&&""!==S(e);)e.comment+=S(e),A(e);if(""!==S(e)){if("\n"===S(e)&&!e.nestingLevel)return e.tokenType=w.DELIMITER,e.token=S(e),void A(e);var t=S(e),r=E(e,2),n=E(e,3);if(3===n.length&&N[n])return e.tokenType=w.DELIMITER,e.token=n,A(e),A(e),void A(e);if(2===r.length&&N[r])return e.tokenType=w.DELIMITER,e.token=r,A(e),void A(e);if(N[t])return e.tokenType=w.DELIMITER,e.token=t,void A(e);if(x.isDigitDot(t)){if(e.tokenType=w.NUMBER,"."===S(e))e.token+=S(e),A(e),x.isDigit(S(e))||(e.tokenType=w.DELIMITER);else{for(;x.isDigit(S(e));)e.token+=S(e),A(e);x.isDecimalMark(S(e),T(e))&&(e.token+=S(e),A(e))}for(;x.isDigit(S(e));)e.token+=S(e),A(e);if("E"===S(e)||"e"===S(e))if(x.isDigit(T(e))||"-"===T(e)||"+"===T(e)){if(e.token+=S(e),A(e),"+"!==S(e)&&"-"!==S(e)||(e.token+=S(e),A(e)),!x.isDigit(S(e)))throw re(e,'Digit expected, got "'+S(e)+'"');for(;x.isDigit(S(e));)e.token+=S(e),A(e);if(x.isDecimalMark(S(e),T(e)))throw re(e,'Digit expected, got "'+S(e)+'"')}else if("."===T(e))throw A(e),re(e,'Digit expected, got "'+S(e)+'"')}else{if(!x.isAlpha(S(e),C(e),T(e))){for(e.tokenType=w.UNKNOWN;""!==S(e);)e.token+=S(e),A(e);throw re(e,'Syntax error in part "'+e.token+'"')}for(;x.isAlpha(S(e),C(e),T(e))||x.isDigit(S(e));)e.token+=S(e),A(e);Object(ae.f)(O,e.token)?e.tokenType=w.DELIMITER:e.tokenType=w.SYMBOL}}else e.tokenType=w.DELIMITER}function q(e){for(;_(e),"\n"===e.token;);}function I(e){e.nestingLevel++}function k(e){e.nestingLevel--}function B(e,t){var r={extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:w.NULL,nestingLevel:0,conditionalLevel:null};kf(r,{expression:e,extraNodes:t}),_(r);var n=function(e){var t,r,n=[];""!==e.token&&"\n"!==e.token&&";"!==e.token&&((t=z(e)).comment=e.comment);for(;"\n"===e.token||";"===e.token;)0===n.length&&t&&(r=";"!==e.token,n.push({node:t,visible:r})),_(e),"\n"!==e.token&&";"!==e.token&&""!==e.token&&((t=z(e)).comment=e.comment,r=";"!==e.token,n.push({node:t,visible:r}));return 0":"larger","<=":"smallerEq",">=":"largerEq"};Object(ae.f)(n,e.token);){var i={name:e.token,fn:n[e.token]};r.push(i),q(e),t.push(H(e))}return 1===t.length?t[0]:2===t.length?new y(r[0].name,r[0].fn,t):new v(r.map(function(e){return e.fn}),t)}function H(e){for(var t,r,n,i=$(e),a={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};Object(ae.f)(a,e.token);)r=a[t=e.token],q(e),n=[i,$(e)],i=new y(t,r,n);return i}function $(e){for(var t,r,n,i=G(e),a={to:"to",in:"to"};Object(ae.f)(a,e.token);)r=a[t=e.token],q(e),i="in"===t&&""===e.token?new y("*","multiply",[i,new b("in")],!0):(n=[i,G(e)],new y(t,r,n));return i}function G(e){var t=[],r=":"===e.token?new l(1):Z(e);if(":"===e.token&&e.conditionalLevel!==e.nestingLevel){for(t.push(r);":"===e.token&&t.length<3;)q(e),")"===e.token||"]"===e.token||","===e.token||""===e.token?t.push(new b("end")):t.push(Z(e));r=3===t.length?new n(t[0],t[2],t[1]):new n(t[0],t[1])}return r}function Z(e){for(var t,r,n,i=V(e),a={"+":"add","-":"subtract"};Object(ae.f)(a,e.token);)r=a[t=e.token],q(e),n=[i,V(e)],i=new y(t,r,n);return i}function V(e){for(var t,r,n,i=J(e),a={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide","%":"mod",mod:"mod"};Object(ae.f)(a,e.token);)r=a[t=e.token],q(e),n=J(e),i=new y(t,r,[i,n]);return i}function J(e){for(var t=W(e),r=t;e.tokenType===w.SYMBOL||"in"===e.token&&Object(ie.l)(t)||!(e.tokenType!==w.NUMBER||Object(ie.l)(r)||Object(ie.B)(r)&&"!"!==r.op)||"("===e.token;)r=W(e),t=new y("*","multiply",[t,r],!0);return t}function W(e){for(var t=Y(e),r=t,n=[];"/"===e.token&&Object(ie.l)(r);){if(n.push(kf({},e)),q(e),e.tokenType!==w.NUMBER){kf(e,n.pop());break}if(n.push(kf({},e)),q(e),e.tokenType!==w.SYMBOL&&"("!==e.token){n.pop(),kf(e,n.pop());break}kf(e,n.pop()),n.pop(),r=Y(e),t=new y("/","divide",[t,r])}return t}function Y(e){var t,r,n,i={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return Object(ae.f)(i,e.token)?(n=i[e.token],t=e.token,q(e),r=[Y(e)],new y(t,n,r)):function(e){var t,r,n,i;t=function(e){var t,r,n;t=function(e){var t=[];if(e.tokenType===w.SYMBOL&&Object(ae.f)(e.extraNodes,e.token)){var r=e.extraNodes[e.token];if(_(e),"("===e.token){if(t=[],I(e),_(e),")"!==e.token)for(t.push(z(e));","===e.token;)_(e),t.push(z(e));if(")"!==e.token)throw re(e,"Parenthesis ) expected");k(e),_(e)}return new r(t)}return function(e){var t,r;if(e.tokenType===w.SYMBOL||e.tokenType===w.DELIMITER&&e.token in O)return r=e.token,_(e),t=Object(ae.f)(M,r)?new l(M[r]):-1!==j.indexOf(r)?new l(s(r,"number")):new b(r),t=X(e,t);return function(e){var t,r;return'"'!==e.token?function(e){var t,r;return"'"!==e.token?function(e){var t,r,n,i;if("["!==e.token)return function(e){if("{"!==e.token)return function(e){var t;return e.tokenType!==w.NUMBER?function(e){var t;if("("!==e.token)return function(e){throw""===e.token?re(e,"Unexpected end of expression"):re(e,"Value expected")}(e);if(I(e),_(e),t=z(e),")"===e.token)return k(e),_(e),t=new g(t),t=X(e,t);throw re(e,"Parenthesis ) expected")}(e):(t=e.token,_(e),new l(s(t,u.number)))}(e);var t;I(e);var r={};do{if(_(e),"}"!==e.token){if('"'===e.token)t=Q(e);else if("'"===e.token)t=K(e);else{if(!(e.tokenType===w.SYMBOL||e.tokenType===w.DELIMITER&&e.token in O))throw re(e,"Symbol or string expected as object key");t=e.token,_(e)}if(":"!==e.token)throw re(e,"Colon : expected after object key");_(e),r[t]=z(e)}}while(","===e.token);if("}"!==e.token)throw re(e,"Comma , or bracket } expected after object value");k(e),_(e);var n=new d(r);return n=X(e,n)}(e);if(I(e),_(e),"]"!==e.token){var a=ee(e);if(";"===e.token){for(n=1,r=[a];";"===e.token;)_(e),r[n]=ee(e),n++;if("]"!==e.token)throw re(e,"End of matrix ] expected");k(e),_(e),i=r[0].items.length;for(var o=1;oi))for(var l=s[c+1];f=I?M[T+U]-=m:0!==M[T+U]&&(M[T+U]=M[C+U]+G);for(h=L;h1, -1 when x<0, and 0 when x=0.",examples:["sign(3.5)","sign(-4.2)","sign(0)"],seealso:["abs"]},sqrt:{name:"sqrt",category:"Arithmetic",syntax:["sqrt(x)"],description:"Compute the square root value. If x = y * y, then y is the square root of x.",examples:["sqrt(25)","5 * 5","sqrt(-1)"],seealso:["square","sqrtm","multiply","nthRoot","nthRoots","pow"]},sqrtm:{name:"sqrtm",category:"Arithmetic",syntax:["sqrtm(x)"],description:"Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",examples:["sqrtm([[1, 2], [3, 4]])"],seealso:["sqrt","abs","square","multiply"]},square:{name:"square",category:"Arithmetic",syntax:["square(x)"],description:"Compute the square of a value. The square of x is x * x.",examples:["square(3)","sqrt(9)","3^2","3 * 3"],seealso:["multiply","pow","sqrt","cube"]},subtract:{name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["a = 5.3 - 2","a + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]},unaryMinus:{name:"unaryMinus",category:"Operators",syntax:["-x","unaryMinus(x)"],description:"Inverse the sign of a value. Converts booleans and strings to numbers.",examples:["-4.5","-(-5.6)",'-"22"'],seealso:["add","subtract","unaryPlus"]},unaryPlus:{name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},xgcd:{name:"xgcd",category:"Arithmetic",syntax:["xgcd(a, b)"],description:"Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.",examples:["xgcd(8, 12)","gcd(8, 12)","xgcd(36163, 21199)"],seealso:["gcd","lcm"]},bitAnd:{name:"bitAnd",category:"Bitwise",syntax:["x & y","bitAnd(x, y)"],description:"Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",examples:["5 & 3","bitAnd(53, 131)","[1, 12, 31] & 42"],seealso:["bitNot","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitNot:{name:"bitNot",category:"Bitwise",syntax:["~x","bitNot(x)"],description:"Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.",examples:["~1","~2","bitNot([2, -3, 4])"],seealso:["bitAnd","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitOr:{name:"bitOr",category:"Bitwise",syntax:["x | y","bitOr(x, y)"],description:"Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.",examples:["5 | 3","bitOr([1, 2, 3], 4)"],seealso:["bitAnd","bitNot","bitXor","leftShift","rightArithShift","rightLogShift"]},bitXor:{name:"bitXor",category:"Bitwise",syntax:["bitXor(x, y)"],description:"Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.",examples:["bitOr(1, 2)","bitXor([2, 3, 4], 4)"],seealso:["bitAnd","bitNot","bitOr","leftShift","rightArithShift","rightLogShift"]},leftShift:{name:"leftShift",category:"Bitwise",syntax:["x << y","leftShift(x, y)"],description:"Bitwise left logical shift of a value x by y number of bits.",examples:["4 << 1","8 >> 1"],seealso:["bitAnd","bitNot","bitOr","bitXor","rightArithShift","rightLogShift"]},rightArithShift:{name:"rightArithShift",category:"Bitwise",syntax:["x >> y","rightArithShift(x, y)"],description:"Bitwise right arithmetic shift of a value x by y number of bits.",examples:["8 >> 1","4 << 1","-12 >> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightLogShift"]},rightLogShift:{name:"rightLogShift",category:"Bitwise",syntax:["x >>> y","rightLogShift(x, y)"],description:"Bitwise right logical shift of a value x by y number of bits.",examples:["8 >>> 1","4 << 1","-12 >>> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightArithShift"]},bellNumbers:{name:"bellNumbers",category:"Combinatorics",syntax:["bellNumbers(n)"],description:"The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["bellNumbers(3)","bellNumbers(8)"],seealso:["stirlingS2"]},catalan:{name:"catalan",category:"Combinatorics",syntax:["catalan(n)"],description:"The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["catalan(3)","catalan(8)"],seealso:["bellNumbers"]},composition:{name:"composition",category:"Combinatorics",syntax:["composition(n, k)"],description:"The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.",examples:["composition(5, 3)"],seealso:["combinations"]},stirlingS2:{name:"stirlingS2",category:"Combinatorics",syntax:["stirlingS2(n, k)"],description:"he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",examples:["stirlingS2(5, 3)"],seealso:["bellNumbers"]},config:{name:"config",category:"Core",syntax:["config()","config(options)"],description:"Get configuration or change configuration.",examples:["config()","1/3 + 1/4",'config({number: "Fraction"})',"1/3 + 1/4"],seealso:[]},import:{name:"import",category:"Core",syntax:["import(functions)","import(functions, options)"],description:"Import functions or constants from an object.",examples:["import({myFn: f(x)=x^2, myConstant: 32 })","myFn(2)","myConstant"],seealso:[]},typed:{name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number, number": f(x)=x+x })',"double(2)",'double("hello")'],seealso:[]},arg:{name:"arg",category:"Complex",syntax:["arg(x)"],description:"Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).",examples:["arg(2 + 2i)","atan2(3, 2)","arg(2 + 3i)"],seealso:["re","im","conj","abs"]},conj:{name:"conj",category:"Complex",syntax:["conj(x)"],description:"Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.",examples:["conj(2 + 3i)","conj(2 - 3i)","conj(-5.2i)"],seealso:["re","im","abs","arg"]},re:{name:"re",category:"Complex",syntax:["re(x)"],description:"Get the real part of a complex number.",examples:["re(2 + 3i)","im(2 + 3i)","re(-5.2i)","re(2.4)"],seealso:["im","conj","abs","arg"]},im:{name:"im",category:"Complex",syntax:["im(x)"],description:"Get the imaginary part of a complex number.",examples:["im(2 + 3i)","re(2 + 3i)","im(-5.2i)","im(2.4)"],seealso:["re","conj","abs","arg"]},evaluate:{name:"evaluate",category:"Expression",syntax:["evaluate(expression)","evaluate([expr1, expr2, expr3, ...])"],description:"Evaluate an expression or an array with expressions.",examples:['evaluate("2 + 3")','evaluate("sqrt(" + 4 + ")")'],seealso:[]},help:{name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},distance:{name:"distance",category:"Geometry",syntax:["distance([x1, y1], [x2, y2])","distance([[x1, y1], [x2, y2]])"],description:"Calculates the Euclidean distance between two points.",examples:["distance([0,0], [4,4])","distance([[0,0], [4,4]])"],seealso:[]},intersect:{name:"intersect",category:"Geometry",syntax:["intersect(expr1, expr2, expr3, expr4)","intersect(expr1, expr2, expr3)"],description:"Computes the intersection point of lines and/or planes.",examples:["intersect([0, 0], [10, 10], [10, 0], [0, 10])","intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])"],seealso:[]},and:{name:"and",category:"Logical",syntax:["x and y","and(x, y)"],description:"Logical and. Test whether two values are both defined with a nonzero/nonempty value.",examples:["true and false","true and true","2 and 4"],seealso:["not","or","xor"]},not:{name:"not",category:"Logical",syntax:["not x","not(x)"],description:"Logical not. Flips the boolean value of given argument.",examples:["not true","not false","not 2","not 0"],seealso:["and","or","xor"]},or:{name:"or",category:"Logical",syntax:["x or y","or(x, y)"],description:"Logical or. Test if at least one value is defined with a nonzero/nonempty value.",examples:["true or false","false or false","0 or 4"],seealso:["not","and","xor"]},xor:{name:"xor",category:"Logical",syntax:["x xor y","xor(x, y)"],description:"Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.",examples:["true xor false","false xor false","true xor true","0 xor 4"],seealso:["not","and","or"]},concat:{name:"concat",category:"Matrix",syntax:["concat(A, B, C, ...)","concat(A, B, C, ..., dim)"],description:"Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",examples:["A = [1, 2; 5, 6]","B = [3, 4; 7, 8]","concat(A, B)","concat(A, B, 1)","concat(A, B, 2)"],seealso:["det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},cross:{name:"cross",category:"Matrix",syntax:["cross(A, B)"],description:"Calculate the cross product for two vectors in three dimensional space.",examples:["cross([1, 1, 0], [0, 1, 1])","cross([3, -3, 1], [4, 9, 2])","cross([2, 3, 4], [5, 6, 7])"],seealso:["multiply","dot"]},column:{name:"column",category:"Matrix",syntax:["column(x, index)"],description:"Return a column from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","column(A, 1)","column(A, 2)"],seealso:["row"]},ctranspose:{name:"ctranspose",category:"Matrix",syntax:["x'","ctranspose(x)"],description:"Complex Conjugate and Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","ctranspose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},det:{name:"det",category:"Matrix",syntax:["det(x)"],description:"Calculate the determinant of a matrix",examples:["det([1, 2; 3, 4])","det([-2, 2, 3; -1, 1, 3; 2, 0, -1])"],seealso:["concat","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},diag:{name:"diag",category:"Matrix",syntax:["diag(x)","diag(x, k)"],description:"Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.",examples:["diag(1:3)","diag(1:3, 1)","a = [1, 2, 3; 4, 5, 6; 7, 8, 9]","diag(a)"],seealso:["concat","det","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},dot:{name:"dot",category:"Matrix",syntax:["dot(A, B)","A * B"],description:"Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn",examples:["dot([2, 4, 1], [2, 2, 3])","[2, 4, 1] * [2, 2, 3]"],seealso:["multiply","cross"]},getMatrixDataType:{name:"getMatrixDataType",category:"Matrix",syntax:["getMatrixDataType(x)"],description:'Find the data type of all elements in a matrix or array, for example "number" if all items are a number and "Complex" if all values are complex numbers. If a matrix contains more than one data type, it will return "mixed".',examples:["getMatrixDataType([1, 2, 3])","getMatrixDataType([[5 cm], [2 inch]])",'getMatrixDataType([1, "text"])',"getMatrixDataType([1, bignumber(4)])"],seealso:["matrix","sparse","typeOf"]},identity:{name:"identity",category:"Matrix",syntax:["identity(n)","identity(m, n)","identity([m, n])"],description:"Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.",examples:["identity(3)","identity(3, 5)","a = [1, 2, 3; 4, 5, 6]","identity(size(a))"],seealso:["concat","det","diag","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},filter:{name:"filter",category:"Matrix",syntax:["filter(x, test)"],description:"Filter items in a matrix.",examples:["isPositive(x) = x > 0","filter([6, -2, -1, 4, 3], isPositive)","filter([6, -2, 0, 1, 0], x != 0)"],seealso:["sort","map","forEach"]},flatten:{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"]},forEach:{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"]},inv:{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","identity","ones","range","size","squeeze","subset","trace","transpose","zeros"]},eigs:{name:"eigs",category:"Matrix",syntax:["eigs(x)"],description:"Calculate the eigenvalues and eigenvectors of a real symmetric matrix",examples:["eigs([[5, 2.3], [2.3, 1]])"],seealso:["inv"]},kron:{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"]},map:{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"]},ones:{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","identity","inv","range","size","squeeze","subset","trace","transpose","zeros"]},partitionSelect:{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"]},range:{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","identity","inv","ones","size","squeeze","subset","trace","transpose","zeros"]},resize:{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"]},reshape:{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"]},row:{name:"row",category:"Matrix",syntax:["row(x, index)"],description:"Return a row from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","row(A, 1)","row(A, 2)"],seealso:["column"]},size:{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","identity","inv","ones","range","squeeze","subset","trace","transpose","zeros"]},sort:{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"]},squeeze:{name:"squeeze",category:"Matrix",syntax:["squeeze(x)"],description:"Remove inner and outer singleton dimensions from a matrix.",examples:["a = zeros(3,2,1)","size(squeeze(a))","b = zeros(1,1,3)","size(squeeze(b))"],seealso:["concat","det","diag","identity","inv","ones","range","size","subset","trace","transpose","zeros"]},subset:{name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of a matrix or string. Indexes are one-based. Both the ranges lower-bound and upper-bound are included.",examples:["d = [1, 2; 3, 4]","e = []","e[1, 1:2] = [5, 6]","e[2, :] = [7, 8]","f = d * e","f[2, 1]","f[:, 1]"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","trace","transpose","zeros"]},trace:{name:"trace",category:"Matrix",syntax:["trace(A)"],description:"Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.",examples:["A = [1, 2, 3; -1, 2, 3; 2, 0, 3]","trace(A)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","transpose","zeros"]},transpose:{name:"transpose",category:"Matrix",syntax:["x'","transpose(x)"],description:"Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","transpose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},zeros:{name:"zeros",category:"Matrix",syntax:["zeros(m)","zeros(m, n)","zeros(m, n, p, ...)","zeros([m])","zeros([m, n])","zeros([m, n, p, ...])"],description:"Create a matrix containing zeros.",examples:["zeros(3)","zeros(3, 5)","a = [1, 2, 3; 4, 5, 6]","zeros(size(a))"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose"]},combinations:{name:"combinations",category:"Probability",syntax:["combinations(n, k)"],description:"Compute the number of combinations of n items taken k at a time",examples:["combinations(7, 5)"],seealso:["combinationsWithRep","permutations","factorial"]},combinationsWithRep:{name:"combinationsWithRep",category:"Probability",syntax:["combinationsWithRep(n, k)"],description:"Compute the number of combinations of n items taken k at a time with replacements.",examples:["combinationsWithRep(7, 5)"],seealso:["combinations","permutations","factorial"]},factorial:{name:"factorial",category:"Probability",syntax:["n!","factorial(n)"],description:"Compute the factorial of a value",examples:["5!","5 * 4 * 3 * 2 * 1","3!"],seealso:["combinations","combinationsWithRep","permutations","gamma"]},gamma:{name:"gamma",category:"Probability",syntax:["gamma(n)"],description:"Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.",examples:["gamma(4)","3!","gamma(1/2)","sqrt(pi)"],seealso:["factorial"]},kldivergence:{name:"kldivergence",category:"Probability",syntax:["kldivergence(x, y)"],description:"Calculate the Kullback-Leibler (KL) divergence between two distributions.",examples:["kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])"],seealso:[]},multinomial:{name:"multinomial",category:"Probability",syntax:["multinomial(A)"],description:"Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.",examples:["multinomial([1, 2, 1])"],seealso:["combinations","factorial"]},permutations:{name:"permutations",category:"Probability",syntax:["permutations(n)","permutations(n, k)"],description:"Compute the number of permutations of n items taken k at a time",examples:["permutations(5)","permutations(5, 3)"],seealso:["combinations","combinationsWithRep","factorial"]},pickRandom:{name:"pickRandom",category:"Probability",syntax:["pickRandom(array)","pickRandom(array, number)","pickRandom(array, weights)","pickRandom(array, number, weights)","pickRandom(array, weights, number)"],description:"Pick a random entry from a given array.",examples:["pickRandom(0:10)","pickRandom([1, 3, 1, 6])","pickRandom([1, 3, 1, 6], 2)","pickRandom([1, 3, 1, 6], [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)"],seealso:["random","randomInt"]},random:{name:"random",category:"Probability",syntax:["random()","random(max)","random(min, max)","random(size)","random(size, max)","random(size, min, max)"],description:"Return a random number.",examples:["random()","random(10, 20)","random([2, 3])"],seealso:["pickRandom","randomInt"]},randomInt:{name:"randomInt",category:"Probability",syntax:["randomInt(max)","randomInt(min, max)","randomInt(size)","randomInt(size, max)","randomInt(size, min, max)"],description:"Return a random integer number",examples:["randomInt(10, 20)","randomInt([2, 3], 10)"],seealso:["pickRandom","random"]},compare:{name:"compare",category:"Relational",syntax:["compare(x, y)"],description:"Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compare(2, 3)","compare(3, 2)","compare(2, 2)","compare(5cm, 40mm)","compare(2, [1, 2, 3])"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compareNatural","compareText"]},compareNatural:{name:"compareNatural",category:"Relational",syntax:["compareNatural(x, y)"],description:"Compare two values of any type in a deterministic, natural way. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compareNatural(2, 3)","compareNatural(3, 2)","compareNatural(2, 2)","compareNatural(5cm, 40mm)",'compareNatural("2", "10")',"compareNatural(2 + 3i, 2 + 4i)","compareNatural([1, 2, 4], [1, 2, 3])","compareNatural([1, 5], [1, 2, 3])","compareNatural([1, 2], [1, 2])","compareNatural({a: 2}, {a: 4})"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare","compareText"]},compareText:{name:"compareText",category:"Relational",syntax:["compareText(x, y)"],description:"Compare two strings lexically. Comparison is case sensitive. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:['compareText("B", "A")','compareText("A", "B")','compareText("A", "A")','compareText("2", "10")','compare("2", "10")',"compare(2, 10)",'compareNatural("2", "10")','compareText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural"]},deepEqual:{name:"deepEqual",category:"Relational",syntax:["deepEqual(x, y)"],description:"Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.",examples:["deepEqual([1,3,4], [1,3,4])","deepEqual([1,3,4], [1,3])"],seealso:["equal","unequal","smaller","larger","smallerEq","largerEq","compare"]},equal:{name:"equal",category:"Relational",syntax:["x == y","equal(x, y)"],description:"Check equality of two values. Returns true if the values are equal, and false if not.",examples:["2+2 == 3","2+2 == 4","a = 3.2","b = 6-2.8","a == b","50cm == 0.5m"],seealso:["unequal","smaller","larger","smallerEq","largerEq","compare","deepEqual","equalText"]},equalText:{name:"equalText",category:"Relational",syntax:["equalText(x, y)"],description:"Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.",examples:['equalText("Hello", "Hello")','equalText("a", "A")','equal("2e3", "2000")','equalText("2e3", "2000")','equalText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural","compareText","equal"]},larger:{name:"larger",category:"Relational",syntax:["x > y","larger(x, y)"],description:"Check if value x is larger than y. Returns true if x is larger than y, and false if not.",examples:["2 > 3","5 > 2*2","a = 3.3","b = 6-2.8","(a > b)","(b < a)","5 cm > 2 inch"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare"]},largerEq:{name:"largerEq",category:"Relational",syntax:["x >= y","largerEq(x, y)"],description:"Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.",examples:["2 >= 1+1","2 > 1+1","a = 3.2","b = 6-2.8","(a >= b)"],seealso:["equal","unequal","smallerEq","smaller","compare"]},smaller:{name:"smaller",category:"Relational",syntax:["x < y","smaller(x, y)"],description:"Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.",examples:["2 < 3","5 < 2*2","a = 3.3","b = 6-2.8","(a < b)","5 cm < 2 inch"],seealso:["equal","unequal","larger","smallerEq","largerEq","compare"]},smallerEq:{name:"smallerEq",category:"Relational",syntax:["x <= y","smallerEq(x, y)"],description:"Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.",examples:["2 <= 1+1","2 < 1+1","a = 3.2","b = 6-2.8","(a <= b)"],seealso:["equal","unequal","larger","smaller","largerEq","compare"]},unequal:{name:"unequal",category:"Relational",syntax:["x != y","unequal(x, y)"],description:"Check unequality of two values. Returns true if the values are unequal, and false if they are equal.",examples:["2+2 != 3","2+2 != 4","a = 3.2","b = 6-2.8","a != b","50cm != 0.5m","5 cm != 2 inch"],seealso:["equal","smaller","larger","smallerEq","largerEq","compare","deepEqual"]},setCartesian:{name:"setCartesian",category:"Set",syntax:["setCartesian(set1, set2)"],description:"Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setCartesian([1, 2], [3, 4])"],seealso:["setUnion","setIntersect","setDifference","setPowerset"]},setDifference:{name:"setDifference",category:"Set",syntax:["setDifference(set1, set2)"],description:"Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setDifference([1, 2, 3, 4], [3, 4, 5, 6])","setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setSymDifference"]},setDistinct:{name:"setDistinct",category:"Set",syntax:["setDistinct(set)"],description:"Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setDistinct([1, 1, 1, 2, 2, 3])"],seealso:["setMultiplicity"]},setIntersect:{name:"setIntersect",category:"Set",syntax:["setIntersect(set1, set2)"],description:"Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIntersect([1, 2, 3, 4], [3, 4, 5, 6])","setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setDifference"]},setIsSubset:{name:"setIsSubset",category:"Set",syntax:["setIsSubset(set1, set2)"],description:"Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIsSubset([1, 2], [3, 4, 5, 6])","setIsSubset([3, 4], [3, 4, 5, 6])"],seealso:["setUnion","setIntersect","setDifference"]},setMultiplicity:{name:"setMultiplicity",category:"Set",syntax:["setMultiplicity(element, set)"],description:"Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setMultiplicity(1, [1, 2, 2, 4])","setMultiplicity(2, [1, 2, 2, 4])"],seealso:["setDistinct","setSize"]},setPowerset:{name:"setPowerset",category:"Set",syntax:["setPowerset(set)"],description:"Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setPowerset([1, 2, 3])"],seealso:["setCartesian"]},setSize:{name:"setSize",category:"Set",syntax:["setSize(set)","setSize(set, unique)"],description:'Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.',examples:["setSize([1, 2, 2, 4])","setSize([1, 2, 2, 4], true)"],seealso:["setUnion","setIntersect","setDifference"]},setSymDifference:{name:"setSymDifference",category:"Set",syntax:["setSymDifference(set1, set2)"],description:"Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])","setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setDifference"]},setUnion:{name:"setUnion",category:"Set",syntax:["setUnion(set1, set2)"],description:"Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setUnion([1, 2, 3, 4], [3, 4, 5, 6])","setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setIntersect","setDifference"]},erf:{name:"erf",category:"Special",syntax:["erf(x)"],description:"Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x",examples:["erf(0.2)","erf(-0.5)","erf(4)"],seealso:[]},mad:{name:"mad",category:"Statistics",syntax:["mad(a, b, c, ...)","mad(A)"],description:"Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.",examples:["mad(10, 20, 30)","mad([1, 2, 3])"],seealso:["mean","median","std","abs"]},max:{name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dim)"],description:"Compute the maximum value of a list of values.",examples:["max(2, 3, 4, 1)","max([2, 3, 4, 1])","max([2, 5; 4, 3])","max([2, 5; 4, 3], 1)","max([2, 5; 4, 3], 2)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["mean","median","min","prod","std","sum","variance"]},mean:{name:"mean",category:"Statistics",syntax:["mean(a, b, c, ...)","mean(A)","mean(A, dim)"],description:"Compute the arithmetic mean of a list of values.",examples:["mean(2, 3, 4, 1)","mean([2, 3, 4, 1])","mean([2, 5; 4, 3])","mean([2, 5; 4, 3], 1)","mean([2, 5; 4, 3], 2)","mean([1.0, 2.7, 3.2, 4.0])"],seealso:["max","median","min","prod","std","sum","variance"]},median:{name:"median",category:"Statistics",syntax:["median(a, b, c, ...)","median(A)"],description:"Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.",examples:["median(5, 2, 7)","median([3, -1, 5, 7])"],seealso:["max","mean","min","prod","std","sum","variance","quantileSeq"]},min:{name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dim)"],description:"Compute the minimum value of a list of values.",examples:["min(2, 3, 4, 1)","min([2, 3, 4, 1])","min([2, 5; 4, 3])","min([2, 5; 4, 3], 1)","min([2, 5; 4, 3], 2)","min(2.7, 7.1, -4.5, 2.0, 4.1)","max(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["max","mean","median","prod","std","sum","variance"]},mode:{name:"mode",category:"Statistics",syntax:["mode(a, b, c, ...)","mode(A)","mode(A, a, b, B, c, ...)"],description:"Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.",examples:["mode(2, 1, 4, 3, 1)","mode([1, 2.7, 3.2, 4, 2.7])","mode(1, 4, 6, 1, 6)"],seealso:["max","mean","min","median","prod","std","sum","variance"]},prod:{name:"prod",category:"Statistics",syntax:["prod(a, b, c, ...)","prod(A)"],description:"Compute the product of all values.",examples:["prod(2, 3, 4)","prod([2, 3, 4])","prod([2, 5; 4, 3])"],seealso:["max","mean","min","median","min","std","sum","variance"]},quantileSeq:{name:"quantileSeq",category:"Statistics",syntax:["quantileSeq(A, prob[, sorted])","quantileSeq(A, [prob1, prob2, ...][, sorted])","quantileSeq(A, N[, sorted])"],description:"Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probablity are: Number, BigNumber. \n\nIn case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.",examples:["quantileSeq([3, -1, 5, 7], 0.5)","quantileSeq([3, -1, 5, 7], [1/3, 2/3])","quantileSeq([3, -1, 5, 7], 2)","quantileSeq([-1, 3, 5, 7], 0.5, true)"],seealso:["mean","median","min","max","prod","std","sum","variance"]},std:{name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, normalization)"],description:'Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["std(2, 4, 6)","std([2, 4, 6, 8])",'std([2, 4, 6, 8], "uncorrected")','std([2, 4, 6, 8], "biased")',"std([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","prod","sum","variance"]},sum:{name:"sum",category:"Statistics",syntax:["sum(a, b, c, ...)","sum(A)"],description:"Compute the sum of all values.",examples:["sum(2, 3, 4, 1)","sum([2, 3, 4, 1])","sum([2, 5; 4, 3])"],seealso:["max","mean","median","min","prod","std","sum","variance"]},variance:{name:"variance",category:"Statistics",syntax:["variance(a, b, c, ...)","variance(A)","variance(A, normalization)"],description:'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["variance(2, 4, 6)","variance([2, 4, 6, 8])",'variance([2, 4, 6, 8], "uncorrected")','variance([2, 4, 6, 8], "biased")',"variance([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","std","sum"]},acos:{name:"acos",category:"Trigonometry",syntax:["acos(x)"],description:"Compute the inverse cosine of a value in radians.",examples:["acos(0.5)","acos(cos(2.3))"],seealso:["cos","atan","asin"]},acosh:{name:"acosh",category:"Trigonometry",syntax:["acosh(x)"],description:"Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",examples:["acosh(1.5)"],seealso:["cosh","asinh","atanh"]},acot:{name:"acot",category:"Trigonometry",syntax:["acot(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acot(0.5)","acot(cot(0.5))","acot(2)"],seealso:["cot","atan"]},acoth:{name:"acoth",category:"Trigonometry",syntax:["acoth(x)"],description:"Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",examples:["acoth(2)","acoth(0.5)"],seealso:["acsch","asech"]},acsc:{name:"acsc",category:"Trigonometry",syntax:["acsc(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acsc(2)","acsc(csc(0.5))","acsc(0.5)"],seealso:["csc","asin","asec"]},acsch:{name:"acsch",category:"Trigonometry",syntax:["acsch(x)"],description:"Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",examples:["acsch(0.5)"],seealso:["asech","acoth"]},asec:{name:"asec",category:"Trigonometry",syntax:["asec(x)"],description:"Calculate the inverse secant of a value.",examples:["asec(0.5)","asec(sec(0.5))","asec(2)"],seealso:["acos","acot","acsc"]},asech:{name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},asin:{name:"asin",category:"Trigonometry",syntax:["asin(x)"],description:"Compute the inverse sine of a value in radians.",examples:["asin(0.5)","asin(sin(0.5))"],seealso:["sin","acos","atan"]},asinh:{name:"asinh",category:"Trigonometry",syntax:["asinh(x)"],description:"Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",examples:["asinh(0.5)"],seealso:["acosh","atanh"]},atan:{name:"atan",category:"Trigonometry",syntax:["atan(x)"],description:"Compute the inverse tangent of a value in radians.",examples:["atan(0.5)","atan(tan(0.5))"],seealso:["tan","acos","asin"]},atanh:{name:"atanh",category:"Trigonometry",syntax:["atanh(x)"],description:"Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",examples:["atanh(0.5)"],seealso:["acosh","asinh"]},atan2:{name:"atan2",category:"Trigonometry",syntax:["atan2(y, x)"],description:"Computes the principal value of the arc tangent of y/x in radians.",examples:["atan2(2, 2) / pi","angle = 60 deg in rad","x = cos(angle)","y = sin(angle)","atan2(y, x)"],seealso:["sin","cos","tan"]},cos:{name:"cos",category:"Trigonometry",syntax:["cos(x)"],description:"Compute the cosine of x in radians.",examples:["cos(2)","cos(pi / 4) ^ 2","cos(180 deg)","cos(60 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["acos","sin","tan"]},cosh:{name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},cot:{name:"cot",category:"Trigonometry",syntax:["cot(x)"],description:"Compute the cotangent of x in radians. Defined as 1/tan(x)",examples:["cot(2)","1 / tan(2)"],seealso:["sec","csc","tan"]},coth:{name:"coth",category:"Trigonometry",syntax:["coth(x)"],description:"Compute the hyperbolic cotangent of x in radians.",examples:["coth(2)","1 / tanh(2)"],seealso:["sech","csch","tanh"]},csc:{name:"csc",category:"Trigonometry",syntax:["csc(x)"],description:"Compute the cosecant of x in radians. Defined as 1/sin(x)",examples:["csc(2)","1 / sin(2)"],seealso:["sec","cot","sin"]},csch:{name:"csch",category:"Trigonometry",syntax:["csch(x)"],description:"Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)",examples:["csch(2)","1 / sinh(2)"],seealso:["sech","coth","sinh"]},sec:{name:"sec",category:"Trigonometry",syntax:["sec(x)"],description:"Compute the secant of x in radians. Defined as 1/cos(x)",examples:["sec(2)","1 / cos(2)"],seealso:["cot","csc","cos"]},sech:{name:"sech",category:"Trigonometry",syntax:["sech(x)"],description:"Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)",examples:["sech(2)","1 / cosh(2)"],seealso:["coth","csch","cosh"]},sin:{name:"sin",category:"Trigonometry",syntax:["sin(x)"],description:"Compute the sine of x in radians.",examples:["sin(2)","sin(pi / 4) ^ 2","sin(90 deg)","sin(30 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["asin","cos","tan"]},sinh:{name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},tan:{name:"tan",category:"Trigonometry",syntax:["tan(x)"],description:"Compute the tangent of x in radians.",examples:["tan(0.5)","sin(0.5) / cos(0.5)","tan(pi / 4)","tan(45 deg)"],seealso:["atan","sin","cos"]},tanh:{name:"tanh",category:"Trigonometry",syntax:["tanh(x)"],description:"Compute the hyperbolic tangent of x in radians.",examples:["tanh(0.5)","sinh(0.5) / cosh(0.5)"],seealso:["sinh","cosh"]},to:{name:"to",category:"Units",syntax:["x to unit","to(x, unit)"],description:"Change the unit of a value.",examples:["5 inch to cm","3.2kg to g","16 bytes in bits"],seealso:[]},clone:{name:"clone",category:"Utils",syntax:["clone(x)"],description:"Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices",examples:["clone(3.5)","clone(2 - 4i)","clone(45 deg)","clone([1, 2; 3, 4])",'clone("hello world")'],seealso:[]},format:{name:"format",category:"Utils",syntax:["format(value)","format(value, precision)"],description:"Format a value of any type as string.",examples:["format(2.3)","format(3 - 4i)","format([])","format(pi, 3)"],seealso:["print"]},isNaN:{name:"isNaN",category:"Utils",syntax:["isNaN(x)"],description:"Test whether a value is NaN (not a number)",examples:["isNaN(2)","isNaN(0 / 0)","isNaN(NaN)","isNaN(Infinity)"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isInteger:{name:"isInteger",category:"Utils",syntax:["isInteger(x)"],description:"Test whether a value is an integer number.",examples:["isInteger(2)","isInteger(3.5)","isInteger([3, 0.5, -2])"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isNegative:{name:"isNegative",category:"Utils",syntax:["isNegative(x)"],description:"Test whether a value is negative: smaller than zero.",examples:["isNegative(2)","isNegative(0)","isNegative(-4)","isNegative([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isPositive","isZero"]},isNumeric:{name:"isNumeric",category:"Utils",syntax:["isNumeric(x)"],description:"Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.",examples:["isNumeric(2)",'isNumeric("2")','hasNumericValue("2")',"isNumeric(0)","isNumeric(bignumber(500))","isNumeric(fraction(0.125))","isNumeric(2 + 3i)",'isNumeric([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","hasNumericValue"]},hasNumericValue:{name:"hasNumericValue",category:"Utils",syntax:["hasNumericValue(x)"],description:"Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.",examples:["hasNumericValue(2)",'hasNumericValue("2")','isNumeric("2")',"hasNumericValue(0)","hasNumericValue(bignumber(500))","hasNumericValue(fraction(0.125))","hasNumericValue(2 + 3i)",'hasNumericValue([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","isNumeric"]},isPositive:{name:"isPositive",category:"Utils",syntax:["isPositive(x)"],description:"Test whether a value is positive: larger than zero.",examples:["isPositive(2)","isPositive(0)","isPositive(-4)","isPositive([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isPrime:{name:"isPrime",category:"Utils",syntax:["isPrime(x)"],description:"Test whether a value is prime: has no divisors other than itself and one.",examples:["isPrime(3)","isPrime(-2)","isPrime([2, 17, 100])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isZero:{name:"isZero",category:"Utils",syntax:["isZero(x)"],description:"Test whether a value is zero.",examples:["isZero(2)","isZero(0)","isZero(-4)","isZero([3, 0, -2, 0])"],seealso:["isInteger","isNumeric","isNegative","isPositive"]},typeOf:{name:"typeOf",category:"Utils",syntax:["typeOf(x)"],description:"Get the type of a variable.",examples:["typeOf(3.5)","typeOf(2 - 4i)","typeOf(45 deg)",'typeOf("hello world")'],seealso:["getMatrixDataType"]},numeric:{name:"numeric",category:"Utils",syntax:["numeric(x)"],description:"Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.",examples:['numeric("4")','numeric("4", "number")','numeric("4", "BigNumber")','numeric("4", "Fraction)','numeric(4, "Fraction")','numeric(fraction(2, 5), "number)'],seealso:["number","fraction","bignumber","string","format"]}},jl=["typed","mathWithTransform","Help"],El=Object(s.a)("help",jl,function(e){var t=e.typed,a=e.mathWithTransform,o=e.Help;return t("help",{any:function(e){var t,r=e;if("string"!=typeof e)for(t in a)if(Object(ae.f)(a,t)&&e===a[t]){r=t;break}var n=zi(Ml,r);if(n)return new o(n);var i="function"==typeof r?r.name:r;throw new Error('No documentation found on "'+i+'"')}})}),Sl=["typed","Chain"],Al=Object(s.a)("chain",Sl,function(e){var t=e.typed,r=e.Chain;return t("chain",{"":function(){return new r},any:function(e){return new r(e)}})}),Cl=["typed","matrix","subtract","multiply","unaryMinus","lup"],Tl=Object(s.a)("det",Cl,function(e){var t=e.typed,n=e.matrix,f=e.subtract,l=e.multiply,p=e.unaryMinus,m=e.lup;return t("det",{any:function(e){return Object(ae.a)(e)},"Array | Matrix":function(e){var t=Object(ie.v)(e)?e.size():Array.isArray(e)?(e=n(e)).size():[];switch(t.length){case 0:return Object(ae.a)(e);case 1:if(1===t[0])return Object(ae.a)(e.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+Object(V.d)(t)+")");case 2:var r=t[0];if(r===t[1])return function(e,t){{if(1===t)return Object(ae.a)(e[0][0]);if(2===t)return f(l(e[0][0],e[1][1]),l(e[1][0],e[0][1]));for(var r=m(e),n=r.U[0][0],i=1;il&&(l=M(u[m][f]),p=m),m++;if(0===l)throw Error("Cannot calculate inverse, determinant is zero");(m=p)!==f&&(o=u[f],u[f]=u[m],u[m]=o,o=c[f],c[f]=c[m],c[m]=o);var h=u[f],d=c[f];for(m=0;m=l(n);){var s=o[0][0],u=o[0][1];t=function(e,t,r){var n=g(t,e);return l(n)<=d.epsilon?w(-1).acos().div(4):x(.5,p(N(2,r,m(n))))}(e[s][s],e[u][u],e[s][u]),e=function(e,t,r,n){for(var i=e.length,a=w(v(t)),o=w(b(t)),s=x(a,a),u=x(o,o),c=E(i,w(0)),f=E(i,w(0)),l=N(w(2),a,o,e[r][n]),p=y(g(x(s,e[r][r]),l),x(u,e[n][n])),m=O(x(u,e[r][r]),l,x(s,e[n][n])),h=0;h=Math.abs(n);){var l=f[0][0],p=f[0][1];o=e[l][l],s=e[p][p],u=e[l][p],c=void 0,c=s-o,e=function(e,t,r,n){for(var i=e.length,a=Math.cos(t),o=Math.sin(t),s=a*a,u=o*o,c=E(i,0),f=E(i,0),l=s*e[r][r]-2*a*o*e[r][n]+u*e[n][n],p=u*e[r][r]+2*a*o*e[r][n]+s*e[n][n],m=0;m>1;return up(e,r)*up(1+r,t)}function cp(e,t){if(!Object(E.i)(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!Object(E.i)(t)||t<0)throw new TypeError("Positive integer value expected in function combinations");if(e");if(2!==u.length)throw SyntaxError("Could not parse rule: "+a);a={l:u[0],r:u[1]};case"object":o={l:T(c(a.l)),r:T(c(a.r))},a.context&&(o.evaluate=a.context),a.evaluate&&(o.evaluate=c(a.evaluate)),M(o.l)&&(n=A(o.l),i=new v("_p"+q++),o.expanded={},o.expanded.l=n([o.l.clone(),i]),j(o.expanded.l),E(o.expanded.l),o.expanded.r=n([o.r,i]));break;case"function":o=a;break;default:throw TypeError("Unsupported type of rule: "+s)}t.push(o)}return t}(t);for(var i=w(e,r),a={},o=(i=T(i)).toString({parenthesis:"all"});!a[o];){a[o]=!0;for(var s=q=0;s