!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){var a;!function(){"use strict";function n(e){return.5*(Math.exp(e)+Math.exp(-e))}function i(e){return.5*(Math.exp(e)-Math.exp(-e))}var u=function(){throw SyntaxError("Invalid Param")};function o(e,t){var r=Math.abs(e),n=Math.abs(t);return 0===e?Math.log(n):0===t?Math.log(r):r<3e3&&n<3e3?.5*Math.log(e*e+t*t):Math.log(e/Math.cos(Math.atan2(t,e)))}function c(e,t){if(!(this instanceof c))return new c(e,t);t=function(e,t){var r={re:0,im:0};if(null==e)r.re=r.im=0;else if(void 0!==t)r.re=e,r.im=t;else switch(typeof e){case"object":if("im"in e&&"re"in e)r.re=e.re,r.im=e.im;else if("abs"in e&&"arg"in e){if(!Number.isFinite(e.abs)&&Number.isFinite(e.arg))return c.INFINITY;r.re=e.abs*Math.cos(e.arg),r.im=e.abs*Math.sin(e.arg)}else if("r"in e&&"phi"in e){if(!Number.isFinite(e.r)&&Number.isFinite(e.phi))return c.INFINITY;r.re=e.r*Math.cos(e.phi),r.im=e.r*Math.sin(e.phi)}else 2===e.length?(r.re=e[0],r.im=e[1]):u();break;case"string":r.im=r.re=0;var n=e.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),i=1,a=0;null===n&&u();for(var o=0;o>=1)1&t&&(n=n*e%r);return n}(10,i,e),n=0;n<300;n++){if(t===r)return n;t=10*t%e,r=10*r%e}return 0}(r),a=-1===this.s?"-":"";if(a+=t/r|0,t%=r,(t*=10)&&(a+="."),i){for(var o=n;o--;)a+=t/r|0,t%=r,t*=10;for(a+="(",o=i;o--;)a+=t/r|0,t%=r,t*=10;a+=")"}else for(o=e;t&&o--;)a+=t/r|0,t%=r,t*=10;return a}},void 0===(a=function(){return u}.apply(i,[]))||(n.exports=a)}()},function(e,t){e.exports=function t(e,r){"use strict";function n(e){return t.insensitive&&(""+e).toLowerCase()||""+e}var i,a,o=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,s=/(^[ ]*|[ ]*$)/g,u=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,c=/^0x[0-9a-f]+$/i,f=/^0/,e=n(e).replace(s,"")||"",s=n(r).replace(s,"")||"",l=e.replace(o,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),p=s.replace(o,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),e=parseInt(e.match(c),16)||1!==l.length&&e.match(u)&&Date.parse(e),s=parseInt(s.match(c),16)||e&&s.match(u)&&Date.parse(s)||null;if(s){if(er-1&&(void 0===a[n+1]&&(a[n+1]=0),a[n+1]+=a[n]/r|0,a[n]%=r)}return a.reverse()}v.absoluteValue=v.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),k(e)},v.ceil=function(){return k(new this.constructor(this),this.e+1,2)},v.comparedTo=v.cmp=function(e){var t,r,n=this,i=n.d,a=(e=new n.constructor(e)).d,o=n.s,s=e.s;if(!i||!a)return o&&s?o!==s?o:i===a?0:!i^o<0?1:-1:NaN;if(!i[0]||!a[0])return i[0]?o:a[0]?-s:0;if(o!==s)return o;if(n.e!==e.e)return n.e>e.e^o<0?1:-1;for(t=0,r=(n=i.length)<(e=a.length)?n:e;ta[t]^o<0?1:-1;return n===e?0:ethis.d.length-2},v.isNaN=function(){return!this.s},v.isNegative=v.isNeg=function(){return this.s<0},v.isPositive=v.isPos=function(){return 0(n=Math.max(Math.ceil(s/7),o)+2)&&(a=n,t.length=1),t.reverse(),n=a;n--;)t.push(0);t.reverse()}else{for((f=(n=c.length)<(o=l.length))&&(o=n),n=0;n(i=(f=Math.ceil(a/7))>i?f+1:i+1)&&(n=i,r.length=1),r.reverse();n--;)r.push(0);r.reverse()}for((i=s.length)-(n=u.length)<0&&(n=i,r=u,u=s,s=r),t=0;n;)t=(s[--n]=s[n]+u[n]+t)/z|0,s[n]%=z;for(t&&(s.unshift(t),++c),i=s.length;0==s[--i];)s.pop();return e.d=s,e.e=A(s,c),x?k(e,a,o):e},v.precision=v.sd=function(e){var t;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(d+e);return this.d?(t=D(this.d),e&&this.e+1>t&&(t=this.e+1)):t=NaN,t},v.round=function(){var e=this.constructor;return k(new e(this),this.e+1,e.rounding)},v.sine=v.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())+7,n.rounding=1,r=function(e,t){var r,n=t.d.length;if(n<3)return $(e,2,t,t);r=16<(r=1.4*Math.sqrt(n))?16:0|r,t=$(e,2,t=t.times(1/G(5,r)),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,V(n,r)),n.precision=e,n.rounding=t,k(2=e.d.length-1&&(r=c<0?-c:c)<=9007199254740991)return i=j(u,s,r,n),e.s<0?new u(1).div(i):k(i,n,a);if((o=s.s)<0){if(tu.maxE+1||t=n.toExpPos):(w(e,1,1e9),void 0===t?t=n.rounding:w(t,0,8),E(r=k(new n(r),e,t),e<=r.e||r.e<=n.toExpNeg,e));return r.isNeg()&&!r.isZero()?"-"+e:e},v.toSignificantDigits=v.toSD=function(e,t){var r=this.constructor;return void 0===e?(e=r.precision,t=r.rounding):(w(e,1,1e9),void 0===t?t=r.rounding:w(t,0,8)),k(new r(this),e,t)},v.toString=function(){var e=this,t=e.constructor,t=E(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+t:t},v.truncated=v.trunc=function(){return k(new this.constructor(this),this.e+1,1)},v.valueOf=v.toJSON=function(){var e=this,t=e.constructor,t=E(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+t:t};var S=function(e,t,r,n,i,a){var o,s,u,c,f,l,p,m,h,d,y,g,v,x,b,w,N,M,S,E=e.constructor,A=e.s==t.s?1:-1,O=e.d,C=t.d;if(!(O&&O[0]&&C&&C[0]))return new E(e.s&&t.s&&(O?!C||O[0]!=C[0]:C)?O&&0==O[0]||!C?0*A:A/0:NaN);for(s=a?(f=1,e.e-t.e):(a=z,f=7,T(e.e/f)-T(t.e/f)),M=C.length,w=O.length,h=(A=new E(A)).d=[],u=0;C[u]==(O[u]||0);u++);if(C[u]>(O[u]||0)&&s--,null==r?(v=r=E.precision,n=E.rounding):v=i?r+(e.e-t.e)+1:r,v<0)h.push(1),l=!0;else{if(v=v/f+2|0,u=0,1==M){for(C=C[c=0],v++;(u=a/2&&++N;c=0,(o=I(C,d,M,y))<0?(g=d[0],M!=y&&(g=g*a+(d[1]||0)),1<(c=g/N|0)?(a<=c&&(c=a-1),1==(o=I(p=q(C,c,a),d,m=p.length,y=d.length))&&(c--,B(p,Mt[i]?1:-1;break}return a}function B(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]=(s=f.length)){if(!n)break e;for(;s++<=l;)f.push(0);c=u=0,o=(a%=7)-7+(i=1)}else{for(c=s=f[l],i=1;10<=s;s/=10)i++;u=(o=(a%=7)-7+i)<0?0:c/y(10,i-o-1)%10|0}if(n=n||t<0||void 0!==f[l+1]||(o<0?c:c%y(10,i-o-1)),u=r<4?(u||n)&&(0==r||r==(e.s<0?3:2)):5p.maxE?(e.d=null,e.e=NaN):e.ee.constructor.maxE?(e.d=null,e.e=NaN):e.ei-1;)f[r]=0,r||(++a,f.unshift(1));for(s=f.length;!f[s-1];--s);for(o=0,c="";os)for(a-=s;a--;)c+="0";else at&&(e.length=t,1)}function W(e){return new this(e).abs()}function J(e){return new this(e).acos()}function Y(e){return new this(e).acosh()}function X(e,t){return new this(e).plus(t)}function Q(e){return new this(e).asin()}function K(e){return new this(e).asinh()}function ee(e){return new this(e).atan()}function te(e){return new this(e).atanh()}function re(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?C(this,n,i):new this(0)).s=e.s:!e.d||t.isZero()?(r=C(this,a,1).times(.5)).s=e.s:r=t.s<0?(this.precision=a,this.rounding=1,r=this.atan(S(e,t,a,1)),t=C(this,a,1),this.precision=n,this.rounding=i,e.s<0?r.minus(t):r.plus(t)):this.atan(S(e,t,a,1)):(r=C(this,a,1).times(0a.maxE?(i.e=NaN,i.d=null):e.et?(n=new TypeError("Too many arguments in function "+a+" (expected: "+t+", actual: "+r.length+")")).data={category:"tooManyArgs",fn:a,index:r.length,expectedLength:t}:(n=new TypeError('Arguments of type "'+r.join(", ")+'" do not match any of the defined signatures of function '+a+".")).data={category:"mismatch",actual:r.map(G)}),n}(t,arguments,i)}function o(e,t){return(arguments.length===B&&d(e)&&w(t)?C:arguments.length===k&&y(e)&&N(t)?_:arguments.length===D&&g(e)&&M(t)?T:arguments.length===R&&v(e)&&S(t)?z:arguments.length===j&&x(e)&&E(t)?q:arguments.length===P&&b(e)&&A(t)?I:a).apply(o,arguments)}var s,e=i[0]&&i[0].params.length<=2&&!Z(i[0].params),u=i[1]&&i[1].params.length<=2&&!Z(i[1].params),c=i[2]&&i[2].params.length<=2&&!Z(i[2].params),f=i[3]&&i[3].params.length<=2&&!Z(i[3].params),l=i[4]&&i[4].params.length<=2&&!Z(i[4].params),p=i[5]&&i[5].params.length<=2&&!Z(i[5].params),m=e&&u&&c&&f&&l&&p,h=i.map(function(e){return function(e){var r,t,n;if(Z(e)){var i=(r=e.slice(0,e.length-1).map(J)).length,a=J(se(e));return function(e){for(var t=0;t=i+1}}return 0===e.length?function(e){return 0===e.length}:1===e.length?(t=J(e[0]),function(e){return t(e[0])&&1===e.length}):2===e.length?(t=J(e[0]),n=J(e[1]),function(e){return t(e[0])&&n(e[1])&&2===e.length}):(r=e.map(J),function(e){for(var t=0;t=e.length&&n.slice(0,e.length)===e&&(i+=a[o[t]],n=n.slice(e.length,n.length),r=!0)}),r||(i+=n.slice(0,1),n=n.slice(1,n.length))}();return i}},function(e,n,o){(function(e){var r;!function(e){function i(e){var n,t=this,r=(n=4022871197,function(e){e=String(e);for(var t=0;t>>0,n=(r*=n)>>>0,n+=4294967296*(r-=n)}return 2.3283064365386963e-10*(n>>>0)});t.next=function(){var e=2091639*t.s0+2.3283064365386963e-10*t.c;return t.s0=t.s1,t.s1=t.s2,t.s2=e-(t.c=0|e)},t.c=1,t.s0=r(" "),t.s1=r(" "),t.s2=r(" "),t.s0-=r(e),t.s0<0&&(t.s0+=1),t.s1-=r(e),t.s1<0&&(t.s1+=1),t.s2-=r(e),t.s2<0&&(t.s2+=1),r=null}function a(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function t(e,t){var r=new i(e),t=t&&t.state,n=r.next;return n.int32=function(){return 4294967296*r.next()|0},n.double=function(){return n()+11102230246251565e-32*(2097152*n()|0)},n.quick=n,t&&("object"==typeof t&&a(t,r),n.state=function(){return a(r,{})}),n}e&&e.exports?e.exports=t:o(2)&&o(6)?void 0===(r=function(){return t}.call(n,o,n,e))||(e.exports=r):this.alea=t}(e,o(2))}).call(this,o(5)(e))},function(e,a,o){(function(e){var r;!function(e){function n(e){var t=this,r="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:r+=e;for(var n=0;n>>0)/4294967296};return t.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},t.int32=r.next,t.quick=t,e&&("object"==typeof e&&i(e,r),t.state=function(){return i(r,{})}),t}e&&e.exports?e.exports=t:o(2)&&o(6)?void 0===(r=function(){return t}.call(a,o,a,e))||(e.exports=r):this.xor128=t}(e,o(2))}).call(this,o(5)(e))},function(e,a,o){(function(e){var r;!function(e){function n(e){var t=this,r="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,e===((t.v=0)|e)?t.x=e:r+=e;for(var n=0;n>>4),t.next()}function i(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function t(e,t){var r=new n(e),e=t&&t.state,t=function(){return(r.next()>>>0)/4294967296};return t.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},t.int32=r.next,t.quick=t,e&&("object"==typeof e&&i(e,r),t.state=function(){return i(r,{})}),t}e&&e.exports?e.exports=t:o(2)&&o(6)?void 0===(r=function(){return t}.call(a,o,a,e))||(e.exports=r):this.xorwow=t}(e,o(2))}).call(this,o(5)(e))},function(e,a,o){(function(e){var r;!function(e){function n(e){var i=this;i.next=function(){var e=i.x,t=i.i,r=e[t],n=(r^=r>>>7)^r<<24;return n^=(r=e[t+1&7])^r>>>10,n^=(r=e[t+3&7])^r>>>3,n^=(r=e[t+4&7])^r<<7,r=e[t+7&7],n^=(r^=r<<13)^r<<9,e[t]=n,i.i=t+1&7,n},function(e,t){var r,n=[];if(t===(0|t))n[0]=t;else for(t=""+t,r=0;r>>0)/4294967296};return t.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},t.int32=r.next,t.quick=t,e&&(e.x&&i(e,r),t.state=function(){return i(r,{})}),t}e&&e.exports?e.exports=t:o(2)&&o(6)?void 0===(r=function(){return t}.call(a,o,a,e))||(e.exports=r):this.xorshift7=t}(e,o(2))}).call(this,o(5)(e))},function(e,a,o){(function(e){var r;!function(e){function n(e){var a=this;a.next=function(){var e,t,r=a.w,n=a.X,i=a.i;return a.w=r=r+1640531527|0,t=n[i+34&127],e=n[i=i+1&127],t^=t<<13,e^=e<<17,t^=t>>>15,e^=e>>>12,t=n[i]=t^e,a.i=i,t+(r^r>>>16)|0},function(e,t){var r,n,i,a,o,s=[],u=128;for(t===(0|t)?(n=t,t=null):(t+="\0",n=0,u=Math.max(u,t.length)),i=0,a=-32;a>>15,n^=n<<4,n^=n>>>13,0<=a&&(o=o+1640531527|0,i=0==(r=s[127&a]^=n+o)?i+1:0);for(128<=i&&(s[127&(t&&t.length||0)]=-1),i=127,a=512;0>>15,r^=r>>>12,s[i]=n^r;e.w=o,e.X=s,e.i=i}(a,e)}function i(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function t(e,t){null==e&&(e=+new Date);var r=new n(e),e=t&&t.state,t=function(){return(r.next()>>>0)/4294967296};return t.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},t.int32=r.next,t.quick=t,e&&(e.X&&i(e,r),t.state=function(){return i(r,{})}),t}e&&e.exports?e.exports=t:o(2)&&o(6)?void 0===(r=function(){return t}.call(a,o,a,e))||(e.exports=r):this.xor4096=t}(e,o(2))}).call(this,o(5)(e))},function(e,a,o){(function(e){var r;!function(e){function n(e){var i=this,t="";i.next=function(){var e=(e=i.b)<<25^e>>>7^(t=i.c),t=t-(r=i.d)|0,r=r<<24^r>>>8^(n=i.a),n=n-e|0;return i.b=e=e<<20^e>>>12^t,i.c=t=t-r|0,i.d=r<<16^t>>>16^n,i.a=n-e|0},i.a=0,i.b=0,i.c=-1640531527,i.d=1367130551,e===Math.floor(e)?(i.a=e/4294967296|0,i.b=0|e):t+=e;for(var r=0;r>>0)/4294967296};return t.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},t.int32=r.next,t.quick=t,e&&("object"==typeof e&&i(e,r),t.state=function(){return i(r,{})}),t}e&&e.exports?e.exports=t:o(2)&&o(6)?void 0===(r=function(){return t}.call(a,o,a,e))||(e.exports=r):this.tychei=t}(e,o(2))}).call(this,o(5)(e))},function(t,r,n){var i;!function(a,o,s){var u,c=s.pow(256,6),f=s.pow(2,52),l=2*f;function e(e,t,r){var n=[],e=h(function e(t,r){var n,i=[],a=typeof t;if(r&&"object"==a)for(n in t)try{i.push(e(t[n],r-1))}catch(e){}return i.length?i:"string"==a?t:t+"\0"}((t=1==t?{entropy:!0}:t||{}).entropy?[e,d(o)]:null==e?function(){try{var e;return u&&(e=u.randomBytes)?e=e(256):(e=new Uint8Array(256),(a.crypto||a.msCrypto).getRandomValues(e)),d(e)}catch(e){var t=a.navigator,t=t&&t.plugins;return[+new Date,a,t,a.screen,d(o)]}}():e,3),n),i=new p(n),n=function(){for(var e=i.g(6),t=c,r=0;e>>=1;return(e+r)/t};return n.int32=function(){return 0|i.g(4)},n.quick=function(){return i.g(4)/4294967296},n.double=n,h(d(i.S),o),(t.pass||r||function(e,t,r,n){return n&&(n.S&&m(n,i),e.state=function(){return m(i,{})}),r?(s.random=e,t):e})(n,e,"global"in t?t.global:this==s,t.state)}function p(e){var t,r=e.length,o=this,n=0,i=o.i=o.j=0,a=o.S=[];for(r||(e=[r++]);n<256;)a[n]=n++;for(n=0;n<256;n++)a[n]=a[i=255&i+e[n%r]+(t=a[n])],a[i]=t;(o.g=function(e){for(var t,r=0,n=o.i,i=o.j,a=o.S;e--;)t=a[n=255&n+1],r=256*r+a[255&(a[n]=a[i=255&i+t])+(a[i]=t)];return o.i=n,o.j=i,r})(256)}function m(e,t){return t.i=e.i,t.j=e.j,t.S=e.S.slice(),t}function h(e,t){for(var r,n=e+"",i=0;iMath.pow(2,r-1)-1||e<-Math.pow(2,r-1))throw new Error("Value must be in range [-2^".concat(r-1,", 2^").concat(r-1,"-1]"));if(!L(e))throw new Error("Value must be an integer");e<0&&(e+=Math.pow(2,r)),i="i".concat(r)}r="";return e<0&&(e=-e,r="-"),"".concat(r).concat(n).concat(e.toString(t)).concat(i)}function V(e,t){if("function"==typeof t)return t(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var r,n,i="auto";if(t&&(t.notation&&(i=t.notation),M(t)?r=t:M(t.precision)&&(r=t.precision),t.wordSize&&"number"!=typeof(n=t.wordSize)))throw new Error('Option "wordSize" must be a number');switch(i){case"fixed":return X(e,r);case"exponential":return Q(e,r);case"engineering":return function(e,t){if(isNaN(e)||!isFinite(e))return String(e);var r=K(Y(e),t),n=r.exponent,i=r.coefficients,a=n%3==0?n:n<0?n-3-n%3:n-n%3;if(M(t))for(;t>i.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 Q(e,t);i=r.coefficients,e=r.exponent;i.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 ee(e){for(var t=[],r=0;r/g,">")}function be(e,t){if(!S(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+J(e)+", index: 0)");if(!S(t))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+J(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}function Me(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function Se(e,t){if(0===t.length){if(Array.isArray(e))throw new we(e.length,0)}else!function e(t,r,n){var i=t.length;if(i!==r[n])throw new we(i,r[n]);if(n")}(e,t,0)}function Ee(e,t){if(!M(e)||!L(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||"number"==typeof t&&t<=e)throw new Ne(e,t)}function Ae(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(!M(e)||!L(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+ge(t)+")")}),function e(t,r,n,i){var a,o=t.length,s=r[n],u=Math.min(o,s);if(t.length=s,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||rt(e),new n(e,0)}},{from:"number",to:"string",convert:function(e){return e+""}},{from:"BigNumber",to:"Complex",convert:function(e){return n||rt(e),new n(e.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(e){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||rt(e),new n(e.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(e){i||nt(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||tt(t);try{return new r(t)}catch(e){throw new Error('Cannot convert "'+t+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(t){i||nt(t);try{return new i(t)}catch(e){throw new Error('Cannot convert "'+t+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(t){n||rt(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||tt(e),new r(+e)}},{from:"boolean",to:"Fraction",convert:function(e){return i||nt(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()}}],e});function tt(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function rt(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function nt(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}var it=Ye("ResultSet",[],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}),at=r(7),ot=r.n(at),st=Ye("BigNumber",["?on","config"],function(e){var t=e.on,e=e.config,r=ot.a.clone({precision:e.precision,modulo:9});return r.prototype.type="BigNumber",r.prototype.isBigNumber=!0,r.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},r.fromJSON=function(e){return new r(e.value)},t&&t("config",function(e,t){e.precision!==t.precision&&r.config({precision:e.precision})}),r},{isClass:!0}),a=r(1),ut=r.n(a);function ct(e){return(ct="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 ft=Ye("Complex",[],function(){return ut.a.prototype.type="Complex",ut.a.prototype.isComplex=!0,ut.a.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},ut.a.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},ut.a.prototype.format=function(e){var t=this.im,r=this.re,n=V(this.re,e),i=V(this.im,e),e=M(e)?e:e?e.precision:null;return null!==e&&(e=Math.pow(10,-e),Math.abs(r/t)t.re?1:e.ret.im?1:e.imn[a]&&(n[a]=t[a],i=!0);i&&s(e,n,r)}return(p.prototype=new e).createDenseMatrix=function(e,t){return new p(e,t)},p.prototype.type="DenseMatrix",p.prototype.isDenseMatrix=!0,p.prototype.getDataType=function(){return Ue(this._data,J)},p.prototype.storage=function(){return"dense"},p.prototype.datatype=function(){return this._datatype},p.prototype.create=function(e,t){return new p(e,t)},p.prototype.subset=function(e,t,r){switch(arguments.length){case 1:return function(e,t){if(!A(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 we(r.length,e._size.length);for(var n=t.min(),i=t.max(),a=0,o=e._size.length;a");c(e,t.max().map(function(e){return e+1}),n);n=a.length;!function r(n,i,a,o,s){var e=s===o-1,t=i.dimension(s);e?t.forEach(function(e,t){Ee(e),n[e]=a[t[0]]}):t.forEach(function(e,t){Ee(e),r(n[e],i,a[t[0]],o,s+1)})}(e._data,t,r,n,0)}return e}(this,e,t,r);default:throw new SyntaxError("Wrong number of arguments")}},p.prototype.get=function(e){if(!x(e))throw new TypeError("Array expected");if(e.length!==this._size.length)throw new we(e.length,this._size.length);for(var t=0;t=n.length)throw new Ne(t,n.length);return E(e)?e.create(wt(e.valueOf(),t,r)):wt(e,t,r)}function wt(e,t,r){var n,i,a,o;if(t<=0){if(Array.isArray(e[0])){for(o=function(e){for(var t=e.length,r=e[0].length,n=[],i=0;it-1&&(e._values.splice(y,1),e._index.splice(y,1),m++)}e._ptr[f]=e._values.length}return e._size[0]=t,e._size[1]=r,e}function t(e,t,r,n,i){for(var a,o=n[0],s=n[1],u=[],c=0;c");for(var c=t.min()[0],f=t.min()[1],l=i[0],p=i[1],m=0;m "+(this._values?ge(this._values[u],e):"X");return i},N.prototype.toString=function(){return ge(this.toArray())},N.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},N.prototype.diagonal=function(e){if(e){if(I(e)&&(e=e.toNumber()),!M(e)||!L(e))throw new TypeError("The parameter k must be an integer number")}else e=0;var t=0Math.pow(2,t)-1)throw new SyntaxError('String "'.concat(e,'" is out of range'));n>=Math.pow(2,t-1)&&(n-=Math.pow(2,t))}return n},BigNumber:function(e){return e.toNumber()},Fraction:function(e){return e.valueOf()},Unit:function(e){throw new Error("Second argument with valueless unit expected")},null:function(e){return 0},"Unit, string | Unit":function(e,t){return e.toNumber(t)},"Array | Matrix":function(e){return xt(e,this)}});return e.fromJSON=function(e){return parseFloat(e.value)},e}),Pt=Ye("string",["typed"],function(e){return(0,e.typed)("string",{"":function(){return""},number:V,null:function(e){return"null"},boolean:function(e){return e+""},string:function(e){return e},"Array | Matrix":function(e){return xt(e,this)},any:function(e){return String(e)}})}),Ut=Ye("boolean",["typed"],function(e){return(0,e.typed)("boolean",{"":function(){return!1},boolean:function(e){return e},number:function(e){return!!e},null:function(e){return!1},BigNumber:function(e){return!e.isZero()},string:function(e){var t=e.toLowerCase();if("true"===t)return!0;if("false"===t)return!1;t=Number(e);if(""!==e&&!isNaN(t))return!!t;throw new Error('Cannot convert "'+e+'" to a boolean')},"Array | Matrix":function(e){return xt(e,this)}})}),Ft=Ye("bignumber",["typed","BigNumber"],function(e){var t=e.typed,i=e.BigNumber;return t("bignumber",{"":function(){return new i(0)},number:function(e){return new i(e+"")},string:function(e){var t=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(t){var r=t[2],n=i(t[1]),t=new i(2).pow(Number(r));if(n.gt(t.sub(1)))throw new SyntaxError('String "'.concat(e,'" is out of range'));r=new i(2).pow(Number(r)-1);return n.gte(r)?n.sub(t):n}return new i(e)},BigNumber:function(e){return e},Fraction:function(e){return new i(e.n).div(e.d).times(e.s)},null:function(e){return new i(0)},"Array | Matrix":function(e){return xt(e,this)}})}),Lt=Ye("complex",["typed","Complex"],function(e){var t=e.typed,r=e.Complex;return t("complex",{"":function(){return r.ZERO},number:function(e){return new r(e,0)},"number, number":function(e,t){return new r(e,t)},"BigNumber, BigNumber":function(e,t){return new r(e.toNumber(),t.toNumber())},Fraction:function(e){return new r(e.valueOf(),0)},Complex:function(e){return e.clone()},string:function(e){return r(e)},null:function(e){return r(0)},Object:function(e){if("re"in e&&"im"in e)return new r(e.re,e.im);if("r"in e&&"phi"in e||"abs"in e&&"arg"in e)return new r(e);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":function(e){return xt(e,this)}})}),Ht=Ye("fraction",["typed","Fraction"],function(e){var t=e.typed,r=e.Fraction;return t("fraction",{number:function(e){if(!isFinite(e)||isNaN(e))throw new Error(e+" cannot be represented as a fraction");return new r(e)},string:function(e){return new r(e)},"number, number":function(e,t){return new r(e,t)},null:function(e){return new r(0)},BigNumber:function(e){return new r(e.toString())},Fraction:function(e){return e},Object:function(e){return new r(e)},"Array | Matrix":function(e){return xt(e,this)}})}),$t=Ye("matrix",["typed","Matrix","DenseMatrix","SparseMatrix"],function(e){var t=e.typed,n=(e.Matrix,e.DenseMatrix),i=e.SparseMatrix;return t("matrix",{"":function(){return r([])},string:function(e){return r([],e)},"string, string":function(e,t){return r([],e,t)},Array:function(e){return r(e)},Matrix:function(e){return r(e,e.storage())},"Array | Matrix, string":r,"Array | Matrix, string, string":r});function r(e,t,r){if("dense"===t||"default"===t||void 0===t)return new n(e,r);if("sparse"===t)return new i(e,r);throw new TypeError("Unknown matrix type "+JSON.stringify(t)+".")}}),Gt=Ye("splitUnit",["typed"],function(e){return(0,e.typed)("splitUnit",{"Unit, Array":function(e,t){return e.splitUnit(t)}})}),a="number, number";function Vt(e){return Math.abs(e)}function Zt(e,t){return e+t}function Wt(e,t){return e*t}function Jt(e){return-e}function Yt(e){return e}function Xt(e){return H(e)}function Qt(e){return Math.ceil(e)}function Kt(e){return e*e*e}function er(e){return Math.exp(e)}function tr(e){return $(e)}function rr(e,t){if(!L(e)||!L(t))throw new Error("Parameters in function gcd must be integer numbers");for(var r;0!==t;)r=e%t,e=t,t=r;return e<0?-e:e}function nr(e,t){if(!L(e)||!L(t))throw new Error("Parameters in function lcm must be integer numbers");if(0===e||0===t)return 0;for(var r,n=e*t;0!==t;)t=e%(r=t),e=r;return Math.abs(n/e)}function ir(e){return Math.log(e)}function ar(e){return c(e)}function or(e){return u(e)}function sr(e,t){if(0=n.length)throw new Ne(t,n.length);return E(e)?e.create(vr(e.valueOf(),t,r)):vr(e,t,r)}})});function vr(e,t,r){var n,i,a;if(t<=0){if(Array.isArray(e[0])){for(a=function(e){for(var t=e.length,r=e[0].length,n=[],i=0;ie.length)&&(t=e.length);for(var r=0,n=new Array(t);re.length)&&(t=e.length);for(var r=0,n=new Array(t);re)for(s-=e;s--;)u+="0";else s>1,c[p]&=1)}return c.reverse()}function fn(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)?on(t):t.eq(n)?on(e):e.isFinite()&&t.isFinite()?un(e,t,function(e,t){return e^t}):e.isFinite()||t.isFinite()?new r(e.isNegative()===t.isNegative()?1/0:-1/0):n}function ln(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 pn(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())+""):e.div(new r(2).pow(t))).floor():e.isNegative()?new r(-1):e.isFinite()?new r(0):new r(NaN)}at="number, number";function mn(e,t){if(!L(e)||!L(t))throw new Error("Integers expected in function bitAnd");return e&t}function hn(e){if(!L(e))throw new Error("Integer expected in function bitNot");return~e}function dn(e,t){if(!L(e)||!L(t))throw new Error("Integers expected in function bitOr");return e|t}function yn(e,t){if(!L(e)||!L(t))throw new Error("Integers expected in function bitXor");return e^t}function gn(e,t){if(!L(e)||!L(t))throw new Error("Integers expected in function leftShift");return e<>t}function xn(e,t){if(!L(e)||!L(t))throw new Error("Integers expected in function rightLogShift");return e>>>t}mn.signature=at,hn.signature="number",xn.signature=vn.signature=gn.signature=yn.signature=dn.signature=at;var bn=Ye("bitAnd",["typed","matrix","equalScalar"],function(e){var t=e.typed,r=e.matrix,e=e.equalScalar,n=jr({typed:t,equalScalar:e}),i=Pr({typed:t,equalScalar:e}),a=wr({typed:t,equalScalar:e}),o=Dr({typed:t}),s=Nr({typed:t});return t("bitAnd",{"number, number":mn,"BigNumber, BigNumber":an,"SparseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return n(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return n(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return o(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 a(e,t,this,!1)},"DenseMatrix, any":function(e,t){return s(e,t,this,!1)},"any, SparseMatrix":function(e,t){return a(t,e,this,!0)},"any, DenseMatrix":function(e,t){return s(t,e,this,!0)},"Array, any":function(e,t){return s(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return s(r(t),e,this,!0).valueOf()}})}),wn=Ye("bitNot",["typed"],function(e){return(0,e.typed)("bitNot",{number:hn,BigNumber:on,"Array | Matrix":function(e){return xt(e,this)}})}),Nn=Ye("bitOr",["typed","matrix","equalScalar","DenseMatrix"],function(e){var t=e.typed,r=e.matrix,n=e.equalScalar,e=e.DenseMatrix,i=Ir({typed:t}),a=Br({typed:t,equalScalar:n}),o=kr({typed:t,DenseMatrix:e}),s=Dr({typed:t}),u=Nr({typed:t});return t("bitOr",{"number, number":dn,"BigNumber, BigNumber":sn,"SparseMatrix, SparseMatrix":function(e,t){return a(e,t,this)},"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()}})}),Mn=Ye("algorithm07",["typed","DenseMatrix"],function(e){var N=e.typed,M=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 we(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 ji(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 Xi(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 Qi(n){for(var e=1;ee.length)&&(t=e.length);for(var r=0,n=new Array(t);re.length)&&(t=e.length);for(var r=0,n=new Array(t);rt.re?1:e.ret.im?1:e.imr.length?1:t.length=e.length)throw new Error("k out of bounds");for(var n=0;n=e&&(c(o.value,0)||r(o.key,o.value,this)),(o=n.extractMinimum())&&a.push(o);for(var s=0;se[n+1].length&&(t=e[n],e[n]=e[n+1],e[n+1]=t);return e}(r)}})}),Jo=Ye("setSize",["typed","compareNatural"],function(e){var t=e.typed,a=e.compareNatural;return t("setSize",{"Array | Matrix":function(e){return(Array.isArray(e)?qe(e):qe(e.toArray())).length},"Array | Matrix, boolean":function(e,t){if(!1===t||0===e.length)return(Array.isArray(e)?qe(e):qe(e.toArray())).length;for(var r=qe(Array.isArray(e)?e:e.toArray()).sort(a),n=1,i=1;i)'),t+this.index.toHTML(e)},r.prototype._toTex=function(e){var t=this.object.toTex(e);return n(this.object)&&(t="\\left(' + object + '\\right)"),t+this.index.toTex(e)},r.prototype.toJSON=function(){return{mathjs:"AccessorNode",object:this.object,index:this.index}},r.fromJSON=function(e){return new r(e.object,e.index)},r},{isClass:!0,isNode:!0}),ls=Ye("ArrayNode",["Node"],function(e){e=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(R))throw new TypeError("Array containing Nodes expected")}return(n.prototype=new e).type="ArrayNode",n.prototype.isArrayNode=!0,n.prototype._compile=function(t,r){var e=Ie(this.items,function(e){return e._compile(t,r)});if("Array"===t.config.matrix)return function(t,r,n){return Ie(e,function(e){return e(t,r,n)})};var i=t.matrix;return function(t,r,n){return i(Ie(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 ps(e){return(ps="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 ms=[{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 hs(e,t){var r=e;"keep"!==t&&(r=e.getContent());for(var n=r.getIdentifier(),i=0;i)'),t+r+'='+n},a.prototype._toTex=function(e){var t=this.object.toTex(e),r=this.index?this.index.toTex(e):"",n=this.value.toTex(e);return o(this,e&&e.parenthesis)&&(n="\\left(".concat(n,"\\right)")),t+r+":="+n},a},{isClass:!0,isNode:!0}),vs=Ye("BlockNode",["ResultSet","Node"],function(e){var o=e.ResultSet,e=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,e=!e||void 0===e.visible||e.visible;if(!R(t))throw new TypeError('Property "node" must be a Node');if("boolean"!=typeof e)throw new TypeError('Property "visible" must be a boolean');return{node:t,visible:e}})}return(a.prototype=new e).type="BlockNode",a.prototype.isBlockNode=!0,a.prototype._compile=function(t,r){var e=Ie(this.blocks,function(e){return{evaluate:e.node._compile(t,r),visible:e.visible}});return function(r,n,i){var a=[];return Be(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}),xs=Ye("ConditionalNode",["Node"],function(e){e=e.Node;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!R(e))throw new TypeError("Parameter condition must be a Node");if(!R(t))throw new TypeError("Parameter trueExpr must be a Node");if(!R(r))throw new TypeError("Parameter falseExpr must be a Node");this.condition=e,this.trueExpr=t,this.falseExpr=r}return(n.prototype=new e).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(I(e))return!e.isZero();if(Z(e))return e.re||e.im;if(W(e))return e.value}if(null!=e)throw new TypeError('Unsupported type of condition "'+J(e)+'"')}(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=hs(this,t),n=this.condition.toString(e),i=hs(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n="("+n+")");var a=this.trueExpr.toString(e),i=hs(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==i&&i<=r)&&(a="("+a+")");i=this.falseExpr.toString(e),e=hs(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==e&&e<=r)&&(i="("+i+")"),n+" ? "+a+" : "+i},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=hs(this,t),n=this.condition.toHTML(e),i=hs(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==i&&i<=r)&&(n='('+n+')');var a=this.trueExpr.toHTML(e),i=hs(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==i&&i<=r)&&(a='('+a+')');i=this.falseExpr.toHTML(e),e=hs(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==e&&e<=r)&&(i='('+i+')'),n+'?'+a+':'+i},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}),at=r(11),bs=r.n(at),ws={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{?}"},Ns={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"},Ms={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(Ns.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(Ns.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(Ns.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(Ns.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(Ns.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(Ns.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(Ns.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(Ns.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(Ns.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(Ns.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(Ns.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(Ns.bitAnd,"${args[1]}\\right)")},bitNot:{1:Ns.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(Ns.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(Ns.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(Ns.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(Ns.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(Ns.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(Ns.and,"${args[1]}\\right)")},not:{1:Ns.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(Ns.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(Ns.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(Ns.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(Ns.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(Ns.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(Ns.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(Ns.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(Ns.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(Ns.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(Ns.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(Ns.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(Ns.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(Ns.to,"${args[1]}\\right)")},numeric:function(e,t){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(ws.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)"}},Ss={deg:"^\\circ"};function Es(e){return bs()(e,{preserveFormatting:!0})}function As(e,t){return(t=void 0!==t&&t)?We(Ss,e)?Ss[e]:"\\mathrm{"+Es(e)+"}":We(ws,e)?ws[e]:Es(e)}var Os=Ye("ConstantNode",["Node"],function(e){e=e.Node;function t(e){if(!(this instanceof t))throw new SyntaxError("Constructor must be called with the new operator");this.value=e}return(t.prototype=new e).type="ConstantNode",t.prototype.isConstantNode=!0,t.prototype._compile=function(e,t){var r=this.value;return function(){return r}},t.prototype.forEach=function(e){},t.prototype.map=function(e){return this.clone()},t.prototype.clone=function(){return new t(this.value)},t.prototype._toString=function(e){return ge(this.value,e)},t.prototype.toHTML=function(e){e=this._toString(e);switch(J(this.value)){case"number":case"BigNumber":case"Fraction":return''+e+"";case"string":return''+e+"";case"boolean":return''+e+"";case"null":return''+e+"";case"undefined":return''+e+"";default:return''+e+""}},t.prototype.toJSON=function(){return{mathjs:"ConstantNode",value:this.value}},t.fromJSON=function(e){return new t(e.value)},t.prototype._toTex=function(e){var t=this._toString(e);switch(J(this.value)){case"string":return"\\mathtt{"+Es(t)+"}";case"number":case"BigNumber":if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";e=t.toLowerCase().indexOf("e");return-1!==e?t.substring(0,e)+"\\cdot10^{"+t.substring(e+1)+"}":t;case"Fraction":return this.value.toLatex();default:return t}},t},{isClass:!0,isNode:!0}),Cs=Ye("FunctionAssignmentNode",["typed","Node"],function(e){var f=e.typed,e=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(!R(r))throw new TypeError('Node expected for parameter "expr"');if(e in is)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 i(e,t){var r=hs(e,t),e=hs(e.expr,t);return"all"===t||null!==e&&e<=r}return(n.prototype=new e).type="FunctionAssignmentNode",n.prototype.isFunctionAssignmentNode=!0,n.prototype._compile=function(e,t){var r=Object.create(t);Be(this.params,function(e){r[e]=!0});var a=this.expr._compile(e,r),o=this.name,s=this.params,u=Re(this.types,","),c=o+"("+Re(this.params,", ")+")";return function(r,n,i){var e={};e[u]=function(){for(var e=Object.create(n),t=0;t'+xe(this.params[n])+"");e=this.expr.toHTML(e);return i(this,t)&&(e='('+e+')'),''+xe(this.name)+'('+r.join(',')+')='+e},n.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",e=this.expr.toTex(e);return i(this,t)&&(e="\\left(".concat(e,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(As).join(",")+"\\right):="+e},n},{isClass:!0,isNode:!0});function _s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r.'+xe(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 zs(e){return(zs="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 qs=Ye("ObjectNode",["Node"],function(e){e=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"!==zs(t)||!Object.keys(t).every(function(e){return R(t[e])})))throw new TypeError("Object containing Nodes expected")}return(n.prototype=new e).type="ObjectNode",n.prototype.isObjectNode=!0,n.prototype._compile=function(e,t){var r,a={};for(r in this.properties)if(We(this.properties,r)){var n=ve(r),n=JSON.parse(n);if(!vi(this.properties,n))throw new Error('No access to property "'+n+'"');a[n]=this.properties[r]._compile(e,t)}return function(e,t,r){var n,i={};for(n in a)We(a,n)&&(i[n]=a[n](e,t,r));return i}},n.prototype.forEach=function(e){for(var t in this.properties)We(this.properties,t)&&e(this.properties[t],"properties["+ve(t)+"]",this)},n.prototype.map=function(e){var t,r={};for(t in this.properties)We(this.properties,t)&&(r[t]=this._ifNode(e(this.properties[t],"properties["+ve(t)+"]",this)));return new n(r)},n.prototype.clone=function(){var e,t={};for(e in this.properties)We(this.properties,e)&&(t[e]=this.properties[e]);return new n(t)},n.prototype._toString=function(e){var t,r=[];for(t in this.properties)We(this.properties,t)&&r.push(ve(t)+": "+this.properties[t].toString(e));return"{"+r.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,r=[];for(t in this.properties)We(this.properties,t)&&r.push(''+xe(t)+':'+this.properties[t].toHTML(e));return'{'+r.join(',')+'}'},n.prototype._toTex=function(e){var t,r=[];for(t in this.properties)We(this.properties,t)&&r.push("\\mathbf{"+t+":} & "+this.properties[t].toTex(e)+"\\\\");return"\\left\\{\\begin{array}{ll}".concat(r.join("\n"),"\\end{array}\\right\\}")},n},{isClass:!0,isNode:!0}),Is=Ye("OperatorNode",["Node"],function(e){e=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(R))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=!0===n,this.op=e,this.fn=t,this.args=r||[]}function c(n,i,e,t,r){var a,o=hs(n,i),s=ds(n,i);if("all"===i||2)'),"right"===e?''+xe(this.op)+""+a:a+''+xe(this.op)+""}if(2===n.length){var a=n[0].toHTML(r),o=n[1].toHTML(r);return i[0]&&(a='('+a+')'),i[1]&&(o='('+o+')'),this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===t?a+''+o:a+''+xe(this.op)+""+o}o=n.map(function(e,t){return e=e.toHTML(r),i[t]&&(e='('+e+')'),e});return 2'):o.join(''+xe(this.op)+""):''+xe(this.fn)+'('+o.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=c(this,e,t,n,!0),a=void 0===(a=Ns[this.fn])?this.op:a;if(1===n.length){var o=ds(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){o=n[0],s=o.toTex(r);i[0]&&(s="\\left(".concat(s,"\\right)"));var u=n[1].toTex(r);switch(i[1]&&(u="\\left(".concat(u,"\\right)")),o=("keep"===e?o:o.getContent()).getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return a+"{"+s+"}{"+u+"}";case"OperatorNode:pow":switch(s="{"+s+"}",u="{"+u+"}",o){case"ConditionalNode":case"OperatorNode:divide":s="\\left(".concat(s,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&"hide"===t)return s+"~"+u}return s+a+u}if(2('+this.content.toHTML(e)+')':this.content.toHTML(e)},t.prototype._toTex=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"\\left(".concat(this.content.toTex(e),"\\right)"):this.content.toTex(e)},t},{isClass:!0,isNode:!0}),ks=Ye("RangeNode",["Node"],function(e){e=e.Node;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!R(e))throw new TypeError("Node expected");if(!R(t))throw new TypeError("Node expected");if(r&&!R(r))throw new TypeError("Node expected");if(3('+n+')'),t=n,this.step&&(n=this.step.toHTML(e),r.step&&(n='('+n+')'),t+=':'+n);e=this.end.toHTML(e);return r.end&&(e='('+e+')'),t+':'+e},n.prototype._toTex=function(e){var t,r=i(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);e=this.end.toTex(e);return r.end&&(e="\\left(".concat(e,"\\right)")),n+":"+e},n},{isClass:!0,isNode:!0}),Ds=Ye("RelationalNode",["Node"],function(e){e=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 e).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,i=u[0](e,t,r),a=0;a",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'+xe(t[this.conditionals[o]])+""+e[o+1];return r},i.prototype._toTex=function(n){for(var i=n&&n.parenthesis?n.parenthesis:"keep",a=hs(this,i),e=this.params.map(function(e,t){var r=hs(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+""},t.prototype.toJSON=function(){return{mathjs:"SymbolNode",name:this.name}},t.fromJSON=function(e){return new t(e.name)},t.prototype._toTex=function(e){var t=!1;void 0===r[this.name]&&s(this.name)&&(t=!0);t=As(this.name,t);return"\\"===t[0]?t:" "+t},t},{isClass:!0,isNode:!0});function js(e){return(js="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 Ps(){return(Ps=Object.assign||function(e){for(var t=1;t'+xe(this.fn)+'('+e.join(',')+')'};var o=d.prototype.toTex;return d.prototype.toTex=function(e){var t;return e&&"object"===js(e.handler)&&We(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(Ms[this.name]&&(e=Ms[this.name]),!i[this.name]||"function"!=typeof i[this.name].toTex&&"object"!==js(i[this.name].toTex)&&"string"!=typeof i[this.name].toTex||(e=i[this.name].toTex),js(e)){case"function":r=e(this,t);break;case"string":r=a(e,this,t);break;case"object":switch(js(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 Fs(){return(Fs=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},C={true:!0,false:!1,null:null,undefined:void 0},_=["NaN","Infinity"];function T(e,t){return e.expression.substr(e.index,t)}function z(e){return T(e,1)}function q(e){e.index++}function I(e){return e.expression.charAt(e.index-1)}function B(e){return e.expression.charAt(e.index+1)}function k(e){for(e.tokenType=w,e.token="",e.comment="";b.isWhitespace(z(e),e.nestingLevel);)q(e);if("#"===z(e))for(;"\n"!==z(e)&&""!==z(e);)e.comment+=z(e),q(e);if(""!==z(e)){if("\n"===z(e)&&!e.nestingLevel)return e.tokenType=N,e.token=z(e),q(e),0;var t=z(e),r=T(e,2),n=T(e,3);if(3===n.length&&A[n])return e.tokenType=N,e.token=n,q(e),q(e),q(e),0;if(2===r.length&&A[r])return e.tokenType=N,e.token=r,q(e),q(e),0;if(A[t])return e.tokenType=N,e.token=t,q(e),0;if(b.isDigitDot(t)){e.tokenType=M;t=T(e,2);if("0b"!==t&&"0o"!==t&&"0x"!==t){if("."===z(e))e.token+=z(e),q(e),b.isDigit(z(e))||(e.tokenType=N);else{for(;b.isDigit(z(e));)e.token+=z(e),q(e);b.isDecimalMark(z(e),B(e))&&(e.token+=z(e),q(e))}for(;b.isDigit(z(e));)e.token+=z(e),q(e);if("E"===z(e)||"e"===z(e))if(b.isDigit(B(e))||"-"===B(e)||"+"===B(e)){if(e.token+=z(e),q(e),"+"!==z(e)&&"-"!==z(e)||(e.token+=z(e),q(e)),!b.isDigit(z(e)))throw oe(e,'Digit expected, got "'+z(e)+'"');for(;b.isDigit(z(e));)e.token+=z(e),q(e);if(b.isDecimalMark(z(e),B(e)))throw oe(e,'Digit expected, got "'+z(e)+'"')}else if("."===B(e))throw q(e),oe(e,'Digit expected, got "'+z(e)+'"')}else{for(e.token+=z(e),q(e),e.token+=z(e),q(e);b.isHexDigit(z(e));)e.token+=z(e),q(e);t=z(e);if("i"===t)for(e.token+=t,q(e);b.isDigit(z(e));)e.token+=z(e),q(e)}}else{if(!b.isAlpha(z(e),I(e),B(e))){for(e.tokenType=E;""!==z(e);)e.token+=z(e),q(e);throw oe(e,'Syntax error in part "'+e.token+'"')}for(;b.isAlpha(z(e),I(e),B(e))||b.isDigit(z(e));)e.token+=z(e),q(e);We(O,e.token)?e.tokenType=N:e.tokenType=S}}else e.tokenType=N}function D(e){for(;k(e),"\n"===e.token;);}function R(e){e.nestingLevel++}function j(e){e.nestingLevel--}function P(e,t){var r={extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:w,nestingLevel:0,conditionalLevel:null};Fs(r,{expression:e,extraNodes:t}),k(r);t=function(e){var t,r,n=[];for(""!==e.token&&"\n"!==e.token&&";"!==e.token&&((t=U(e)).comment=e.comment);"\n"===e.token||";"===e.token;)0===n.length&&t&&(r=";"!==e.token,n.push({node:t,visible:r})),k(e),"\n"!==e.token&&";"!==e.token&&""!==e.token&&((t=U(e)).comment=e.comment,r=";"!==e.token,n.push({node:t,visible:r}));return 0":"larger","<=":"smallerEq",">=":"largerEq"};We(n,e.token);){var i={name:e.token,fn:n[e.token]};r.push(i),D(e),t.push(Z(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 Z(e){for(var t,r,n,i=W(e),a={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};We(a,e.token);)r=a[t=e.token],D(e),n=[i,W(e)],i=new y(t,r,n);return i}function W(e){for(var t,r,n,i=J(e),a={to:"to",in:"to"};We(a,e.token);)r=a[t=e.token],D(e),i="in"===t&&""===e.token?new y("*","multiply",[i,new x("in")],!0):(n=[i,J(e)],new y(t,r,n));return i}function J(e){var t=[],r=":"===e.token?new l(1):Y(e);if(":"===e.token&&e.conditionalLevel!==e.nestingLevel){for(t.push(r);":"===e.token&&t.length<3;)D(e),")"===e.token||"]"===e.token||","===e.token||""===e.token?t.push(new x("end")):t.push(Y(e));r=3===t.length?new n(t[0],t[2],t[1]):new n(t[0],t[1])}return r}function Y(e){for(var t,r,n,i=X(e),a={"+":"add","-":"subtract"};We(a,e.token);)r=a[t=e.token],D(e),n=[i,X(e)],i=new y(t,r,n);return i}function X(e){for(var t,r,n,i=t=Q(e),a={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide","%":"mod",mod:"mod"};We(a,e.token);)n=a[r=e.token],D(e),i=Q(e),t=new y(r,n,[t,i]);return t}function Q(e){for(var t,r=t=K(e);e.tokenType===S||"in"===e.token&&ce(t)||!(e.tokenType!==M||ce(r)||le(r)&&"!"!==r.op)||"("===e.token;)r=K(e),t=new y("*","multiply",[t,r],!0);return t}function K(e){for(var t=ee(e),r=t,n=[];"/"===e.token&&ce(r);){if(n.push(Fs({},e)),D(e),e.tokenType!==M){Fs(e,n.pop());break}if(n.push(Fs({},e)),D(e),e.tokenType!==S&&"("!==e.token){n.pop(),Fs(e,n.pop());break}Fs(e,n.pop()),n.pop(),r=ee(e),t=new y("/","divide",[t,r])}return t}function ee(e){var t,r,n,i={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return We(i,e.token)?(n=i[e.token],t=e.token,D(e),r=[ee(e)],new y(t,n,r)):(n=function(e){for(var t,r,n=function(e){var t,r,n=[];if(e.tokenType===S&&We(e.extraNodes,e.token)){var i=e.extraNodes[e.token];if(k(e),"("===e.token){if(n=[],R(e),k(e),")"!==e.token)for(n.push(U(e));","===e.token;)k(e),n.push(U(e));if(")"!==e.token)throw oe(e,"Parenthesis ) expected");j(e),k(e)}return new i(n)}return(t=e).tokenType===S||t.tokenType===N&&t.token in O?(i=t.token,k(t),te(t,We(C,i)?new l(C[i]):-1!==_.indexOf(i)?new l(s(i,"number")):new x(i))):'"'===(t=t).token?(r=re(t),te(t,new l(r))):"'"===(r=t).token?(t=ne(r),te(r,new l(t))):function(e){var t,r,n,i;if("["!==e.token)return function(e){if("{"!==e.token)return(n=e).tokenType===M?(i=n.token,k(n),new l(s(i,u.number))):function(e){var t;if("("!==e.token)return function(e){throw""===e.token?oe(e,"Unexpected end of expression"):oe(e,"Value expected")}(e);if(R(e),k(e),t=U(e),")"!==e.token)throw oe(e,"Parenthesis ) expected");return j(e),k(e),te(e,t=new g(t))}(n);var t;R(e);var r={};do{if(k(e),"}"!==e.token){if('"'===e.token)t=re(e);else if("'"===e.token)t=ne(e);else{if(!(e.tokenType===S||e.tokenType===N&&e.token in O))throw oe(e,"Symbol or string expected as object key");t=e.token,k(e)}if(":"!==e.token)throw oe(e,"Colon : expected after object key");k(e),r[t]=U(e)}}while(","===e.token);if("}"!==e.token)throw oe(e,"Comma , or bracket } expected after object value");j(e),k(e);var n,i,n=new d(r);return te(e,n)}(e);if(R(e),k(e),"]"!==e.token){var a=ie(e);if(";"===e.token){for(n=1,r=[a];";"===e.token;)k(e),r[n]=ie(e),n++;if("]"!==e.token)throw oe(e,"End of matrix ] expected");j(e),k(e),i=r[0].items.length;for(var o=1;oi))for(var l=s[c+1];f=I?S[T+f]-=m:0!==S[T+f]&&(S[T+f]=S[_+f]+$);for(h=F;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"]},count:{name:"count",category:"Matrix",syntax:["count(x)"],description:"Count the number of elements of a matrix, array or string.",examples:["a = [1, 2; 3, 4; 5, 6]","count(a)","size(a)",'count("hello world")'],seealso:["size"]},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"]},diff:{name:"diff",category:"Matrix",syntax:["diff(arr)","diff(arr, dim)"],description:["Create a new matrix or array with the difference of the passed matrix or array.","Dim parameter is optional and used to indicant the dimension of the array/matrix to apply the difference","If no dimension parameter is passed it is assumed as dimension 0","Dimension is zero-based in javascript and one-based in the parser","Arrays must be 'rectangular' meaning arrays like [1, 2]","If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays"],examples:["diff([1, 2, 4, 7, 0])","diff([1, 2, 4, 7, 0], 0)","diff(matrix([1, 2, 4, 7, 0]))","diff([[1, 2], [3, 4]])","diff([[1, 2], [3, 4]], 0)","diff([[1, 2], [3, 4]], 1)","diff([[1, 2], [3, 4]], bignumber(1))","diff(matrix([[1, 2], [3, 4]]), 1)","diff([[1, 2], matrix([3, 4])], 1)"],seealso:["subtract","partitionSelect"]},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"]},rotate:{name:"rotate",category:"Matrix",syntax:["rotate(w, theta)","rotate(w, theta, v)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotate([1, 0], math.pi / 2)",'rotate(matrix([1, 0]), unit("35deg"))','rotate([1, 0, 0], unit("90deg"), [0, 0, 1])','rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))'],seealso:["matrix","rotationMatrix"]},rotationMatrix:{name:"rotationMatrix",category:"Matrix",syntax:["rotationMatrix(theta)","rotationMatrix(theta, v)","rotationMatrix(theta, v, format)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotationMatrix(pi / 2)",'rotationMatrix(unit("45deg"), [0, 0, 1])','rotationMatrix(1, matrix([0, 0, 1]), "sparse")'],seealso:["cos","sin"]},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","count","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"]},bin:{name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},oct:{name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},hex:{name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},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"]}},fu=Ye("help",["typed","mathWithTransform","Help"],function(e){var t=e.typed,i=e.mathWithTransform,a=e.Help;return t("help",{any:function(e){var t,r=e;if("string"!=typeof e)for(t in i)if(We(i,t)&&e===i[t]){r=t;break}var n=yi(cu,r);if(n)return new a(n);n="function"==typeof r?r.name:r;throw new Error('No documentation found on "'+n+'"')}})}),lu=Ye("chain",["typed","Chain"],function(e){var t=e.typed,r=e.Chain;return t("chain",{"":function(){return new r},any:function(e){return new r(e)}})}),pu=Ye("det",["typed","matrix","subtract","multiply","unaryMinus","lup"],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:He,"Array | Matrix":function(e){var t;switch((t=E(e)?e.size():Array.isArray(e)?(e=n(e)).size():[]).length){case 0:return He(e);case 1:if(1===t[0])return He(e.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+ge(t)+")");case 2:var r=t[0];if(r===t[1])return function(e,t){if(1===t)return He(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;if&&(f=M(s[p][c]),l=p),p++;if(0===f)throw Error("Cannot calculate inverse, determinant is zero");(p=l)!==c&&(a=s[c],s[c]=s[p],s[p]=a,a=u[c],u[c]=u[p],u[p]=a);var m=s[c],h=u[c];for(p=0;p=l(r);){var o,s=a[0][0],u=a[0][1];e=function(e,t,r,n){for(var i=e.length,a=b(g(t)),o=b(v(t)),s=x(a,a),u=x(o,o),c=A(i,b(0)),f=A(i,b(0)),l=w(b(2),a,o,e[r][n]),t=d(y(x(s,e[r][r]),l),x(u,e[n][n])),s=N(x(u,e[r][r]),l,x(s,e[n][n])),p=0;p=Math.abs(r);){var f=c[0][0],l=c[0][1];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=A(i,0),f=A(i,0),t=s*e[r][r]-2*a*o*e[r][n]+u*e[n][n],s=u*e[r][r]+2*a*o*e[r][n]+s*e[n][n],l=0;l>1;return Ou(e,r)*Ou(1+r,t)}function Cu(e,t){if(!L(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!L(t)||t<0)throw new TypeError("Positive integer value expected in function combinations");if(e");if(2!==o.length)throw SyntaxError("Could not parse rule: "+n);n={l:o[0],r:o[1]};case"object":var s,i={l:A(u(n.l)),r:A(u(n.r))};n.context&&(i.evaluate=n.context),n.evaluate&&(i.evaluate=u(n.evaluate)),w(i.l)&&(s=E(i.l),o=new v("_p"+C++),i.expanded={},i.expanded.l=s([i.l.clone(),o]),N(i.expanded.l),M(i.expanded.l),i.expanded.r=s([i.r,o]));break;case"function":i=n;break;default:throw TypeError("Unsupported type of rule: "+a)}t.push(i)}return t}(t);for(var i=x(e,r),a={},o=(i=A(i)).toString({parenthesis:"all"});!a[o];){a[o]=!0;for(var s=C=0;s