UNPKG

mathjs

Version:

Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with dif

42 lines 574 kB
/** * math.js * https://github.com/josdejong/mathjs * * Math.js is an extensive math library for JavaScript and Node.js, * It features real and complex numbers, units, matrices, a large set of * mathematical functions, and a flexible expression parser. * * @version 7.5.1 * @date 2020-10-10 * * @license * Copyright (C) 2013-2020 Jos de Jong <wjosdejong@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy * of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.math=t():e.math=t()}(this,function(){return n={},i.m=r=[function(e,t,r){"use strict";r.d(t,"a",function(){return n}),r.d(t,"b",function(){return i}),r.d(t,"c",function(){return o});r(2);var a=r(3);function n(r,n,i,e){function t(e){var t=Object(a.j)(e,n.map(o));return function(e,t,r){if(!t.filter(function(e){return!((e=e)&&"?"===e[0])}).every(function(e){return void 0!==r[e]})){t=t.filter(function(e){return void 0===r[e]});throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(t.map(function(e){return'"'.concat(e,'"')}).join(", "),"."))}}(r,n,e),i(t)}return t.isFactory=!0,t.fn=r,t.dependencies=n.slice().sort(),e&&(t.meta=e),t}function i(e){return"function"==typeof e&&"string"==typeof e.fn&&Array.isArray(e.dependencies)}function o(e){return e&&"?"===e[0]?e.slice(1):e}},function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e){return"number"==typeof e}function a(e){return e&&!0===e.constructor.prototype.isBigNumber||!1}function o(e){return e&&"object"===n(e)&&!0===Object.getPrototypeOf(e).isComplex||!1}function s(e){return e&&"object"===n(e)&&!0===Object.getPrototypeOf(e).isFraction||!1}function u(e){return e&&!0===e.constructor.prototype.isUnit||!1}function c(e){return"string"==typeof e}r.d(t,"y",function(){return i}),r.d(t,"e",function(){return a}),r.d(t,"j",function(){return o}),r.d(t,"o",function(){return s}),r.d(t,"L",function(){return u}),r.d(t,"I",function(){return c}),r.d(t,"b",function(){return f}),r.d(t,"v",function(){return l}),r.d(t,"i",function(){return p}),r.d(t,"n",function(){return m}),r.d(t,"H",function(){return h}),r.d(t,"D",function(){return d}),r.d(t,"t",function(){return y}),r.d(t,"g",function(){return g}),r.d(t,"G",function(){return b}),r.d(t,"s",function(){return v}),r.d(t,"p",function(){return x}),r.d(t,"m",function(){return w}),r.d(t,"F",function(){return N}),r.d(t,"z",function(){return O}),r.d(t,"x",function(){return M}),r.d(t,"K",function(){return j}),r.d(t,"a",function(){return E}),r.d(t,"c",function(){return S}),r.d(t,"d",function(){return A}),r.d(t,"f",function(){return C}),r.d(t,"k",function(){return _}),r.d(t,"l",function(){return T}),r.d(t,"q",function(){return q}),r.d(t,"r",function(){return I}),r.d(t,"u",function(){return B}),r.d(t,"w",function(){return k}),r.d(t,"A",function(){return z}),r.d(t,"B",function(){return D}),r.d(t,"C",function(){return R}),r.d(t,"E",function(){return U}),r.d(t,"J",function(){return P}),r.d(t,"h",function(){return F}),r.d(t,"M",function(){return L});var f=Array.isArray;function l(e){return e&&!0===e.constructor.prototype.isMatrix||!1}function p(e){return Array.isArray(e)||l(e)}function m(e){return e&&e.isDenseMatrix&&!0===e.constructor.prototype.isMatrix||!1}function h(e){return e&&e.isSparseMatrix&&!0===e.constructor.prototype.isMatrix||!1}function d(e){return e&&!0===e.constructor.prototype.isRange||!1}function y(e){return e&&!0===e.constructor.prototype.isIndex||!1}function g(e){return"boolean"==typeof e}function b(e){return e&&!0===e.constructor.prototype.isResultSet||!1}function v(e){return e&&!0===e.constructor.prototype.isHelp||!1}function x(e){return"function"==typeof e}function w(e){return e instanceof Date}function N(e){return e instanceof RegExp}function O(e){return!(!e||"object"!==n(e)||e.constructor!==Object||o(e)||s(e))}function M(e){return null===e}function j(e){return void 0===e}function E(e){return e&&!0===e.isAccessorNode&&!0===e.constructor.prototype.isNode||!1}function S(e){return e&&!0===e.isArrayNode&&!0===e.constructor.prototype.isNode||!1}function A(e){return e&&!0===e.isAssignmentNode&&!0===e.constructor.prototype.isNode||!1}function C(e){return e&&!0===e.isBlockNode&&!0===e.constructor.prototype.isNode||!1}function _(e){return e&&!0===e.isConditionalNode&&!0===e.constructor.prototype.isNode||!1}function T(e){return e&&!0===e.isConstantNode&&!0===e.constructor.prototype.isNode||!1}function q(e){return e&&!0===e.isFunctionAssignmentNode&&!0===e.constructor.prototype.isNode||!1}function I(e){return e&&!0===e.isFunctionNode&&!0===e.constructor.prototype.isNode||!1}function B(e){return e&&!0===e.isIndexNode&&!0===e.constructor.prototype.isNode||!1}function k(e){return e&&!0===e.isNode&&!0===e.constructor.prototype.isNode||!1}function z(e){return e&&!0===e.isObjectNode&&!0===e.constructor.prototype.isNode||!1}function D(e){return e&&!0===e.isOperatorNode&&!0===e.constructor.prototype.isNode||!1}function R(e){return e&&!0===e.isParenthesisNode&&!0===e.constructor.prototype.isNode||!1}function U(e){return e&&!0===e.isRangeNode&&!0===e.constructor.prototype.isNode||!1}function P(e){return e&&!0===e.isSymbolNode&&!0===e.constructor.prototype.isNode||!1}function F(e){return e&&!0===e.constructor.prototype.isChain||!1}function L(e){var t=n(e);return"object"===t?null===e?"null":Array.isArray(e)?"Array":e instanceof Date?"Date":e instanceof RegExp?"RegExp":a(e)?"BigNumber":o(e)?"Complex":s(e)?"Fraction":l(e)?"Matrix":u(e)?"Unit":y(e)?"Index":d(e)?"Range":b(e)?"ResultSet":k(e)?e.type:F(e)?"Chain":v(e)?"Help":"Object":"function"===t?"Function":t}},function(e,t,r){"use strict";r.d(t,"a",function(){return s}),r.d(t,"p",function(){return c}),r.d(t,"q",function(){return f}),r.d(t,"m",function(){return l}),r.d(t,"l",function(){return p}),r.d(t,"n",function(){return m}),r.d(t,"o",function(){return h}),r.d(t,"e",function(){return d}),r.d(t,"k",function(){return y}),r.d(t,"f",function(){return g}),r.d(t,"c",function(){return b}),r.d(t,"d",function(){return v}),r.d(t,"j",function(){return x}),r.d(t,"i",function(){return w}),r.d(t,"g",function(){return N}),r.d(t,"h",function(){return O}),r.d(t,"b",function(){return M});var n=r(4),i=r(1),a=r(5),u=r(6),o=r(9);function s(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function c(e,t){if(0===t.length){if(Array.isArray(e))throw new u.a(e.length,0)}else!function e(t,r,n){var i=t.length;if(i!==r[n])throw new u.a(i,r[n]);if(n<r.length-1)for(var a=n+1,o=0;o<i;o++){var s=t[o];if(!Array.isArray(s))throw new u.a(r.length-1,r.length,"<");e(t[o],r,a)}else for(o=0;o<i;o++)if(Array.isArray(t[o]))throw new u.a(r.length+1,r.length,">")}(e,t,0)}function f(e,t){if(!Object(i.y)(e)||!Object(n.i)(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||"number"==typeof t&&t<=e)throw new o.a(e,t)}function l(e,t,r){if(!Array.isArray(e)||!Array.isArray(t))throw new TypeError("Array expected");if(0===t.length)throw new Error("Resizing to scalar is not supported");return t.forEach(function(e){if(!Object(i.y)(e)||!Object(n.i)(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+Object(a.d)(t)+")")}),function e(t,r,n,i){var a;var o;var s=t.length;var u=r[n];var c=Math.min(s,u);t.length=u;if(n<r.length-1){var f=n+1;for(a=0;a<c;a++)o=t[a],Array.isArray(o)||(o=[o],t[a]=o),e(o,r,f,i);for(a=c;a<u;a++)o=[],t[a]=o,e(o,r,f,i)}else{for(a=0;a<c;a++)for(;Array.isArray(t[a]);)t[a]=t[a][0];for(a=c;a<u;a++)t[a]=i}}(e,t,0,void 0!==r?r:0),e}function p(t,r){var e,n=d(t);function i(e){return e.reduce(function(e,t){return e*t})}if(!Array.isArray(t)||!Array.isArray(r))throw new TypeError("Array expected");if(0===r.length)throw new u.a(0,i(s(t)),"!=");for(var a=1,o=0;o<r.length;o++)a*=r[o];if(n.length!==a)throw new u.a(i(r),i(s(t)),"!=");try{e=function(e,t){for(var r,n=e,i=t.length-1;0<i;i--){var a=t[i];r=[];for(var o=n.length/a,s=0;s<o;s++)r.push(n.slice(s*a,(s+1)*a));n=r}return n}(n,r)}catch(e){if(e instanceof u.a)throw new u.a(i(r),i(s(t)),"!=");throw e}return e}function m(e,t){for(var r=t||s(e);Array.isArray(e)&&1===e.length;)e=e[0],r.shift();for(var n=r.length;1===r[n-1];)n--;return n<r.length&&(e=function e(t,r,n){var i,a;if(n<r){var o=n+1;for(i=0,a=t.length;i<a;i++)t[i]=e(t[i],r,o)}else for(;Array.isArray(t);)t=t[0];return t}(e,n,0),r.length=n),e}function h(e,t,r,n){var i=n||s(e);if(r)for(var a=0;a<r;a++)e=[e],i.unshift(1);for(e=function e(t,r,n){var i,a;if(Array.isArray(t)){var o=n+1;for(i=0,a=t.length;i<a;i++)t[i]=e(t[i],r,o)}else for(var s=n;s<r;s++)t=[t];return t}(e,t,0);i.length<t;)i.push(1);return e}function d(e){if(!Array.isArray(e))return e;var r=[];return e.forEach(function e(t){Array.isArray(t)?t.forEach(e):r.push(t)}),r}function y(e,t){return Array.prototype.map.call(e,t)}function g(e,t){Array.prototype.forEach.call(e,t)}function b(e,t){if(1!==s(e).length)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,t)}function v(e,t){if(1!==s(e).length)throw new Error("Only one dimensional matrices supported");return Array.prototype.filter.call(e,function(e){return t.test(e)})}function x(e,t){return Array.prototype.join.call(e,t)}function w(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(0===e.length)return e;var t=[],r=0;t[0]={value:e[0],identifier:0};for(var n=1;n<e.length;n++)e[n]===e[n-1]?r++:r=0,t.push({value:e[n],identifier:r});return t}function N(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(0===e.length)return e;for(var t=[],r=0;r<e.length;r++)t.push(e[r].value);return t}function O(e,t){for(var r,n=0,i=0;i<e.length;i++){var a=e[i],o=Array.isArray(a);if(0===i&&o&&(n=a.length),o&&a.length!==n)return;a=o?O(a,t):t(a);if(void 0===r)r=a;else if(r!==a)return"mixed"}return r}function M(e,t){return-1!==e.indexOf(t)}},function(e,t,r){"use strict";r.d(t,"a",function(){return i}),r.d(t,"i",function(){return o}),r.d(t,"e",function(){return s}),r.d(t,"b",function(){return u}),r.d(t,"d",function(){return c}),r.d(t,"c",function(){return f}),r.d(t,"h",function(){return l}),r.d(t,"f",function(){return p}),r.d(t,"g",function(){return m}),r.d(t,"j",function(){return h}),r.d(t,"k",function(){return d});var n=r(1);function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e){var t=a(e);if("number"===t||"string"===t||"boolean"===t||null==e)return e;if("function"==typeof e.clone)return e.clone();if(Array.isArray(e))return e.map(i);if(e instanceof Date)return new Date(e.valueOf());if(Object(n.e)(e))return e;if(e instanceof RegExp)throw new TypeError("Cannot clone "+e);return o(e,i)}function o(e,t){var r,n={};for(r in e)p(e,r)&&(n[r]=t(e[r]));return n}function s(e,t){for(var r in t)p(t,r)&&(e[r]=t[r]);return e}function u(e,t){if(Array.isArray(t))throw new TypeError("Arrays are not supported by deepExtend");for(var r in t)if(p(t,r)&&!(r in Object.prototype)&&!(r in Function.prototype))if(t[r]&&t[r].constructor===Object)void 0===e[r]&&(e[r]={}),e[r]&&e[r].constructor===Object?u(e[r],t[r]):e[r]=t[r];else{if(Array.isArray(t[r]))throw new TypeError("Arrays are not supported by deepExtend");e[r]=t[r]}return e}function c(e,t){var r,n,i;if(Array.isArray(e)){if(!Array.isArray(t))return!1;if(e.length!==t.length)return!1;for(n=0,i=e.length;n<i;n++)if(!c(e[n],t[n]))return!1;return!0}if("function"==typeof e)return e===t;if(e instanceof Object){if(Array.isArray(t)||!(t instanceof Object))return!1;for(r in e)if(!(r in t&&c(e[r],t[r])))return!1;for(r in t)if(!(r in e&&c(e[r],t[r])))return!1;return!0}return e===t}function f(e){var t={};return function e(t,r){for(var n in t){var i;p(t,n)&&("object"===a(i=t[n])&&null!==i?e(i,r):r[n]=i)}}(e,t),t}function l(e,t,r){var n,i=!0;Object.defineProperty(e,t,{get:function(){return i&&(n=r(),i=!1),n},set:function(e){n=e,i=!1},configurable:!0,enumerable:!0})}function p(e,t){return e&&Object.hasOwnProperty.call(e,t)}function m(e){return e&&"function"==typeof e.factory}function h(e,t){for(var r={},n=0;n<t.length;n++){var i=t[n],a=e[i];void 0!==a&&(r[i]=a)}return r}function d(t){return Object.keys(t).map(function(e){return t[e]})}},function(e,t,r){"use strict";r.d(t,"i",function(){return n}),r.d(t,"n",function(){return i}),r.d(t,"l",function(){return a}),r.d(t,"j",function(){return o}),r.d(t,"k",function(){return s}),r.d(t,"d",function(){return u}),r.d(t,"g",function(){return c}),r.d(t,"h",function(){return l}),r.d(t,"q",function(){return m}),r.d(t,"f",function(){return g}),r.d(t,"m",function(){return v}),r.d(t,"a",function(){return x}),r.d(t,"b",function(){return w}),r.d(t,"c",function(){return N}),r.d(t,"e",function(){return O}),r.d(t,"o",function(){return M}),r.d(t,"p",function(){return j});var f=r(1);function n(e){return"boolean"==typeof e||!!isFinite(e)&&e===Math.round(e)}var i=Math.sign||function(e){return 0<e?1:e<0?-1:0},a=Math.log2||function(e){return Math.log(e)/Math.LN2},o=Math.log10||function(e){return Math.log(e)/Math.LN10},s=Math.log1p||function(e){return Math.log(e+1)},u=Math.cbrt||function(e){if(0===e)return e;var t,r=e<0;return r&&(e=-e),t=isFinite(e)?(e/((t=Math.exp(Math.log(e)/3))*t)+2*t)/3:e,r?-t:t},c=Math.expm1||function(e){return 2e-4<=e||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function l(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="auto";switch(t&&(t.notation&&(n=t.notation),Object(f.y)(t)?r=t:Object(f.y)(t.precision)&&(r=t.precision)),n){case"fixed":return m(e,r);case"exponential":return h(e,r);case"engineering":return function(e,t){if(isNaN(e)||!isFinite(e))return String(e);var r=d(p(e),t),n=r.exponent,i=r.coefficients,a=n%3==0?n:n<0?n-3-n%3:n-n%3;if(Object(f.y)(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<o;s++)i.push(0);var u=Math.abs(n-a),c=1;for(;0<u;)c++,u--;e=i.slice(c).join(""),e=Object(f.y)(t)&&e.length||e.match(/[1-9]/)?"."+e:"",e=i.slice(0,c).join("")+e+"e"+(0<=n?"+":"")+a.toString();return r.sign+e}(e,r);case"auto":return function(e,t,r){if(isNaN(e)||!isFinite(e))return String(e);var n=r&&void 0!==r.lowerExp?r.lowerExp:-3,i=r&&void 0!==r.upperExp?r.upperExp:5,r=p(e),r=t?d(r,t):r;{if(r.exponent<n||r.exponent>=i)return h(e,t);i=r.coefficients,e=r.exponent;i.length<t&&(i=i.concat(y(t-i.length))),i=i.concat(y(e-i.length+1+(i.length<t?t-i.length:0))),i=y(-e).concat(i);e=0<e?e:0;return e<i.length-1&&i.splice(e+1,0,"."),r.sign+i.join("")}}(e,r,t&&t).replace(/((\.\d*?)(0+))($|e)/,function(){var e=arguments[2],t=arguments[4];return"."!==e?e+t:t});default:throw new Error('Unknown notation "'+n+'". Choose "auto", "exponential", or "fixed".')}}function p(e){var t=String(e).toLowerCase().match(/^0*?(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+e);var r=t[1],e=t[2],n=parseFloat(t[4]||"0"),t=e.indexOf(".");n+=-1!==t?t-1:e.length-1;e=e.replace(".","").replace(/^0*/,function(e){return n-=e.length,""}).replace(/0*$/,"").split("").map(function(e){return parseInt(e)});return 0===e.length&&(e.push(0),n++),{sign:r,coefficients:e,exponent:n}}function m(e,t){if(isNaN(e)||!isFinite(e))return String(e);var r=p(e),n="number"==typeof t?d(r,r.exponent+1+t):r,e=n.coefficients,r=n.exponent+1,t=r+(t||0);return e.length<t&&(e=e.concat(y(t-e.length))),r<0&&(e=y(1-r).concat(e),r=1),r<e.length&&e.splice(r,0,0===r?"0.":"."),n.sign+e.join("")}function h(e,t){if(isNaN(e)||!isFinite(e))return String(e);var r=p(e),n=t?d(r,t):r,e=n.coefficients,r=n.exponent;e.length<t&&(e=e.concat(y(t-e.length)));t=e.shift();return n.sign+t+(0<e.length?"."+e.join(""):"")+"e"+(0<=r?"+":"")+r}function d(e,t){for(var r={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},n=r.coefficients;t<=0;)n.unshift(0),r.exponent++,t++;if(n.length>t&&5<=n.splice(t,n.length-t)[0]){var i=t-1;for(n[i]++;10===n[i];)n.pop(),0===i&&(n.unshift(0),r.exponent++,i++),n[--i]++}return r}function y(e){for(var t=[],r=0;r<e;r++)t.push(0);return t}function g(e){return e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length}var b=Number.EPSILON||2220446049250313e-31;function v(e,t,r){if(null==r)return e===t;if(e===t)return!0;if(isNaN(e)||isNaN(t))return!1;if(isFinite(e)&&isFinite(t)){var n=Math.abs(e-t);return n<b||n<=Math.max(Math.abs(e),Math.abs(t))*r}return!1}var x=Math.acosh||function(e){return Math.log(Math.sqrt(e*e-1)+e)},w=Math.asinh||function(e){return Math.log(Math.sqrt(e*e+1)+e)},N=Math.atanh||function(e){return Math.log((1+e)/(1-e))/2},O=Math.cosh||function(e){return(Math.exp(e)+Math.exp(-e))/2},M=Math.sinh||function(e){return(Math.exp(e)-Math.exp(-e))/2},j=Math.tanh||function(e){e=Math.exp(2*e);return(e-1)/(e+1)}},function(e,t,r){"use strict";r.d(t,"b",function(){return u}),r.d(t,"d",function(){return c}),r.d(t,"e",function(){return f}),r.d(t,"c",function(){return l}),r.d(t,"a",function(){return p});var n=r(1),i=r(4);function a(e,t){if("function"==typeof t)return t(e);if(!e.isFinite())return e.isNaN()?"NaN":e.gt(0)?"Infinity":"-Infinity";var r,n="auto";switch(void 0!==t&&(t.notation&&(n=t.notation),"number"==typeof t?r=t:t.precision&&(r=t.precision)),n){case"fixed":return o=r,e.toFixed(o);case"exponential":return s(e,r);case"engineering":return function(e,t){var r=e.e,n=r%3==0?r:r<0?r-3-r%3:r-r%3,e=e.mul(Math.pow(10,-n)),t=e.toPrecision(t);-1!==t.indexOf("e")&&(t=e.toString());return t+"e"+(0<=r?"+":"")+n.toString()}(e,r);case"auto":var i=t&&void 0!==t.lowerExp?t.lowerExp:-3,a=t&&void 0!==t.upperExp?t.upperExp:5;if(e.isZero())return"0";var o=e.toSignificantDigits(r),t=o.e;return(i<=t&&t<a?o.toFixed():s(e,r)).replace(/((\.\d*?)(0+))($|e)/,function(){var e=arguments[2],t=arguments[4];return"."!==e?e+t:t});default:throw new Error('Unknown notation "'+n+'". Choose "auto", "exponential", or "fixed".')}}function s(e,t){return void 0!==t?e.toExponential(t-1):e.toExponential()}function o(e){return(o="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 u(e,t){var r=e.length-t.length,n=e.length;return e.substring(r,n)===t}function c(t,r){return"number"==typeof t?Object(i.h)(t,r):Object(n.e)(t)?a(t,r):(e=t)&&"object"===o(e)&&"number"==typeof e.s&&"number"==typeof e.n&&"number"==typeof e.d||!1?r&&"decimal"===r.fraction?t.toString():t.s*t.n+"/"+t.d:Array.isArray(t)?function e(t,r){{if(Array.isArray(t)){for(var n="[",i=t.length,a=0;a<i;a++)0!==a&&(n+=", "),n+=e(t[a],r);return n+="]"}return c(t,r)}}(t,r):Object(n.I)(t)?'"'+t+'"':"function"==typeof t?t.syntax?String(t.syntax):"function":t&&"object"===o(t)?"function"==typeof t.format?t.format(r):t&&t.toString(r)!=={}.toString()?t.toString(r):"{"+Object.keys(t).map(function(e){return'"'+e+'": '+c(t[e],r)}).join(", ")+"}":String(t);var e}function f(e){for(var t=String(e),r="",n=0;n<t.length;){var i=t.charAt(n);"\\"===i?(r+=i,n++,""!==(i=t.charAt(n))&&-1!=='"\\/bfnrtu'.indexOf(i)||(r+="\\"),r+=i):r+='"'===i?'\\"':i,n++}return'"'+r+'"'}function l(e){return String(e).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function p(e,t){if(!Object(n.I)(e))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+Object(n.M)(e)+", index: 0)");if(!Object(n.I)(t))throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: "+Object(n.M)(t)+", index: 1)");return e===t?0:t<e?1:-1}},function(e,t,r){"use strict";function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=t,this.relation=r,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=(new Error).stack}r.d(t,"a",function(){return n}),(n.prototype=new RangeError).constructor=RangeError,n.prototype.name="DimensionError",n.prototype.isDimensionError=!0},,function(e,t,r){var a; /** * @license Complex.js v2.0.11 11/02/2016 * * Copyright (c) 2016, Robert Eisele (robert@xarg.org) * Dual licensed under the MIT or GPL Version 2 licenses. **/ !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))}function u(){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)))}var r=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<n.length;o++){var s=n[o];" "===s||"\t"===s||"\n"===s||("+"===s?i++:"-"===s?a++:i=a=("i"===s||"I"===s?(i+a===0&&u()," "===n[o+1]||isNaN(n[o+1])?r.im+=parseFloat((a%2?"-":"")+"1"):(r.im+=parseFloat((a%2?"-":"")+n[o+1]),o++)):(i+a!==0&&!isNaN(s)||u(),"i"===n[o+1]||"I"===n[o+1]?(r.im+=parseFloat((a%2?"-":"")+s),o++):r.re+=parseFloat((a%2?"-":"")+s)),0))}0<i+a&&u();break;case"number":r.im=0,r.re=e;break;default:u()}return isNaN(r.re)||isNaN(r.im),r};function c(e,t){if(!(this instanceof c))return new c(e,t);t=r(e,t);this.re=t.re,this.im=t.im}c.prototype={re:0,im:0,sign:function(){var e=this.abs();return new c(this.re/e,this.im/e)},add:function(e,t){t=new c(e,t);return this.isInfinite()&&t.isInfinite()?c.NAN:this.isInfinite()||t.isInfinite()?c.INFINITY:new c(this.re+t.re,this.im+t.im)},sub:function(e,t){t=new c(e,t);return this.isInfinite()&&t.isInfinite()?c.NAN:this.isInfinite()||t.isInfinite()?c.INFINITY:new c(this.re-t.re,this.im-t.im)},mul:function(e,t){t=new c(e,t);return this.isInfinite()&&t.isZero()||this.isZero()&&t.isInfinite()?c.NAN:this.isInfinite()||t.isInfinite()?c.INFINITY:0===t.im&&0===this.im?new c(this.re*t.re,0):new c(this.re*t.re-this.im*t.im,this.re*t.im+this.im*t.re)},div:function(e,t){var r=new c(e,t);if(this.isZero()&&r.isZero()||this.isInfinite()&&r.isInfinite())return c.NAN;if(this.isInfinite()||r.isZero())return c.INFINITY;if(this.isZero()||r.isInfinite())return c.ZERO;e=this.re,t=this.im;var n,i,a=r.re,r=r.im;return 0===r?new c(e/a,t/a):Math.abs(a)<Math.abs(r)?new c((e*(i=a/r)+t)/(n=a*i+r),(t*i-e)/n):new c((e+t*(i=r/a))/(n=r*i+a),(t-e*i)/n)},pow:function(e,t){var r=new c(e,t);if(e=this.re,t=this.im,r.isZero())return c.ONE;if(0===r.im){if(0===t&&0<=e)return new c(Math.pow(e,r.re),0);if(0===e)switch((r.re%4+4)%4){case 0:return new c(Math.pow(t,r.re),0);case 1:return new c(0,Math.pow(t,r.re));case 2:return new c(-Math.pow(t,r.re),0);case 3:return new c(0,-Math.pow(t,r.re))}}if(0===e&&0===t&&0<r.re&&0<=r.im)return c.ZERO;var n=Math.atan2(t,e),i=o(e,t);return e=Math.exp(r.re*i-r.im*n),t=r.im*i+r.re*n,new c(e*Math.cos(t),e*Math.sin(t))},sqrt:function(){var e,t=this.re,r=this.im,n=this.abs();if(0<=t){if(0===r)return new c(Math.sqrt(t),0);e=.5*Math.sqrt(2*(n+t))}else e=Math.abs(r)/Math.sqrt(2*(n-t));return t=t<=0?.5*Math.sqrt(2*(n-t)):Math.abs(r)/Math.sqrt(2*(n+t)),new c(e,r<0?-t:t)},exp:function(){var e=Math.exp(this.re);return this.im,new c(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){var e=this.re,t=this.im;return new c(Math.expm1(e)*Math.cos(t)+function(e){var t=Math.PI/4;if(e<-t||t<e)return Math.cos(e)-1;e*=e;return e*(e*(1/24+e*(-1/720+e*(1/40320+e*(-1/3628800+e*(1/4790014600+e*(-1/87178291200+1/20922789888e3*e))))))-.5)}(t),Math.exp(e)*Math.sin(t))},log:function(){var e=this.re,t=this.im;return new c(o(e,t),Math.atan2(t,e))},abs:function(){return e=this.re,t=this.im,r=Math.abs(e),n=Math.abs(t),r<3e3&&n<3e3?Math.sqrt(r*r+n*n):(n=r<n?(r=n,e/t):t/e,r*Math.sqrt(1+n*n));var e,t,r,n},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var e=this.re,t=this.im;return new c(Math.sin(e)*n(t),Math.cos(e)*i(t))},cos:function(){var e=this.re,t=this.im;return new c(Math.cos(e)*n(t),-Math.sin(e)*i(t))},tan:function(){var e=2*this.re,t=2*this.im,r=Math.cos(e)+n(t);return new c(Math.sin(e)/r,i(t)/r)},cot:function(){var e=2*this.re,t=2*this.im,r=Math.cos(e)-n(t);return new c(-Math.sin(e)/r,i(t)/r)},sec:function(){var e=this.re,t=this.im,r=.5*n(2*t)+.5*Math.cos(2*e);return new c(Math.cos(e)*n(t)/r,Math.sin(e)*i(t)/r)},csc:function(){var e=this.re,t=this.im,r=.5*n(2*t)-.5*Math.cos(2*e);return new c(Math.sin(e)*n(t)/r,-Math.cos(e)*i(t)/r)},asin:function(){var e=this.re,t=this.im,r=new c(t*t-e*e+1,-2*e*t).sqrt(),e=new c(r.re-t,r.im+e).log();return new c(e.im,-e.re)},acos:function(){var e=this.re,t=this.im,r=new c(t*t-e*e+1,-2*e*t).sqrt(),e=new c(r.re-t,r.im+e).log();return new c(Math.PI/2-e.im,e.re)},atan:function(){var e=this.re,t=this.im;if(0===e){if(1===t)return new c(0,1/0);if(-1===t)return new c(0,-1/0)}var r=e*e+(1-t)*(1-t),r=new c((1-t*t-e*e)/r,-2*e/r).log();return new c(-.5*r.im,.5*r.re)},acot:function(){var e=this.re,t=this.im;if(0===t)return new c(Math.atan2(1,e),0);var r=e*e+t*t;return(0!=r?new c(e/r,-t/r):new c(0!==e?e/0:0,0!==t?-t/0:0)).atan()},asec:function(){var e=this.re,t=this.im;if(0===e&&0===t)return new c(0,1/0);var r=e*e+t*t;return(0!=r?new c(e/r,-t/r):new c(0!==e?e/0:0,0!==t?-t/0:0)).acos()},acsc:function(){var e=this.re,t=this.im;if(0===e&&0===t)return new c(Math.PI/2,1/0);var r=e*e+t*t;return(0!=r?new c(e/r,-t/r):new c(0!==e?e/0:0,0!==t?-t/0:0)).asin()},sinh:function(){var e=this.re,t=this.im;return new c(i(e)*Math.cos(t),n(e)*Math.sin(t))},cosh:function(){var e=this.re,t=this.im;return new c(n(e)*Math.cos(t),i(e)*Math.sin(t))},tanh:function(){var e=2*this.re,t=2*this.im,r=n(e)+Math.cos(t);return new c(i(e)/r,Math.sin(t)/r)},coth:function(){var e=2*this.re,t=2*this.im,r=n(e)-Math.cos(t);return new c(i(e)/r,-Math.sin(t)/r)},csch:function(){var e=this.re,t=this.im,r=Math.cos(2*t)-n(2*e);return new c(-2*i(e)*Math.cos(t)/r,2*n(e)*Math.sin(t)/r)},sech:function(){var e=this.re,t=this.im,r=Math.cos(2*t)+n(2*e);return new c(2*n(e)*Math.cos(t)/r,-2*i(e)*Math.sin(t)/r)},asinh:function(){var e=this.im;this.im=-this.re,this.re=e;var t=this.asin();return this.re=-this.im,this.im=e,e=t.re,t.re=-t.im,t.im=e,t},acosh:function(){var e,t=this.acos();return t.im<=0?(e=t.re,t.re=-t.im,t.im=e):(e=t.im,t.im=-t.re,t.re=e),t},atanh:function(){var e=this.re,t=this.im,r=1<e&&0===t,n=1-e,i=1+e,a=n*n+t*t,e=0!=a?new c((i*n-t*t)/a,(t*n+i*t)/a):new c(-1!==e?e/0:0,0!==t?t/0:0),t=e.re;return e.re=o(e.re,e.im)/2,e.im=Math.atan2(e.im,t)/2,r&&(e.im=-e.im),e},acoth:function(){var e=this.re,t=this.im;if(0===e&&0===t)return new c(0,Math.PI/2);var r=e*e+t*t;return(0!=r?new c(e/r,-t/r):new c(0!==e?e/0:0,0!==t?-t/0:0)).atanh()},acsch:function(){var e=this.re,t=this.im;if(0===t)return new c(0!==e?Math.log(e+Math.sqrt(e*e+1)):1/0,0);var r=e*e+t*t;return(0!=r?new c(e/r,-t/r):new c(0!==e?e/0:0,0!==t?-t/0:0)).asinh()},asech:function(){var e=this.re,t=this.im;if(this.isZero())return c.INFINITY;var r=e*e+t*t;return(0!=r?new c(e/r,-t/r):new c(0!==e?e/0:0,0!==t?-t/0:0)).acosh()},inverse:function(){if(this.isZero())return c.INFINITY;if(this.isInfinite())return c.ZERO;var e=this.re,t=this.im,r=e*e+t*t;return new c(e/r,-t/r)},conjugate:function(){return new c(this.re,-this.im)},neg:function(){return new c(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new c(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new c(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new c(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,t){t=new c(e,t);return Math.abs(t.re-this.re)<=c.EPSILON&&Math.abs(t.im-this.im)<=c.EPSILON},clone:function(){return new c(this.re,this.im)},toString:function(){var e=this.re,t=this.im,r="";return this.isNaN()?"NaN":this.isZero()?"0":this.isInfinite()?"Infinity":(0!==e&&(r+=e),0!==t&&(0!==e?r+=t<0?" - ":" + ":t<0&&(r+="-"),1!==(t=Math.abs(t))&&(r+=t),r+="i"),r||"0")},toVector:function(){return[this.re,this.im]},valueOf:function(){return 0===this.im?this.re:null},isNaN:function(){return isNaN(this.re)||isNaN(this.im)},isZero:function(){return!(0!==this.re&&-0!==this.re||0!==this.im&&-0!==this.im)},isFinite:function(){return isFinite(this.re)&&isFinite(this.im)},isInfinite:function(){return!(this.isNaN()||this.isFinite())}},c.ZERO=new c(0,0),c.ONE=new c(1,0),c.I=new c(0,1),c.PI=new c(Math.PI,0),c.E=new c(Math.E,0),c.INFINITY=new c(1/0,1/0),c.NAN=new c(NaN,NaN),c.EPSILON=1e-16,void 0===(a=function(){return c}.apply(t,[]))||(e.exports=a)}()},function(e,t,r){"use strict";function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=r),void 0!==this.min&&this.index<this.min?this.message="Index out of range ("+this.index+" < "+this.min+")":void 0!==this.max&&this.index>=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=(new Error).stack}r.d(t,"a",function(){return n}),(n.prototype=new RangeError).constructor=RangeError,n.prototype.name="IndexError",n.prototype.isIndexError=!0},function(n,i,e){var a; /** * @license Fraction.js v4.0.12 09/09/2015 * http://www.xarg.org/2014/03/rational-numbers-in-javascript/ * * Copyright (c) 2015, Robert Eisele (robert@xarg.org) * Dual licensed under the MIT or GPL Version 2 licenses. **/ !function(){"use strict";var d={s:1,n:0,d:1};function e(t){function e(){var e=Error.apply(this,arguments);e.name=this.name=t,this.stack=e.stack,this.message=e.message}function r(){}return r.prototype=Error.prototype,e.prototype=new r,e}var y=c.DivisionByZero=e("DivisionByZero"),t=c.InvalidParameter=e("InvalidParameter");function g(e,t){return isNaN(e=parseInt(e,10))&&b(),e*t}function b(){throw new t}var r=function(e,t){var r,n=0,i=1,a=1,o=0,s=0,u=0,c=1,f=1,l=0,p=1,m=1,h=1;if(null!=e)if(void 0!==t)a=(n=e)*(i=t);else switch(typeof e){case"object":"d"in e&&"n"in e?(n=e.n,i=e.d,"s"in e&&(n*=e.s)):0 in e?(n=e[0],1 in e&&(i=e[1])):b(),a=n*i;break;case"number":if(e<0&&(e=-(a=e)),e%1==0)n=e;else if(0<e){for(1<=e&&(e/=f=Math.pow(10,Math.floor(1+Math.log(e)/Math.LN10)));p<=1e7&&h<=1e7;){if(e===(r=(l+m)/(p+h))){i=p+h<=1e7?(n=l+m,p+h):p<h?(n=m,h):(n=l,p);break}r<e?(l+=m,p+=h):(m+=l,h+=p),i=1e7<p?(n=m,h):(n=l,p)}n*=f}else(isNaN(e)||isNaN(t))&&(i=n=NaN);break;case"string":if(null===(p=e.match(/\d+|./g))&&b(),"-"===p[l]?(a=-1,l++):"+"===p[l]&&l++,p.length===l+1?s=g(p[l++],a):"."===p[l+1]||"."===p[l]?("."!==p[l]&&(o=g(p[l++],a)),(++l+1===p.length||"("===p[l+1]&&")"===p[l+3]||"'"===p[l+1]&&"'"===p[l+3])&&(s=g(p[l],a),c=Math.pow(10,p[l].length),l++),("("===p[l]&&")"===p[l+2]||"'"===p[l]&&"'"===p[l+2])&&(u=g(p[l+1],a),f=Math.pow(10,p[l+1].length)-1,l+=3)):"/"===p[l+1]||":"===p[l+1]?(s=g(p[l],a),c=g(p[l+2],1),l+=3):"/"===p[l+3]&&" "===p[l+1]&&(o=g(p[l],a),s=g(p[l+2],a),c=g(p[l+4],1),l+=5),p.length<=l){a=n=u+(i=c*f)*o+f*s;break}default:b()}if(0===i)throw new y;d.s=a<0?-1:1,d.n=Math.abs(n),d.d=Math.abs(i)};function s(e,t,r){for(var n=1,i=function(e,t,r){for(var n=1;0<t;e=e*e%r,t>>=1)1&t&&(n=n*e%r);return n}(10,r,t),a=0;a<300;a++){if(n===i)return a;n=10*n%t,i=10*i%t}return 0}function u(e,t){if(!e)return t;if(!t)return e;for(;;){if(!(e%=t))return t;if(!(t%=e))return e}}function c(e,t){if(!(this instanceof c))return new c(e,t);r(e,t),e=c.REDUCE?u(d.d,d.n):1,this.s=d.s,this.n=d.n/e,this.d=d.d/e}c.REDUCE=1,c.prototype={s:1,n:0,d:1,abs:function(){return new c(this.n,this.d)},neg:function(){return new c(-this.s*this.n,this.d)},add:function(e,t){return r(e,t),new c(this.s*this.n*d.d+d.s*this.d*d.n,this.d*d.d)},sub:function(e,t){return r(e,t),new c(this.s*this.n*d.d-d.s*this.d*d.n,this.d*d.d)},mul:function(e,t){return r(e,t),new c(this.s*d.s*this.n*d.n,this.d*d.d)},div:function(e,t){return r(e,t),new c(this.s*d.s*this.n*d.d,this.d*d.n)},clone:function(){return new c(this)},mod:function(e,t){return isNaN(this.n)||isNaN(this.d)?new c(NaN):void 0===e?new c(this.s*this.n%this.d,1):(r(e,t),0===d.n&&0===this.d&&c(0,0),new c(this.s*(d.d*this.n)%(d.n*this.d),d.d*this.d))},gcd:function(e,t){return r(e,t),new c(u(d.n,this.n)*u(d.d,this.d),d.d*this.d)},lcm:function(e,t){return r(e,t),0===d.n&&0===this.n?new c:new c(d.n*this.n,u(d.n,this.n)*u(d.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new c(NaN):new c(Math.ceil(e*this.s*this.n/this.d),e)},floor:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new c(NaN):new c(Math.floor(e*this.s*this.n/this.d),e)},round:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new c(NaN):new c(Math.round(e*this.s*this.n/this.d),e)},inverse:function(){return new c(this.s*this.d,this.n)},pow:function(e){return e<0?new c(Math.pow(this.s*this.d,-e),Math.pow(this.n,-e)):new c(Math.pow(this.s*this.n,e),Math.pow(this.d,e))},equals:function(e,t){return r(e,t),this.s*this.n*d.d==d.s*d.n*this.d},compare:function(e,t){r(e,t);t=this.s*this.n*d.d-d.s*d.n*this.d;return(0<t)-(t<0)},simplify:function(e){if(isNaN(this.n)||isNaN(this.d))return this;var t=this.abs().toContinued();e=e||.001;for(var r=0;r<t.length;r++){var n=function e(t){return 1===t.length?new c(t[0]):e(t.slice(1)).inverse().add(t[0])}(t.slice(0,r+1));if(n.sub(this.abs()).abs().valueOf()<e)return n.mul(this.s)}return this},divisible:function(e,t){return r(e,t),!(!(d.n*this.d)||this.n*d.d%(d.n*this.d))},valueOf:function(){return this.s*this.n/this.d},toFraction:function(e){var t,r="",n=this.n,i=this.d;return this.s<0&&(r+="-"),1===i?r+=n:(e&&0<(t=Math.floor(n/i))&&(r+=t,r+=" ",n%=i),r+=n,r+="/",r+=i),r},toLatex:function(e){var t,r="",n=this.n,i=this.d;return this.s<0&&(r+="-"),1===i?r+=n:(e&&0<(t=Math.floor(n/i))&&(r+=t,n%=i),r+="\\frac{",r+=n,r+="}{",r+=i,r+="}"),r},toContinued:function(){var e,t=this.n,r=this.d,n=[];if(isNaN(this.n)||isNaN(this.d))return n;for(;n.push(Math.floor(t/r)),e=t%r,t=r,r=e,1!==t;);return n},toString:function(e){var t=this.n,r=this.d;if(isNaN(t)||isNaN(r))return"NaN";c.REDUCE||(t/=i=u(t,r),r/=i),e=e||15;var n=function(e){for(;e%2==0;e/=2);for(;e%5==0;e/=5);if(1===e)return 0;for(var t=10%e,r=1;1!==t;r++)if(t=10*t%e,2e3<r)return 0;return r}(r),i=s(0,r,n),a=-1===this.s?"-":"";if(a+=t/r|0,t%=r,(t*=10)&&(a+="."),n){for(var o=i;o--;)a+=t/r|0,t%=r,t*=10;a+="(";for(o=n;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 c}.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(e<s)return-1;if(s<e)return 1}for(var m=0,h=Math.max(l.length,p.length);m<h;m++){if(i=!(l[m]||"").match(f)&&parseFloat(l[m])||l[m]||0,a=!(p[m]||"").match(f)&&parseFloat(p[m])||p[m]||0,isNaN(i)!==isNaN(a))return isNaN(i)?1:-1;if(typeof i!=typeof a&&(i+="",a+=""),i<a)return-1;if(a<i)return 1}return 0}},function(t,De,Re){var Ue;!function(){"use strict";var f,C,a,o=9e15,h=1e9,d="0123456789abcdef",n="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",i="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",s={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-o,maxE:o,crypto:!1},v=!0,u="[DecimalError] ",y=u+"Invalid argument: ",c=u+"Precision limit exceeded",l=u+"crypto unavailable",_=Math.floor,g=Math.pow,p=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,m=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,b=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,x=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,T=1e7,q=7,w=n.length-1,N=i.length-1,O={name:"[object Decimal]"};function M(e){var t,r,n,i=e.length-1,a="",o=e[0];if(0<i){for(a+=o,t=1;t<i;t++)n=e[t]+"",(r=q-n.length)&&(a+=L(r)),a+=n;o=e[t],(r=q-(n=o+"").length)&&(a+=L(r))}else if(0===o)return"0";for(;o%10==0;)o/=10;return a+o}function j(e,t,r){if(e!==~~e||e<t||r<e)throw Error(y+e)}function E(e,t,r,n){for(var i,a,o=e[0];10<=o;o/=10)--t;return--t<0?(t+=q,i=0):(i=Math.ceil((t+1)/q),t%=q),o=g(10,q-t),a=e[i]%o|0,null==n?t<3?(0==t?a=a/100|0:1==t&&(a=a/10|0),r<4&&99999==a||3<r&&49999==a||5e4==a||0==a):(r<4&&a+1==o||3<r&&a+1==o/2)&&(e[i+1]/o/100|0)==g(10,t-2)-1||(a==o/2||0==a)&&0==(e[i+1]/o/100|0):t<4?(0==t?a=a/1e3|0:1==t?a=a/100|0:2==t&&(a=a/10|0),(n||r<4)&&9999==a||!n&&3<r&&4999==a):((n||r<4)&&a+1==o||!n&&3<r&&a+1==o/2)&&(e[i+1]/o/1e3|0)==g(10,t-3)-1}function S(e,t,r){for(var n,i,a=[0],o=0,s=e.length;o<s;){for(i=a.length;i--;)a[i]*=t;for(a[0]+=d.indexOf(e.charAt(o++)),n=0;n<a.length;n++)a[n]>r-1&&(void 0===a[n+1]&&(a[n+1]=0),a[n+1]+=a[n]/r|0,a[n]%=r)}return a.reverse()}O.absoluteValue=O.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),z(e)},O.ceil=function(){return z(new this.constructor(this),this.e+1,2)},O.comparedTo=O.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;t<r;++t)if(i[t]!==a[t])return i[t]>a[t]^o<0?1:-1;return n===e?0:e<n^o<0?1:-1},O.cosine=O.cos=function(){var e,t,r=this,n=r.constructor;return r.d?r.d[0]?(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+q,n.rounding=1,r=function(e,t){var r,n=t.d.length;n=n<32?(r=Math.ceil(n/3),(1/Y(4,r)).toString()):(r=16,"2.3283064365386962890625e-10");e.precision+=r,t=W(e,1,t.times(n),new e(1));for(var i=r;i--;){var a=t.times(t);t=a.times(a).minus(a).times(8).plus(1)}return e.precision-=r,t}(n,X(n,r)),n.precision=e,n.rounding=t,z(2==a||3==a?r.neg():r,e,t,!0)):new n(1):new n(NaN)},O.cubeRoot=O.cbrt=function(){var e,t,r,n,i,a,o,s,u,c,f=this,l=f.constructor;if(!f.isFinite()||f.isZero())return new l(f);for(v=!1,(a=f.s*g(f.s*f,1/3))&&Math.abs(a)!=1/0?n=new l(a.toString()):(r=M(f.d),(a=((e=f.e)-r.length+1)%3)&&(r+=1==a||-2==a?"0":"00"),a=g(r,1/3),e=_((e+1)/3)-(e%3==(e<0?-1:2)),(n=new l(r=a==1/0?"5e"+e:(r=a.toExponential()).slice(0,r.indexOf("e")+1)+e)).s=f.s),o=(e=l.precision)+3;;)if(c=(u=(s=n).times(s).times(s)).plus(f),n=A(c.plus(f).times(s),c.plus(u),o+2,1),M(s.d).slice(0,o)===(r=M(n.d)).slice(0,o)){if("9999"!=(r=r.slice(o-3,o+1))&&(i||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(z(n,e+1,1),t=!n.times(n).times(n).eq(f));break}if(!i&&(z(s,e+1,0),s.times(s).times(s).eq(f))){n=s;break}o+=4,i=1}return v=!0,z(n,e,l.rounding,t)},O.decimalPlaces=O.dp=function(){var e,t=this.d,r=NaN;if(t){if(r=((e=t.length-1)-_(this.e/q))*q,e=t[e])for(;e%10==0;e/=10)r--;r<0&&(r=0)}return r},O.dividedBy=O.div=function(e){return A(this,new this.constructor(e))},O.dividedToIntegerBy=O.divToInt=function(e){var t=this.constructor;return z(A(this,new t(e),0,1,1),t.precision,t.rounding)},O.equals=O.eq=function(e){return 0===this.cmp(e)},O.floor=function(){return z(new this.constructor(this),this.e+1,3)},O.greaterThan=O.gt=function(e){return 0<this.cmp(e)},O.greaterThanOrEqualTo=O.gte=function(e){e=this.cmp(e);return 1==e||0===e},O.hyperbolicCosine=O.cosh=function(){var e,t,r,n,i=this,a=i.constructor,o=new a(1);if(!i.isFinite())return new a(i.s?1/0:NaN);if(i.isZero())return o;t=a.precision,r=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,n=(n=i.d.length)<32?(1/Y(4,e=Math.ceil(n/3))).toString():(e=16,"2.3283064365386962890625e-10"),i=W(a,1,i.times(n),new a(1),!0);for(var s,u=e,c=new a(8);u--;)s=i.times(i),i=o.minus(s.times(c.minus(s.times(c))));return z(i,a.precision=t,a.rounding=r,!0)},O.hyperbolicSine=O.sinh=function(){var e,t,r,n,i=this,a=i.constructor;if(!i.isFinite()||i.isZero())return new a(i);if(t=a.precision,r=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,(n=i.d.length)<3)i=W(a,2,i,i,!0);else{e=16<(e=1.4*Math.sqrt(n))?16:0|e,i=W(a,2,i=i.times(1/Y(5,e)),i,!0);for(var o,s=new a(5),u=new a(16),c=new a(20);e--;)o=i.times(i),i=i.times(s.plus(o.times(u.times(o).plus(c))))}return z(i,a.precision=t,a.rounding=r,!0)},O.hyperbolicTangent=O.tanh=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+7,n.rounding=1,A(r.sinh(),r.cosh(),n.precision=e,n.rounding=t)):new n(r.s)},O.inverseCosine=O.acos=function(){var e=this,t=e.constructor,r=e.abs().cmp(1),n=t.precision,i=t.rounding;return-1!==r?0===r?e.isNeg()?P(t,n,i):new t(0):new t(NaN):e.isZero()?P(t,n+4,i).times(.5):(t.precision=n+6,t.rounding=1,e=e.asin(),r=P(t,n+4,i).times(.5),t.precision=n,t.rounding=i,r.minus(e))},O.inverseHyperbolicCosine=O.acosh=function(){var e,t,r=this,n=r.constructor;return r.lte(1)?new n(r.eq(1)?0:NaN):r.isFinite()?(e=n.precision,t=n.rounding,n.precision=e+Math.max(Math.abs(r.e),r.sd())+4,n.rounding=1,v=!1,r=r.times(r).minus(1).sqrt().plus(r),v=!0,n.precision=e,n.rounding=t,r.ln()):new n(r)},O.inverseHyperbolicSine=O.asinh=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+2*Math.max(Math.abs(r.e),r.sd())+6,n.rounding=1,v=!1,r=r.times(r).plus(1).sqrt().plus(r),v=!0,n.precision=e,n.rounding=t,r.ln())},O.inverseHyperbolicTangent=O.atanh=function(){var e,t,r,n=this,i=n.constructor;return n.isFinite()?0<=n.e?new i(n.abs().eq(1)?n.s/0:n.isZero()?n:NaN):(e=i.precision,t=i.rounding,r=n.sd(),Math.max(r,e)<2*-n.e-1?z(new i(n),e,t,!0):(i.precision=r=r-n.e,n=A(n.plus(1),new i(1).minus(n),r+e,1),i.precision=e+4,i.rounding=1,n=n.ln(),i.precision=e,i.rounding=t,n.times(.5))):new i(NaN)},O.inverseSine=O.asin=function(){var e,t,r,n=this,i=n.constructor;return n.isZero()?new i(n):(e=n.abs().cmp(1),t=i.precision,r=i.rounding,-1!==e?0===e?((e=P(i,t+4,r).times(.5)).s=n.s,e):new i(NaN):(i.precision=t+6,i.rounding=1,n=n.div(new i(1).minus(n.times(n)).sqrt().plus(1)).atan(),i.precision=t,i.rounding=r,n.times(2)))},O.inverseTangent=O.atan=function(){var e,t,r,n,i,a,o,s,u,c=this,f=c.constructor,l=f.precision,p=f.rounding;if(c.isFinite()){if(c.isZero())return new f(c);if(c.abs().eq(1)&&l+4<=N)return(o=P(f,l+4,p).times(.25)).s=c.s,o}else{if(!c.s)return new f(NaN);if(l+4<=N)return(o=P(f,l+4,p).times(.5)).s=c.s,o}for(f.precision=s=l+10,f.rounding=1,e=r=Math.min(28,s/q+2|0);e;--e)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(v=!1,t=Math.ceil(s/q),n=1,u=c.times(c),o=new f(c),i=c;-1!==e;)if(i=i.times(u),a=o.minus(i.div(n+=2)),i=i.times(u),void 0!==(o=a.plus(i.div(n+=2))).d[t])for(e=t;o.d[e]===a.d[e]&&e--;);return r&&(o=o.times(2<<r-1)),v=!0,z(o,f.precision=l,f.rounding=p,!0)},O.isFinite=function(){return!!this.d},O.isInteger=O.isInt=function(){return!!this.d&&_(this.e/q)>this.d.length-2},O.isNaN=function(){return!this.s},O.isNegative=O.isNeg=function(){return this.s<0},O.isPositive=O.isPos=function(){return 0<this.s},O.isZero=function(){return!!this.d&&0===this.d[0]},O.lessThan=O.lt=function(e){return this.cmp(e)<0},O.lessThanOrEqualTo=O.lte=function(e){return this.cmp(e)<1},O.logarithm=O.log=function(e){var t,r,n,i,a,o,s,u,c=this,f=c.constructor,l=f.precision,p=f.rounding;if(null==e)e=new f(10),t=!0;else{if(r=(e=new f(e)).d,e.s<0||!r||!r[0]||e.eq(1))return new f(NaN);t=e.eq(10)}if(r=c.d,c.s<0||!r||!r[0]||c.eq(1))return new f(r&&!r[0]?-1/0:1!=c.s?NaN:r?0:1/0);if(t)if(1<r.length)a=!0;else{for(i=r[0];i%10==0;)i/=10;a=1!==i}if(v=!1,o=Z(c,s=l+5),n=t?U(f,s+10):Z(e,s),E((u=A(o,n,s,1)).d,i=l,p))do{if(o=Z(c,s+=10),n=t?U(f,s+10):Z(e,s),u=A(o,n,s,1),!a){+M(u.d).slice(i+1,i+15)+1==1e14&&(u=z(u,l+1,0));break}}while(E(u.d,i+=10,p));return v=!0,z(u,l,p)},O.minus=O.sub=function(e){var t,r,n,i,a,o,s,u,c,f,l,p=this,m=p.constructor;if(e=new m(e),!p.d||!e.d)return p.s&&e.s?p.d?e.s=-e.s:e=new m(e.d||p.s!==e.s?p:NaN):e=new m(NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(c=p.d,l=e.d,s=m.precision,u=m.rounding,!c[0]||!l[0]){if(l[0])e.s=-e.s;else{if(!c[0])return new m(3===u?-0:0);e=new m(p)}return v?z(e,s,u):e}if(r=_(e.e/q),p=_(p.e/q),c=c.slice(),a=p-r){for(o=(f=a<0)?(t=c,a=-a,l.length):(t=l,r=p,c.length),(n=Math.max(Math.ceil(s/q),o)+2)<a&&(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<o;n++)if(c[n]!=l[n]){f=c[n]<l[n];break}a=0}for(f&&(t=c,c=l,l=t,e.s=-e.s),o=c.length,n=l.length-o;0<n;--n)c[o++]=0;for(n=l.length;a<n;){if(c[--n]<l[n]){for(i=n;i&&0===c[--i];)c[i]=T-1;--c[i],c[n]+=T}c[n]-=l[n]}for(;0===c[--o];)c.pop();for(;0===c[0];c.shift())--r;return c[0]?(e.d=c,e.e=R(c,r),v?z(e,s,u):e):new m(3===u?-0:0)},O.modulo=O.mod=function(e){var t,r=this,n=r.constructor;return e=new n(e),!r.d||!e.s||e.d&&!e.d[0]?new n(NaN):!e.d||r.d&&!r.d[0]?z(new n(r),n.precision,n.rounding):(v=!1,9==n.modulo?(t=A(r,e.abs(),0,3,1)).s*=e.s:t=A(r,e,0,n.modulo,1),t=t.times(e),v=!0,r.minus(t))},O.naturalExponential=O.exp=function(){return G(this)},O.naturalLogarithm=O.ln=function(){return Z(this)},O.negated=O.neg=function(){var e=new this.constructor(this);return e.s=-e.s,z(e)},O.plus=O.add=function(e){var t,r,n,i,a,o,s,u,c=this,f=c.constructor;if(e=new f(e),!c.d||!e.d)return c.s&&e.s?c.d||(e=new f(e.d||c.s===e.s?c:NaN)):e=new f(NaN),e;if(c.s!=e.s)return e.s=-e.s,c.minus(e);if(s=c.d,u=e.d,a=f.precision,o=f.rounding,!s[0]||!u[0])return u[0]||(e=new f(c)),v?z(e,a,o):e;if(f=_(c.e/q),c=_(e.e/q),s=s.slice(),n=f-c){for((i=(i=n<0?(r=s,n=-n,u.length):(r=u,c=f,s.length))<(f=Math.ceil(a/q))?f+1:i+1)<n&&(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)/T|0,s[n]%=T;for(t&&(s.unshift(t),++c),i=s.length;0==s[--i];)s.pop();return e.d=s,e.e=R(s,c),v?z(e,a,o):e},O.precision=O.sd=function(e){var t;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(y+e);return this.d?(t=F(this.d),e&&this.e+1>t&&(t=this.e+1)):t=NaN,t},O.round=function(){var e=this.constructor;return z(new e(this),this.e+1,e.rounding)},O.sine=O.sin=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+q,n.rounding=1,r=function(e,t){var r,n=t.d.length;if(n<3)return W(e,2,t,t);r=16<(r=1.4*Math.sqrt(n))?16:0|r,t=t.times(1/Y(5,r)),t=W(e,2,t,t);for(var i,a=new e(5),o=new e(16),s=new e(20);r--;)i=t.times(t),t=t.times(a.plus(i.times(o.times(i).minus(s))));return t}(n,X(n,r)),n.precision=e,n.rounding=t,z(2<a?r.neg():r,e,t,!0)):new n(NaN)},O.squareRoot=O.sqrt=function(){var e,t,r,n,i,a,o=this,s=o.d,u=o.e,c=o.s,f=o.constr