simple-squiggle/node_modules/mathjs/lib/browser/math.js

41 lines
666 KiB
JavaScript
Raw Normal View History

/**
* 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 10.4.3
* @date 2022-04-08
*
* @license
* Copyright (C) 2013-2022 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 function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=254)}([function(e,t,r){var n=r(110),i=r(36),a=r(192);n||i(Object.prototype,"toString",a,{unsafe:!0})},function(e,t,r){(function(t){var r=function(e){return e&&e.Math==Math&&e};e.exports=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof t&&t)||function(){return this}()||Function("return this")()}).call(this,r(188))},,function(e,t){function r(t){return e.exports=r="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.exports.__esModule=!0,e.exports.default=e.exports,r(t)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){"use strict";var n=r(6),i=r(81).map;n({target:"Array",proto:!0,forced:!r(82)("map")},{map:function(e){return i(this,e,arguments.length>1?arguments[1]:void 0)}})},function(e,t,r){var n=r(1),i=r(144),a=r(145),o=r(193),s=r(53),u=function(e){if(e&&e.forEach!==o)try{s(e,"forEach",o)}catch(t){e.forEach=o}};for(var c in i)i[c]&&u(n[c]&&n[c].prototype);u(a)},function(e,t,r){var n=r(1),i=r(58).f,a=r(53),o=r(36),s=r(107),u=r(140),c=r(80);e.exports=function(e,t){var r,f,l,p,m,h=e.target,d=e.global,v=e.stat;if(r=d?n:v?n[h]||s(h,{}):(n[h]||{}).prototype)for(f in t){if(p=t[f],l=e.noTargetGet?(m=i(r,f))&&m.value:r[f],!c(d?f:h+(v?".":"#")+f,e.forced)&&void 0!==l){if(typeof p==typeof l)continue;u(p,l)}(e.sham||l&&l.sham)&&a(p,"sham",!0),o(r,f,p,e)}}},function(e,t,r){"use strict";var n=r(9),i=r(78).PROPER,a=r(36),o=r(21),s=r(52),u=r(34),c=r(8),f=r(116),l=RegExp.prototype,p=l.toString,m=n(f),h=c((function(){return"/a/b"!=p.call({source:"a",flags:"b"})})),d=i&&"toString"!=p.name;(h||d)&&a(RegExp.prototype,"toString",(function(){var e=o(this),t=u(e.source),r=e.flags;return"/"+t+"/"+u(void 0===r&&s(l,e)&&!("flags"in l)?m(e):r)}),{unsafe:!0})},function(e,t){e.exports=function(e){try{return!!e()}catch(e){return!0}}},function(e,t,r){var n=r(86),i=Function.prototype,a=i.bind,o=i.call,s=n&&a.bind(o,o);e.exports=n?function(e){return e&&s(e)}:function(e){return e&&function(){return o.apply(e,arguments)}}},function(e,t,r){"use strict";var n=r(6),i=r(100);n({target:"RegExp",proto:!0,forced:/./.exec!==i},{exec:i})},function(e,t,r){"use strict";var n,i,a,o,s=r(6),u=r(67),c=r(1),f=r(49),l=r(22),p=r(224),m=r(36),h=r(174),d=r(115),v=r(85),y=r(117),g=r(66),x=r(15),b=r(23),w=r(128),N=r(93),M=r(126),E=r(129),S=r(155),A=r(177).set,O=r(226),C=r(229),_=r(230),T=r(179),I=r(231),k=r(232),z=r(44),q=r(80),R=r(16),B=r(233),D=r(130),j=r(76),P=R("species"),F="Promise",U=z.getterFor(F),L=z.set,$=z.getterFor(F),H=p&&p.prototype,G=p,V=H,Z=c.TypeError,W=c.document,Y=c.process,J=T.f,X=J,Q=!!(W&&W.createEvent&&c.dispatchEvent),K=x(c.PromiseRejectionEvent),ee=!1,te=q(F,(function(){var e=N(G),t=e!==String(G);if(!t&&66===j)return!0;if(u&&!V.finally)return!0;if(j>=51&&/native code/.test(e))return!1;var
/**
* @license Complex.js v2.1.0 12/05/2020
*
* Copyright (c) 2020, Robert Eisele (robert@xarg.org)
* Dual licensed under the MIT or GPL Version 2 licenses.
**/!function(r){"use strict";var i=function(e){return.5*(Math.exp(e)+Math.exp(-e))},a=function(e){return.5*(Math.exp(e)-Math.exp(-e))},o=function(){throw SyntaxError("Invalid Param")};function s(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):(e/=2,t/=2,.5*Math.log(e*e+t*t)+Math.LN2)}function u(e,t){if(!(this instanceof u))return new u(e,t);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 u.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 u.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]):o();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&&o();for(var s=0;s<n.length;s++){var c=n[s];" "===c||"\t"===c||"\n"===c||("+"===c?i++:"-"===c?a++:"i"===c||"I"===c?(i+a===0&&o()," "===n[s+1]||isNaN(n[s+1])?r.im+=parseFloat((a%2?"-":"")+"1"):(r.im+=parseFloat((a%2?"-":"")+n[s+1]),s++),i=a=0):((i+a===0||isNaN(c))&&o(),"i"===n[s+1]||"I"===n[s+1]?(r.im+=parseFloat((a%2?"-":"")+c),s++):r.re+=parseFloat((a%2?"-":"")+c),i=a=0))}i+a>0&&o();break;case"number":r.im=0,r.re=e;break;default:o()}return isNaN(r.re)||isNaN(r.im),r}(e,t);this.re=r.re,this.im=r.im}u.prototype={re:0,im:0,sign:function(){var e=this.abs();return new u(this.re/e,this.im/e)},add:function(e,t){var r=new u(e,t);return this.isInfinite()&&r.isInfinite()?u.NAN:this.isInfinite()||r.isInfinite()?u.INFINITY:new u(this.re+r.re,this.im+r.im)},sub:function(e,t){var r=new u(e,t);return this.isInfinite()&&r.isInfinite()?u.NAN:this.isInfinite()||r.isInfinite()?u.INFINITY:new u(this.re-r.re,this.im-r.im)},mul:function(e,t){var r=new u(e,t);return this.isInfinite()&&r.isZero()||this.isZero()&&r.isInfinite()?u.NAN:this.isInfinite()||r.isInfinite()?u.INFINITY:0===r.im&&0===this.im?new u(this.re*r.re,0):new u(this.re*r.re-this.im*r.im,this.re*r.im+this.im*r.re)},div:function(e,t){var r=new u(e,t);if(this.isZero()&&r.isZero()||this.isInfinite()&&r.isInfinite())return u.NAN;if(this.isInfinite()||r.isZero())return u.INFINITY;if(this.isZero()||r.isInfinite())return u.ZERO;e=this.re,t=this.im;var n,i,a=r.re,o=r.im;return 0===o?new u(e/a,t/a):Math.abs(a)<Math.abs(o)?new u((e*(i=a/o)+t)/(n=a*i+o),(t*i-e)/n):new u((e+t*(i=o/a))/(n=o*i+a),(t-e*i)/n)},pow:function(e,t){var r=new u(e,t);if(e=this.re,t=this.im,r.isZero())return u.ONE;if(0===r.im){if(0===t&&e>0)return new u(Math.pow(e,r.re),0);if(0===e)switch((r.re%4+4)%4){case 0:return new u(Math.pow(t,r.re),0);case 1:return new u(0,Math.pow(t,r.re));case 2:return new u(-Math.pow(t,r.re),0);case 3:return new u(0,-Math.pow(t,r.re))}}if(0===e&&0===t&&r.re>0&&r.im>=0)return u.ZERO;var n=Math.atan2(t,e),i=s(e,t);return e=Math.exp(r.re*i-r.im*n),t=r.im*i+r.re*n,new u(e*Math.cos(t),e*Math.sin(t))},sqrt:function(){var e,t,r=this.re,n=this.im,i=this.abs();if(r>=0){if(0===n)return new u(Math.sqrt(r),0);e=.5*Math.sqrt(2*(i+r))}else e=Math.abs(n)/Math.sqrt(2*(i-r));return t=r<=0?.5*Math.sqrt(2*(i-r)):Math.abs(n)/Math.sqrt(2*(i+r)),new u(e,n<0?-t:t)},exp:function(){var e=Math.exp(this.re);return this.im,new u(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){var e=this.re,t=this.im;return new u(Math.expm1(e)*Math.cos(t)+function(e){var t=Math.PI/4;if(-t>e||e>t)return Math.cos(e)-1;var r=e*e;return r*(r*(r*(r*(r*(r*(r*(r/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-.5)}(t),Math.exp(e)*Math.sin(t))},log:function(){var e=this.re,t=this.im;return new u(s(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):(r<n?(r=n,n=e/t):n=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 u(Math.sin(e)*i(t),Math.cos(
/**
* @license Fraction.js v4.2.0 05/03/2022
* https://www.xarg.org/2014/03/rational-numbers-in-javascript/
*
* Copyright (c) 2021, Robert Eisele (robert@xarg.org)
* Dual licensed under the MIT or GPL Version 2 licenses.
**/!function(r){"use strict";var i={s:1,n:0,d:1};function a(e,t){if(isNaN(e=parseInt(e,10)))throw f.InvalidParameter;return e*t}function o(e,t){if(0===t)throw f.DivisionByZero;var r=Object.create(f.prototype);r.s=e<0?-1:1;var n=c(e=e<0?-e:e,t);return r.n=e/n,r.d=t/n,r}function s(e){for(var t={},r=e,n=2,i=4;i<=r;){for(;r%n==0;)r/=n,t[n]=(t[n]||0)+1;i+=1+2*n++}return r!==e?r>1&&(t[r]=(t[r]||0)+1):t[e]=(t[e]||0)+1,t}var u=function(e,t){var r,n=0,o=1,s=1,u=0,c=0,l=0,p=1,m=1,h=0,d=1,v=1,y=1,g=1e7;if(null==e);else if(void 0!==t){if(s=(n=e)*(o=t),n%1!=0||o%1!=0)throw f.NonIntegerParameter}else switch(typeof e){case"object":if("d"in e&&"n"in e)n=e.n,o=e.d,"s"in e&&(n*=e.s);else{if(!(0 in e))throw f.InvalidParameter;n=e[0],1 in e&&(o=e[1])}s=n*o;break;case"number":if(e<0&&(s=e,e=-e),e%1==0)n=e;else if(e>0){for(e>=1&&(e/=m=Math.pow(10,Math.floor(1+Math.log(e)/Math.LN10)));d<=g&&y<=g;){if(e===(r=(h+v)/(d+y))){d+y<=g?(n=h+v,o=d+y):y>d?(n=v,o=y):(n=h,o=d);break}e>r?(h+=v,d+=y):(v+=h,y+=d),d>g?(n=v,o=y):(n=h,o=d)}n*=m}else(isNaN(e)||isNaN(t))&&(o=n=NaN);break;case"string":if(null===(d=e.match(/\d+|./g)))throw f.InvalidParameter;if("-"===d[h]?(s=-1,h++):"+"===d[h]&&h++,d.length===h+1?c=a(d[h++],s):"."===d[h+1]||"."===d[h]?("."!==d[h]&&(u=a(d[h++],s)),(++h+1===d.length||"("===d[h+1]&&")"===d[h+3]||"'"===d[h+1]&&"'"===d[h+3])&&(c=a(d[h],s),p=Math.pow(10,d[h].length),h++),("("===d[h]&&")"===d[h+2]||"'"===d[h]&&"'"===d[h+2])&&(l=a(d[h+1],s),m=Math.pow(10,d[h+1].length)-1,h+=3)):"/"===d[h+1]||":"===d[h+1]?(c=a(d[h],s),p=a(d[h+2],1),h+=3):"/"===d[h+3]&&" "===d[h+1]&&(u=a(d[h],s),c=a(d[h+2],s),p=a(d[h+4],1),h+=5),d.length<=h){s=n=l+(o=p*m)*u+m*c;break}default:throw f.InvalidParameter}if(0===o)throw f.DivisionByZero;i.s=s<0?-1:1,i.n=Math.abs(n),i.d=Math.abs(o)};function c(e,t){if(!e)return t;if(!t)return e;for(;;){if(!(e%=t))return t;if(!(t%=e))return e}}function f(e,t){if(u(e,t),!(this instanceof f))return o(i.s*i.n,i.d);e=c(i.d,i.n),this.s=i.s,this.n=i.n/e,this.d=i.d/e}f.DivisionByZero=new Error("Division by Zero"),f.InvalidParameter=new Error("Invalid argument"),f.NonIntegerParameter=new Error("Parameters must be integer"),f.prototype={s:1,n:0,d:1,abs:function(){return o(this.n,this.d)},neg:function(){return o(-this.s*this.n,this.d)},add:function(e,t){return u(e,t),o(this.s*this.n*i.d+i.s*this.d*i.n,this.d*i.d)},sub:function(e,t){return u(e,t),o(this.s*this.n*i.d-i.s*this.d*i.n,this.d*i.d)},mul:function(e,t){return u(e,t),o(this.s*i.s*this.n*i.n,this.d*i.d)},div:function(e,t){return u(e,t),o(this.s*i.s*this.n*i.d,this.d*i.n)},clone:function(){return o(this.s*this.n,this.d)},mod:function(e,t){if(isNaN(this.n)||isNaN(this.d))return new f(NaN);if(void 0===e)return o(this.s*this.n%this.d,1);if(u(e,t),0===i.n&&0===this.d)throw f.DivisionByZero;return o(this.s*(i.d*this.n)%(i.n*this.d),i.d*this.d)},gcd:function(e,t){return u(e,t),o(c(i.n,this.n)*c(i.d,this.d),i.d*this.d)},lcm:function(e,t){return u(e,t),0===i.n&&0===this.n?o(0,1):o(i.n*this.n,c(i.n,this.n)*c(i.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new f(NaN):o(Math.ceil(e*this.s*this.n/this.d),e)},floor:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new f(NaN):o(Math.floor(e*this.s*this.n/this.d),e)},round:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new f(NaN):o(Math.round(e*this.s*this.n/this.d),e)},inverse:function(){return o(this.s*this.d,this.n)},pow:function(e,t){if(u(e,t),1===i.d)return i.s<0?o(Math.pow(this.s*this.d,i.n),Math.pow(this.n,i.n)):o(Math.pow(this.s*this.n,i.n),Math.pow(this.d,i.n));if(this.s<0)return null;var r=s(this.n),n=s(this.d),a=1,c=1;for(var f in r)if("1"!==f){if("0"===f){a=0;break}if(r[f]*=i.n,r[f]%i.d!=0)return null;r[f]/=i.d,a*=Math.pow(f,r[f])}for(var f in n)if("1"!==f){if(n[f]*=i.n,n[f]%i.d!=0)return null;n[f]/=i.d,c*=Math.pow(f,n[f])}return i.s<0?o(c,a):o(a,c)},equals:function(e,t){return u(e,t),this.s*this.n*i.d==i.s*i.n*this.d},compare:function(e,t){u(e,t);var r=this.s*this.n*i.d-i.s*i.n*this.d;return(0<r)-(r<0)},simplify:function(e){if(isNaN(this.n)||isNaN(this.d))retur
//# sourceMappingURL=math.js.map