UNPKG

mathjslab

Version:

MathJSLab - An interpreter with language syntax like MATLAB®/Octave, ISBN 978-65-00-82338-7.

2 lines 409 kB
/*! For license information please see mathjslab.node.cjs2015.js.LICENSE.txt */ (()=>{var __webpack_modules__={21:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=s(r(598));r(323),globalThis.crypto=a.default,i(r(504),t)},34:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ComplexConfigKeyTable=void 0,t.ComplexConfigKeyTable=["precision","precisionCompare","rounding","toExpPos","minE","maxE","toExpNeg","modulo","crypto"]},109:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FunctionHandle=t.Structure=t.MultiArray=t.Complex=t.CharString=t.stringClass=t.doubleQuoteCharacter=t.singleQuoteCharacter=t.AST=void 0;const n=r(956),i=r(845),s=r(271),a=r(679);class o{}t.AST=o,o.nodeString=n.CharString.create,o.nodeNumber=i.Complex.parse,o.firstRow=a.MultiArray.firstRow,o.appendRow=a.MultiArray.appendRow,o.emptyArray=a.MultiArray.emptyArray,o.reload=()=>{o.nodeString=n.CharString.create,o.nodeNumber=i.Complex.parse,o.firstRow=a.MultiArray.firstRow,o.appendRow=a.MultiArray.appendRow,o.emptyArray=a.MultiArray.emptyArray},o.omitAnswerTable=["=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|=","++_","--_","_++","_--","CMDWLIST","IF"],o.omitAnswer=e=>o.omitAnswerTable.includes(e.type)||e.omitAnswer,o.nodeLiteral=e=>({type:e}),o.nodeIdentifier=e=>({type:"IDENT",id:e.replace(/(\r\n|[\n\r])|[\ ]/gm,"")}),o.nodeCmdWList=(e,t)=>({type:"CMDWLIST",id:e.id,args:t?t.list:[]}),o.nodeIndexExpr=(e,t=null,r="()")=>({type:"IDX",expr:e,args:t?t.list:[],delim:r}),o.nodeRange=(e,t,r)=>({type:"RANGE",start_:e,stop_:t,stride_:null!=r?r:null}),o.nodeOp=(e,t,r)=>{switch(e){case"+":case"-":case".*":case"*":case"./":case"/":case".\\":case"\\":case".^":case"^":case".**":case"**":case"<":case"<=":case"==":case">=":case">":case"!=":case"~=":case"&":case"|":case"&&":case"||":case"=":case"+=":case"-=":case"*=":case"/=":case"\\=":case"^=":case"**=":case".*=":case"./=":case".\\=":case".^=":case".**=":case"&=":case"|=":return{type:e,left:t,right:r};case"()":case"!":case"~":case"+_":case"-_":case"++_":case"--_":return{type:e,right:t};case".'":case"'":case"_++":case"_--":return{type:e,left:t};default:return{type:`INVALID:${e}`}}},o.nodeListFirst=e=>{if(e){const t={type:"LIST",list:[e]};return e.parent=t,t}return{type:"LIST",list:[]}},o.appendNodeList=(e,t)=>(t.parent=e,e.list.push(t),e),o.nodeList=e=>({type:"LIST",list:e}),o.nodeFirstRow=(e=null,t)=>e?o.firstRow(e.list,t):o.emptyArray(t),o.nodeAppendRow=(e,t=null)=>t?o.appendRow(e,t.list):e,o.nodeIndirectRef=(e,t)=>"."===e.type?(e.field.push(t),e):{type:".",obj:e,field:[t]},o.nodeReturnList=e=>({type:"RETLIST",selector:e}),o.nodeFunctionHandle=(e=null,t=null,r=null)=>new s.FunctionHandle(e?e.id:null,!0,t?t.list:[],r),o.nodeFunction=(e,t,r,n,i)=>({type:"FCN",id:e.id,return:t.list,parameter:r.list,arguments:n.list,statements:i.list}),o.nodeArgumentValidation=(e,t,r=null,n,i=null)=>({name:e,size:t.list,class:r,functions:n.list,default:i}),o.nodeArguments=(e,t)=>({attribute:e,validation:t.list}),o.nodeDeclarationFirst=e=>({type:e,list:[]}),o.nodeAppendDeclaration=(e,t)=>(e.list.push(t),e),o.nodeIfBegin=(e,t)=>({type:"IF",expression:[e],then:[t],else:null}),o.nodeIfAppendElse=(e,t)=>(e.else=t.else,e),o.nodeIfAppendElseIf=(e,t)=>(e.expression.push(t.expression),e.then.push(t.then),e),o.nodeElseIf=(e,t)=>({expression:e,then:t}),o.nodeElse=e=>({else:e}),t.default={AST:o};var l=r(956);Object.defineProperty(t,"singleQuoteCharacter",{enumerable:!0,get:function(){return l.singleQuoteCharacter}}),Object.defineProperty(t,"doubleQuoteCharacter",{enumerable:!0,get:function(){return l.doubleQuoteCharacter}}),Object.defineProperty(t,"stringClass",{enumerable:!0,get:function(){return l.stringClass}}),Object.defineProperty(t,"CharString",{enumerable:!0,get:function(){return l.CharString}});var c=r(845);Object.defineProperty(t,"Complex",{enumerable:!0,get:function(){return c.Complex}});var h=r(679);Object.defineProperty(t,"MultiArray",{enumerable:!0,get:function(){return h.MultiArray}});var u=r(212);Object.defineProperty(t,"Structure",{enumerable:!0,get:function(){return u.Structure}});var d=r(271);Object.defineProperty(t,"FunctionHandle",{enumerable:!0,get:function(){return d.FunctionHandle}})},110:function(e,t,r){var n;!function(){"use strict";var i,s,a,o=9e15,l=1e9,c="0123456789abcdef",h="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",u="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",d={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-o,maxE:o,crypto:!1},p=!0,m="[DecimalError] ",g=m+"Invalid argument: ",f=m+"Precision limit exceeded",x=m+"crypto unavailable",_="[object Decimal]",E=Math.floor,T=Math.pow,y=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,L=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,A=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,C=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,S=1e7,N=h.length-1,M=u.length-1,I={toStringTag:_};function R(e){var t,r,n,i=e.length-1,s="",a=e[0];if(i>0){for(s+=a,t=1;t<i;t++)(r=7-(n=e[t]+"").length)&&(s+=B(r)),s+=n;(r=7-(n=(a=e[t])+"").length)&&(s+=B(r))}else if(0===a)return"0";for(;a%10==0;)a/=10;return s+a}function b(e,t,r){if(e!==~~e||e<t||e>r)throw Error(g+e)}function O(e,t,r,n){var i,s,a,o;for(s=e[0];s>=10;s/=10)--t;return--t<0?(t+=7,i=0):(i=Math.ceil((t+1)/7),t%=7),s=T(10,7-t),o=e[i]%s|0,null==n?t<3?(0==t?o=o/100|0:1==t&&(o=o/10|0),a=r<4&&99999==o||r>3&&49999==o||5e4==o||0==o):a=(r<4&&o+1==s||r>3&&o+1==s/2)&&(e[i+1]/s/100|0)==T(10,t-2)-1||(o==s/2||0==o)&&!(e[i+1]/s/100|0):t<4?(0==t?o=o/1e3|0:1==t?o=o/100|0:2==t&&(o=o/10|0),a=(n||r<4)&&9999==o||!n&&r>3&&4999==o):a=((n||r<4)&&o+1==s||!n&&r>3&&o+1==s/2)&&(e[i+1]/s/1e3|0)==T(10,t-3)-1,a}function w(e,t,r){for(var n,i,s=[0],a=0,o=e.length;a<o;){for(i=s.length;i--;)s[i]*=t;for(s[0]+=c.indexOf(e.charAt(a++)),n=0;n<s.length;n++)s[n]>r-1&&(void 0===s[n+1]&&(s[n+1]=0),s[n+1]+=s[n]/r|0,s[n]%=r)}return s.reverse()}I.absoluteValue=I.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),F(e)},I.ceil=function(){return F(new this.constructor(this),this.e+1,2)},I.clampedTo=I.clamp=function(e,t){var r=this,n=r.constructor;if(e=new n(e),t=new n(t),!e.s||!t.s)return new n(NaN);if(e.gt(t))throw Error(g+t);return r.cmp(e)<0?e:r.cmp(t)>0?t:new n(r)},I.comparedTo=I.cmp=function(e){var t,r,n,i,s=this,a=s.d,o=(e=new s.constructor(e)).d,l=s.s,c=e.s;if(!a||!o)return l&&c?l!==c?l:a===o?0:!a^l<0?1:-1:NaN;if(!a[0]||!o[0])return a[0]?l:o[0]?-c:0;if(l!==c)return l;if(s.e!==e.e)return s.e>e.e^l<0?1:-1;for(t=0,r=(n=a.length)<(i=o.length)?n:i;t<r;++t)if(a[t]!==o[t])return a[t]>o[t]^l<0?1:-1;return n===i?0:n>i^l<0?1:-1},I.cosine=I.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())+7,n.rounding=1,r=function(e,t){var r,n,i;if(t.isZero())return t;(n=t.d.length)<32?i=(1/K(4,r=Math.ceil(n/3))).toString():(r=16,i="2.3283064365386962890625e-10"),e.precision+=r,t=X(e,1,t.times(i),new e(1));for(var s=r;s--;){var a=t.times(t);t=a.times(a).minus(a).times(8).plus(1)}return e.precision-=r,t}(n,$(n,r)),n.precision=e,n.rounding=t,F(2==a||3==a?r.neg():r,e,t,!0)):new n(1):new n(NaN)},I.cubeRoot=I.cbrt=function(){var e,t,r,n,i,s,a,o,l,c,h=this,u=h.constructor;if(!h.isFinite()||h.isZero())return new u(h);for(p=!1,(s=h.s*T(h.s*h,1/3))&&Math.abs(s)!=1/0?n=new u(s.toString()):(r=R(h.d),(s=((e=h.e)-r.length+1)%3)&&(r+=1==s||-2==s?"0":"00"),s=T(r,1/3),e=E((e+1)/3)-(e%3==(e<0?-1:2)),(n=new u(r=s==1/0?"5e"+e:(r=s.toExponential()).slice(0,r.indexOf("e")+1)+e)).s=h.s),a=(e=u.precision)+3;;)if(c=(l=(o=n).times(o).times(o)).plus(h),n=v(c.plus(h).times(o),c.plus(l),a+2,1),R(o.d).slice(0,a)===(r=R(n.d)).slice(0,a)){if("9999"!=(r=r.slice(a-3,a+1))&&(i||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(F(n,e+1,1),t=!n.times(n).times(n).eq(h));break}if(!i&&(F(o,e+1,0),o.times(o).times(o).eq(h))){n=o;break}a+=4,i=1}return p=!0,F(n,e,u.rounding,t)},I.decimalPlaces=I.dp=function(){var e,t=this.d,r=NaN;if(t){if(r=7*((e=t.length-1)-E(this.e/7)),e=t[e])for(;e%10==0;e/=10)r--;r<0&&(r=0)}return r},I.dividedBy=I.div=function(e){return v(this,new this.constructor(e))},I.dividedToIntegerBy=I.divToInt=function(e){var t=this.constructor;return F(v(this,new t(e),0,1,1),t.precision,t.rounding)},I.equals=I.eq=function(e){return 0===this.cmp(e)},I.floor=function(){return F(new this.constructor(this),this.e+1,3)},I.greaterThan=I.gt=function(e){return this.cmp(e)>0},I.greaterThanOrEqualTo=I.gte=function(e){var t=this.cmp(e);return 1==t||0===t},I.hyperbolicCosine=I.cosh=function(){var e,t,r,n,i,s=this,a=s.constructor,o=new a(1);if(!s.isFinite())return new a(s.s?1/0:NaN);if(s.isZero())return o;r=a.precision,n=a.rounding,a.precision=r+Math.max(s.e,s.sd())+4,a.rounding=1,(i=s.d.length)<32?t=(1/K(4,e=Math.ceil(i/3))).toString():(e=16,t="2.3283064365386962890625e-10"),s=X(a,1,s.times(t),new a(1),!0);for(var l,c=e,h=new a(8);c--;)l=s.times(s),s=o.minus(l.times(h.minus(l.times(h))));return F(s,a.precision=r,a.rounding=n,!0)},I.hyperbolicSine=I.sinh=function(){var e,t,r,n,i=this,s=i.constructor;if(!i.isFinite()||i.isZero())return new s(i);if(t=s.precision,r=s.rounding,s.precision=t+Math.max(i.e,i.sd())+4,s.rounding=1,(n=i.d.length)<3)i=X(s,2,i,i,!0);else{e=(e=1.4*Math.sqrt(n))>16?16:0|e,i=X(s,2,i=i.times(1/K(5,e)),i,!0);for(var a,o=new s(5),l=new s(16),c=new s(20);e--;)a=i.times(i),i=i.times(o.plus(a.times(l.times(a).plus(c))))}return s.precision=t,s.rounding=r,F(i,t,r,!0)},I.hyperbolicTangent=I.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,v(r.sinh(),r.cosh(),n.precision=e,n.rounding=t)):new n(r.s)},I.inverseCosine=I.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()?U(t,n,i):new t(0):new t(NaN):e.isZero()?U(t,n+4,i).times(.5):(t.precision=n+6,t.rounding=1,e=new t(1).minus(e).div(e.plus(1)).sqrt().atan(),t.precision=n,t.rounding=i,e.times(2))},I.inverseHyperbolicCosine=I.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,p=!1,r=r.times(r).minus(1).sqrt().plus(r),p=!0,n.precision=e,n.rounding=t,r.ln()):new n(r)},I.inverseHyperbolicSine=I.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,p=!1,r=r.times(r).plus(1).sqrt().plus(r),p=!0,n.precision=e,n.rounding=t,r.ln())},I.inverseHyperbolicTangent=I.atanh=function(){var e,t,r,n,i=this,s=i.constructor;return i.isFinite()?i.e>=0?new s(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=s.precision,t=s.rounding,n=i.sd(),Math.max(n,e)<2*-i.e-1?F(new s(i),e,t,!0):(s.precision=r=n-i.e,i=v(i.plus(1),new s(1).minus(i),r+e,1),s.precision=e+4,s.rounding=1,i=i.ln(),s.precision=e,s.rounding=t,i.times(.5))):new s(NaN)},I.inverseSine=I.asin=function(){var e,t,r,n,i=this,s=i.constructor;return i.isZero()?new s(i):(t=i.abs().cmp(1),r=s.precision,n=s.rounding,-1!==t?0===t?((e=U(s,r+4,n).times(.5)).s=i.s,e):new s(NaN):(s.precision=r+6,s.rounding=1,i=i.div(new s(1).minus(i.times(i)).sqrt().plus(1)).atan(),s.precision=r,s.rounding=n,i.times(2)))},I.inverseTangent=I.atan=function(){var e,t,r,n,i,s,a,o,l,c=this,h=c.constructor,u=h.precision,d=h.rounding;if(c.isFinite()){if(c.isZero())return new h(c);if(c.abs().eq(1)&&u+4<=M)return(a=U(h,u+4,d).times(.25)).s=c.s,a}else{if(!c.s)return new h(NaN);if(u+4<=M)return(a=U(h,u+4,d).times(.5)).s=c.s,a}for(h.precision=o=u+10,h.rounding=1,e=r=Math.min(28,o/7+2|0);e;--e)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(p=!1,t=Math.ceil(o/7),n=1,l=c.times(c),a=new h(c),i=c;-1!==e;)if(i=i.times(l),s=a.minus(i.div(n+=2)),i=i.times(l),void 0!==(a=s.plus(i.div(n+=2))).d[t])for(e=t;a.d[e]===s.d[e]&&e--;);return r&&(a=a.times(2<<r-1)),p=!0,F(a,h.precision=u,h.rounding=d,!0)},I.isFinite=function(){return!!this.d},I.isInteger=I.isInt=function(){return!!this.d&&E(this.e/7)>this.d.length-2},I.isNaN=function(){return!this.s},I.isNegative=I.isNeg=function(){return this.s<0},I.isPositive=I.isPos=function(){return this.s>0},I.isZero=function(){return!!this.d&&0===this.d[0]},I.lessThan=I.lt=function(e){return this.cmp(e)<0},I.lessThanOrEqualTo=I.lte=function(e){return this.cmp(e)<1},I.logarithm=I.log=function(e){var t,r,n,i,s,a,o,l,c=this,h=c.constructor,u=h.precision,d=h.rounding;if(null==e)e=new h(10),t=!0;else{if(r=(e=new h(e)).d,e.s<0||!r||!r[0]||e.eq(1))return new h(NaN);t=e.eq(10)}if(r=c.d,c.s<0||!r||!r[0]||c.eq(1))return new h(r&&!r[0]?-1/0:1!=c.s?NaN:r?0:1/0);if(t)if(r.length>1)s=!0;else{for(i=r[0];i%10==0;)i/=10;s=1!==i}if(p=!1,a=q(c,o=u+5),n=t?k(h,o+10):q(e,o),O((l=v(a,n,o,1)).d,i=u,d))do{if(a=q(c,o+=10),n=t?k(h,o+10):q(e,o),l=v(a,n,o,1),!s){+R(l.d).slice(i+1,i+15)+1==1e14&&(l=F(l,u+1,0));break}}while(O(l.d,i+=10,d));return p=!0,F(l,u,d)},I.minus=I.sub=function(e){var t,r,n,i,s,a,o,l,c,h,u,d,m=this,g=m.constructor;if(e=new g(e),!m.d||!e.d)return m.s&&e.s?m.d?e.s=-e.s:e=new g(e.d||m.s!==e.s?m:NaN):e=new g(NaN),e;if(m.s!=e.s)return e.s=-e.s,m.plus(e);if(c=m.d,d=e.d,o=g.precision,l=g.rounding,!c[0]||!d[0]){if(d[0])e.s=-e.s;else{if(!c[0])return new g(3===l?-0:0);e=new g(m)}return p?F(e,o,l):e}if(r=E(e.e/7),h=E(m.e/7),c=c.slice(),s=h-r){for((u=s<0)?(t=c,s=-s,a=d.length):(t=d,r=h,a=c.length),s>(n=Math.max(Math.ceil(o/7),a)+2)&&(s=n,t.length=1),t.reverse(),n=s;n--;)t.push(0);t.reverse()}else{for((u=(n=c.length)<(a=d.length))&&(a=n),n=0;n<a;n++)if(c[n]!=d[n]){u=c[n]<d[n];break}s=0}for(u&&(t=c,c=d,d=t,e.s=-e.s),a=c.length,n=d.length-a;n>0;--n)c[a++]=0;for(n=d.length;n>s;){if(c[--n]<d[n]){for(i=n;i&&0===c[--i];)c[i]=S-1;--c[i],c[n]+=S}c[n]-=d[n]}for(;0===c[--a];)c.pop();for(;0===c[0];c.shift())--r;return c[0]?(e.d=c,e.e=P(c,r),p?F(e,o,l):e):new g(3===l?-0:0)},I.modulo=I.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]?F(new n(r),n.precision,n.rounding):(p=!1,9==n.modulo?(t=v(r,e.abs(),0,3,1)).s*=e.s:t=v(r,e,0,n.modulo,1),t=t.times(e),p=!0,r.minus(t))},I.naturalExponential=I.exp=function(){return G(this)},I.naturalLogarithm=I.ln=function(){return q(this)},I.negated=I.neg=function(){var e=new this.constructor(this);return e.s=-e.s,F(e)},I.plus=I.add=function(e){var t,r,n,i,s,a,o,l,c,h,u=this,d=u.constructor;if(e=new d(e),!u.d||!e.d)return u.s&&e.s?u.d||(e=new d(e.d||u.s===e.s?u:NaN)):e=new d(NaN),e;if(u.s!=e.s)return e.s=-e.s,u.minus(e);if(c=u.d,h=e.d,o=d.precision,l=d.rounding,!c[0]||!h[0])return h[0]||(e=new d(u)),p?F(e,o,l):e;if(s=E(u.e/7),n=E(e.e/7),c=c.slice(),i=s-n){for(i<0?(r=c,i=-i,a=h.length):(r=h,n=s,a=c.length),i>(a=(s=Math.ceil(o/7))>a?s+1:a+1)&&(i=a,r.length=1),r.reverse();i--;)r.push(0);r.reverse()}for((a=c.length)-(i=h.length)<0&&(i=a,r=h,h=c,c=r),t=0;i;)t=(c[--i]=c[i]+h[i]+t)/S|0,c[i]%=S;for(t&&(c.unshift(t),++n),a=c.length;0==c[--a];)c.pop();return e.d=c,e.e=P(c,n),p?F(e,o,l):e},I.precision=I.sd=function(e){var t,r=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(g+e);return r.d?(t=H(r.d),e&&r.e+1>t&&(t=r.e+1)):t=NaN,t},I.round=function(){var e=this,t=e.constructor;return F(new t(e),e.e+1,t.rounding)},I.sine=I.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 t.isZero()?t:X(e,2,t,t);r=(r=1.4*Math.sqrt(n))>16?16:0|r,t=X(e,2,t=t.times(1/K(5,r)),t);for(var i,s=new e(5),a=new e(16),o=new e(20);r--;)i=t.times(t),t=t.times(s.plus(i.times(a.times(i).minus(o))));return t}(n,$(n,r)),n.precision=e,n.rounding=t,F(a>2?r.neg():r,e,t,!0)):new n(NaN)},I.squareRoot=I.sqrt=function(){var e,t,r,n,i,s,a=this,o=a.d,l=a.e,c=a.s,h=a.constructor;if(1!==c||!o||!o[0])return new h(!c||c<0&&(!o||o[0])?NaN:o?a:1/0);for(p=!1,0==(c=Math.sqrt(+a))||c==1/0?(((t=R(o)).length+l)%2==0&&(t+="0"),c=Math.sqrt(t),l=E((l+1)/2)-(l<0||l%2),n=new h(t=c==1/0?"5e"+l:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+l)):n=new h(c.toString()),r=(l=h.precision)+3;;)if(n=(s=n).plus(v(a,s,r+2,1)).times(.5),R(s.d).slice(0,r)===(t=R(n.d)).slice(0,r)){if("9999"!=(t=t.slice(r-3,r+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(F(n,l+1,1),e=!n.times(n).eq(a));break}if(!i&&(F(s,l+1,0),s.times(s).eq(a))){n=s;break}r+=4,i=1}return p=!0,F(n,l,h.rounding,e)},I.tangent=I.tan=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+10,n.rounding=1,(r=r.sin()).s=1,r=v(r,new n(1).minus(r.times(r)).sqrt(),e+10,0),n.precision=e,n.rounding=t,F(2==a||4==a?r.neg():r,e,t,!0)):new n(NaN)},I.times=I.mul=function(e){var t,r,n,i,s,a,o,l,c,h=this,u=h.constructor,d=h.d,m=(e=new u(e)).d;if(e.s*=h.s,!(d&&d[0]&&m&&m[0]))return new u(!e.s||d&&!d[0]&&!m||m&&!m[0]&&!d?NaN:d&&m?0*e.s:e.s/0);for(r=E(h.e/7)+E(e.e/7),(l=d.length)<(c=m.length)&&(s=d,d=m,m=s,a=l,l=c,c=a),s=[],n=a=l+c;n--;)s.push(0);for(n=c;--n>=0;){for(t=0,i=l+n;i>n;)o=s[i]+m[n]*d[i-n-1]+t,s[i--]=o%S|0,t=o/S|0;s[i]=(s[i]+t)%S|0}for(;!s[--a];)s.pop();return t?++r:s.shift(),e.d=s,e.e=P(s,r),p?F(e,u.precision,u.rounding):e},I.toBinary=function(e,t){return Y(this,2,e,t)},I.toDecimalPlaces=I.toDP=function(e,t){var r=this,n=r.constructor;return r=new n(r),void 0===e?r:(b(e,0,l),void 0===t?t=n.rounding:b(t,0,8),F(r,e+r.e+1,t))},I.toExponential=function(e,t){var r,n=this,i=n.constructor;return void 0===e?r=D(n,!0):(b(e,0,l),void 0===t?t=i.rounding:b(t,0,8),r=D(n=F(new i(n),e+1,t),!0,e+1)),n.isNeg()&&!n.isZero()?"-"+r:r},I.toFixed=function(e,t){var r,n,i=this,s=i.constructor;return void 0===e?r=D(i):(b(e,0,l),void 0===t?t=s.rounding:b(t,0,8),r=D(n=F(new s(i),e+i.e+1,t),!1,e+n.e+1)),i.isNeg()&&!i.isZero()?"-"+r:r},I.toFraction=function(e){var t,r,n,i,s,a,o,l,c,h,u,d,m=this,f=m.d,x=m.constructor;if(!f)return new x(m);if(c=r=new x(1),n=l=new x(0),a=(s=(t=new x(n)).e=H(f)-m.e-1)%7,t.d[0]=T(10,a<0?7+a:a),null==e)e=s>0?t:c;else{if(!(o=new x(e)).isInt()||o.lt(c))throw Error(g+o);e=o.gt(t)?s>0?t:c:o}for(p=!1,o=new x(R(f)),h=x.precision,x.precision=s=7*f.length*2;u=v(o,t,0,1,1),1!=(i=r.plus(u.times(n))).cmp(e);)r=n,n=i,i=c,c=l.plus(u.times(i)),l=i,i=t,t=o.minus(u.times(i)),o=i;return i=v(e.minus(r),n,0,1,1),l=l.plus(i.times(c)),r=r.plus(i.times(n)),l.s=c.s=m.s,d=v(c,n,s,1).minus(m).abs().cmp(v(l,r,s,1).minus(m).abs())<1?[c,n]:[l,r],x.precision=h,p=!0,d},I.toHexadecimal=I.toHex=function(e,t){return Y(this,16,e,t)},I.toNearest=function(e,t){var r=this,n=r.constructor;if(r=new n(r),null==e){if(!r.d)return r;e=new n(1),t=n.rounding}else{if(e=new n(e),void 0===t?t=n.rounding:b(t,0,8),!r.d)return e.s?r:e;if(!e.d)return e.s&&(e.s=r.s),e}return e.d[0]?(p=!1,r=v(r,e,0,t,1).times(e),p=!0,F(r)):(e.s=r.s,r=e),r},I.toNumber=function(){return+this},I.toOctal=function(e,t){return Y(this,8,e,t)},I.toPower=I.pow=function(e){var t,r,n,i,s,a,o=this,l=o.constructor,c=+(e=new l(e));if(!(o.d&&e.d&&o.d[0]&&e.d[0]))return new l(T(+o,c));if((o=new l(o)).eq(1))return o;if(n=l.precision,s=l.rounding,e.eq(1))return F(o,n,s);if((t=E(e.e/7))>=e.d.length-1&&(r=c<0?-c:c)<=9007199254740991)return i=V(l,o,r,n),e.s<0?new l(1).div(i):F(i,n,s);if((a=o.s)<0){if(t<e.d.length-1)return new l(NaN);if(1&e.d[t]||(a=1),0==o.e&&1==o.d[0]&&1==o.d.length)return o.s=a,o}return(t=0!=(r=T(+o,c))&&isFinite(r)?new l(r+"").e:E(c*(Math.log("0."+R(o.d))/Math.LN10+o.e+1)))>l.maxE+1||t<l.minE-1?new l(t>0?a/0:0):(p=!1,l.rounding=o.s=1,r=Math.min(12,(t+"").length),(i=G(e.times(q(o,n+r)),n)).d&&O((i=F(i,n+5,1)).d,n,s)&&(t=n+10,+R((i=F(G(e.times(q(o,t+r)),t),t+5,1)).d).slice(n+1,n+15)+1==1e14&&(i=F(i,n+1,0))),i.s=a,p=!0,l.rounding=s,F(i,n,s))},I.toPrecision=function(e,t){var r,n=this,i=n.constructor;return void 0===e?r=D(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(b(e,1,l),void 0===t?t=i.rounding:b(t,0,8),r=D(n=F(new i(n),e,t),e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+r:r},I.toSignificantDigits=I.toSD=function(e,t){var r=this.constructor;return void 0===e?(e=r.precision,t=r.rounding):(b(e,1,l),void 0===t?t=r.rounding:b(t,0,8)),F(new r(this),e,t)},I.toString=function(){var e=this,t=e.constructor,r=D(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+r:r},I.truncated=I.trunc=function(){return F(new this.constructor(this),this.e+1,1)},I.valueOf=I.toJSON=function(){var e=this,t=e.constructor,r=D(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+r:r};var v=function(){function e(e,t,r){var n,i=0,s=e.length;for(e=e.slice();s--;)n=e[s]*t+i,e[s]=n%r|0,i=n/r|0;return i&&e.unshift(i),e}function t(e,t,r,n){var i,s;if(r!=n)s=r>n?1:-1;else for(i=s=0;i<r;i++)if(e[i]!=t[i]){s=e[i]>t[i]?1:-1;break}return s}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]<t[r]?1:0,e[r]=i*n+e[r]-t[r];for(;!e[0]&&e.length>1;)e.shift()}return function(n,i,a,o,l,c){var h,u,d,p,m,g,f,x,_,T,y,L,A,C,N,M,I,R,b,O,w=n.constructor,v=n.s==i.s?1:-1,D=n.d,P=i.d;if(!(D&&D[0]&&P&&P[0]))return new w(n.s&&i.s&&(D?!P||D[0]!=P[0]:P)?D&&0==D[0]||!P?0*v:v/0:NaN);for(c?(m=1,u=n.e-i.e):(c=S,m=7,u=E(n.e/m)-E(i.e/m)),b=P.length,I=D.length,T=(_=new w(v)).d=[],d=0;P[d]==(D[d]||0);d++);if(P[d]>(D[d]||0)&&u--,null==a?(C=a=w.precision,o=w.rounding):C=l?a+(n.e-i.e)+1:a,C<0)T.push(1),g=!0;else{if(C=C/m+2|0,d=0,1==b){for(p=0,P=P[0],C++;(d<I||p)&&C--;d++)N=p*c+(D[d]||0),T[d]=N/P|0,p=N%P|0;g=p||d<I}else{for((p=c/(P[0]+1)|0)>1&&(P=e(P,p,c),D=e(D,p,c),b=P.length,I=D.length),M=b,L=(y=D.slice(0,b)).length;L<b;)y[L++]=0;(O=P.slice()).unshift(0),R=P[0],P[1]>=c/2&&++R;do{p=0,(h=t(P,y,b,L))<0?(A=y[0],b!=L&&(A=A*c+(y[1]||0)),(p=A/R|0)>1?(p>=c&&(p=c-1),1==(h=t(f=e(P,p,c),y,x=f.length,L=y.length))&&(p--,r(f,b<x?O:P,x,c))):(0==p&&(h=p=1),f=P.slice()),(x=f.length)<L&&f.unshift(0),r(y,f,L,c),-1==h&&(h=t(P,y,b,L=y.length))<1&&(p++,r(y,b<L?O:P,L,c)),L=y.length):0===h&&(p++,y=[0]),T[d++]=p,h&&y[0]?y[L++]=D[M]||0:(y=[D[M]],L=1)}while((M++<I||void 0!==y[0])&&C--);g=void 0!==y[0]}T[0]||T.shift()}if(1==m)_.e=u,s=g;else{for(d=1,p=T[0];p>=10;p/=10)d++;_.e=d+u*m-1,F(_,l?a+_.e+1:a,o,g)}return _}}();function F(e,t,r,n){var i,s,a,o,l,c,h,u,d,m=e.constructor;e:if(null!=t){if(!(u=e.d))return e;for(i=1,o=u[0];o>=10;o/=10)i++;if((s=t-i)<0)s+=7,a=t,l=(h=u[d=0])/T(10,i-a-1)%10|0;else if((d=Math.ceil((s+1)/7))>=(o=u.length)){if(!n)break e;for(;o++<=d;)u.push(0);h=l=0,i=1,a=(s%=7)-7+1}else{for(h=o=u[d],i=1;o>=10;o/=10)i++;l=(a=(s%=7)-7+i)<0?0:h/T(10,i-a-1)%10|0}if(n=n||t<0||void 0!==u[d+1]||(a<0?h:h%T(10,i-a-1)),c=r<4?(l||n)&&(0==r||r==(e.s<0?3:2)):l>5||5==l&&(4==r||n||6==r&&(s>0?a>0?h/T(10,i-a):0:u[d-1])%10&1||r==(e.s<0?8:7)),t<1||!u[0])return u.length=0,c?(t-=e.e+1,u[0]=T(10,(7-t%7)%7),e.e=-t||0):u[0]=e.e=0,e;if(0==s?(u.length=d,o=1,d--):(u.length=d+1,o=T(10,7-s),u[d]=a>0?(h/T(10,i-a)%T(10,a)|0)*o:0),c)for(;;){if(0==d){for(s=1,a=u[0];a>=10;a/=10)s++;for(a=u[0]+=o,o=1;a>=10;a/=10)o++;s!=o&&(e.e++,u[0]==S&&(u[0]=1));break}if(u[d]+=o,u[d]!=S)break;u[d--]=0,o=1}for(s=u.length;0===u[--s];)u.pop()}return p&&(e.e>m.maxE?(e.d=null,e.e=NaN):e.e<m.minE&&(e.e=0,e.d=[0])),e}function D(e,t,r){if(!e.isFinite())return W(e);var n,i=e.e,s=R(e.d),a=s.length;return t?(r&&(n=r-a)>0?s=s.charAt(0)+"."+s.slice(1)+B(n):a>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(e.e<0?"e":"e+")+e.e):i<0?(s="0."+B(-i-1)+s,r&&(n=r-a)>0&&(s+=B(n))):i>=a?(s+=B(i+1-a),r&&(n=r-i-1)>0&&(s=s+"."+B(n))):((n=i+1)<a&&(s=s.slice(0,n)+"."+s.slice(n)),r&&(n=r-a)>0&&(i+1===a&&(s+="."),s+=B(n))),s}function P(e,t){var r=e[0];for(t*=7;r>=10;r/=10)t++;return t}function k(e,t,r){if(t>N)throw p=!0,r&&(e.precision=r),Error(f);return F(new e(h),t,1,!0)}function U(e,t,r){if(t>M)throw Error(f);return F(new e(u),t,r,!0)}function H(e){var t=e.length-1,r=7*t+1;if(t=e[t]){for(;t%10==0;t/=10)r--;for(t=e[0];t>=10;t/=10)r++}return r}function B(e){for(var t="";e--;)t+="0";return t}function V(e,t,r,n){var i,s=new e(1),a=Math.ceil(n/7+4);for(p=!1;;){if(r%2&&Z((s=s.times(t)).d,a)&&(i=!0),0===(r=E(r/2))){r=s.d.length-1,i&&0===s.d[r]&&++s.d[r];break}Z((t=t.times(t)).d,a)}return p=!0,s}function J(e){return 1&e.d[e.d.length-1]}function Q(e,t,r){for(var n,i,s=new e(t[0]),a=0;++a<t.length;){if(!(i=new e(t[a])).s){s=i;break}((n=s.cmp(i))===r||0===n&&s.s===r)&&(s=i)}return s}function G(e,t){var r,n,i,s,a,o,l,c=0,h=0,u=0,d=e.constructor,m=d.rounding,g=d.precision;if(!e.d||!e.d[0]||e.e>17)return new d(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(null==t?(p=!1,l=g):l=t,o=new d(.03125);e.e>-2;)e=e.times(o),u+=5;for(l+=n=Math.log(T(2,u))/Math.LN10*2+5|0,r=s=a=new d(1),d.precision=l;;){if(s=F(s.times(e),l,1),r=r.times(++h),R((o=a.plus(v(s,r,l,1))).d).slice(0,l)===R(a.d).slice(0,l)){for(i=u;i--;)a=F(a.times(a),l,1);if(null!=t)return d.precision=g,a;if(!(c<3&&O(a.d,l-n,m,c)))return F(a,d.precision=g,m,p=!0);d.precision=l+=10,r=s=o=new d(1),h=0,c++}a=o}}function q(e,t){var r,n,i,s,a,o,l,c,h,u,d,m=1,g=e,f=g.d,x=g.constructor,_=x.rounding,E=x.precision;if(g.s<0||!f||!f[0]||!g.e&&1==f[0]&&1==f.length)return new x(f&&!f[0]?-1/0:1!=g.s?NaN:f?0:g);if(null==t?(p=!1,h=E):h=t,x.precision=h+=10,n=(r=R(f)).charAt(0),!(Math.abs(s=g.e)<15e14))return c=k(x,h+2,E).times(s+""),g=q(new x(n+"."+r.slice(1)),h-10).plus(c),x.precision=E,null==t?F(g,E,_,p=!0):g;for(;n<7&&1!=n||1==n&&r.charAt(1)>3;)n=(r=R((g=g.times(e)).d)).charAt(0),m++;for(s=g.e,n>1?(g=new x("0."+r),s++):g=new x(n+"."+r.slice(1)),u=g,l=a=g=v(g.minus(1),g.plus(1),h,1),d=F(g.times(g),h,1),i=3;;){if(a=F(a.times(d),h,1),R((c=l.plus(v(a,new x(i),h,1))).d).slice(0,h)===R(l.d).slice(0,h)){if(l=l.times(2),0!==s&&(l=l.plus(k(x,h+2,E).times(s+""))),l=v(l,new x(m),h,1),null!=t)return x.precision=E,l;if(!O(l.d,h-10,_,o))return F(l,x.precision=E,_,p=!0);x.precision=h+=10,c=a=g=v(u.minus(1),u.plus(1),h,1),d=F(g.times(g),h,1),i=o=1}l=c,i+=2}}function W(e){return String(e.s*e.s/0)}function j(e,t){var r,n,i;for((r=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),n=0;48===t.charCodeAt(n);n++);for(i=t.length;48===t.charCodeAt(i-1);--i);if(t=t.slice(n,i)){if(i-=n,e.e=r=r-n-1,e.d=[],n=(r+1)%7,r<0&&(n+=7),n<i){for(n&&e.d.push(+t.slice(0,n)),i-=7;n<i;)e.d.push(+t.slice(n,n+=7));n=7-(t=t.slice(n)).length}else n-=i;for(;n--;)t+="0";e.d.push(+t),p&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function z(e,t){var r,n,s,a,o,l,c,h,u;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),C.test(t))return j(e,t)}else if("Infinity"===t||"NaN"===t)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(L.test(t))r=16,t=t.toLowerCase();else if(y.test(t))r=2;else{if(!A.test(t))throw Error(g+t);r=8}for((a=t.search(/p/i))>0?(c=+t.slice(a+1),t=t.substring(2,a)):t=t.slice(2),o=(a=t.indexOf("."))>=0,n=e.constructor,o&&(a=(l=(t=t.replace(".","")).length)-a,s=V(n,new n(r),a,2*a)),a=u=(h=w(t,r,S)).length-1;0===h[a];--a)h.pop();return a<0?new n(0*e.s):(e.e=P(h,u),e.d=h,p=!1,o&&(e=v(e,s,4*l)),c&&(e=e.times(Math.abs(c)<54?T(2,c):i.pow(2,c))),p=!0,e)}function X(e,t,r,n,i){var s,a,o,l,c=e.precision,h=Math.ceil(c/7);for(p=!1,l=r.times(r),o=new e(n);;){if(a=v(o.times(l),new e(t++*t++),c,1),o=i?n.plus(a):n.minus(a),n=v(a.times(l),new e(t++*t++),c,1),void 0!==(a=o.plus(n)).d[h]){for(s=h;a.d[s]===o.d[s]&&s--;);if(-1==s)break}s=o,o=n,n=a,a=s}return p=!0,a.d.length=h+1,a}function K(e,t){for(var r=e;--t;)r*=e;return r}function $(e,t){var r,n=t.s<0,i=U(e,e.precision,1),s=i.times(.5);if((t=t.abs()).lte(s))return a=n?4:1,t;if((r=t.divToInt(i)).isZero())a=n?3:2;else{if((t=t.minus(r.times(i))).lte(s))return a=J(r)?n?2:3:n?4:1,t;a=J(r)?n?1:4:n?3:2}return t.minus(i).abs()}function Y(e,t,r,n){var i,a,o,h,u,d,p,m,g,f=e.constructor,x=void 0!==r;if(x?(b(r,1,l),void 0===n?n=f.rounding:b(n,0,8)):(r=f.precision,n=f.rounding),e.isFinite()){for(x?(i=2,16==t?r=4*r-3:8==t&&(r=3*r-2)):i=t,(o=(p=D(e)).indexOf("."))>=0&&(p=p.replace(".",""),(g=new f(1)).e=p.length-o,g.d=w(D(g),10,i),g.e=g.d.length),a=u=(m=w(p,10,i)).length;0==m[--u];)m.pop();if(m[0]){if(o<0?a--:((e=new f(e)).d=m,e.e=a,m=(e=v(e,g,r,n,0,i)).d,a=e.e,d=s),o=m[r],h=i/2,d=d||void 0!==m[r+1],d=n<4?(void 0!==o||d)&&(0===n||n===(e.s<0?3:2)):o>h||o===h&&(4===n||d||6===n&&1&m[r-1]||n===(e.s<0?8:7)),m.length=r,d)for(;++m[--r]>i-1;)m[r]=0,r||(++a,m.unshift(1));for(u=m.length;!m[u-1];--u);for(o=0,p="";o<u;o++)p+=c.charAt(m[o]);if(x){if(u>1)if(16==t||8==t){for(o=16==t?4:3,--u;u%o;u++)p+="0";for(u=(m=w(p,i,t)).length;!m[u-1];--u);for(o=1,p="1.";o<u;o++)p+=c.charAt(m[o])}else p=p.charAt(0)+"."+p.slice(1);p=p+(a<0?"p":"p+")+a}else if(a<0){for(;++a;)p="0"+p;p="0."+p}else if(++a>u)for(a-=u;a--;)p+="0";else a<u&&(p=p.slice(0,a)+"."+p.slice(a))}else p=x?"0p+0":"0";p=(16==t?"0x":2==t?"0b":8==t?"0o":"")+p}else p=W(e);return e.s<0?"-"+p:p}function Z(e,t){if(e.length>t)return e.length=t,!0}function ee(e){return new this(e).abs()}function te(e){return new this(e).acos()}function re(e){return new this(e).acosh()}function ne(e,t){return new this(e).plus(t)}function ie(e){return new this(e).asin()}function se(e){return new this(e).asinh()}function ae(e){return new this(e).atan()}function oe(e){return new this(e).atanh()}function le(e,t){e=new this(e),t=new this(t);var r,n=this.precision,i=this.rounding,s=n+4;return e.s&&t.s?e.d||t.d?!t.d||e.isZero()?(r=t.s<0?U(this,n,i):new this(0)).s=e.s:!e.d||t.isZero()?(r=U(this,s,1).times(.5)).s=e.s:t.s<0?(this.precision=s,this.rounding=1,r=this.atan(v(e,t,s,1)),t=U(this,s,1),this.precision=n,this.rounding=i,r=e.s<0?r.minus(t):r.plus(t)):r=this.atan(v(e,t,s,1)):(r=U(this,s,1).times(t.s>0?.25:.75)).s=e.s:r=new this(NaN),r}function ce(e){return new this(e).cbrt()}function he(e){return F(e=new this(e),e.e+1,2)}function ue(e,t,r){return new this(e).clamp(t,r)}function de(e){if(!e||"object"!=typeof e)throw Error(m+"Object expected");var t,r,n,i=!0===e.defaults,s=["precision",1,l,"rounding",0,8,"toExpNeg",-o,0,"toExpPos",0,o,"maxE",0,o,"minE",-o,0,"modulo",0,9];for(t=0;t<s.length;t+=3)if(r=s[t],i&&(this[r]=d[r]),void 0!==(n=e[r])){if(!(E(n)===n&&n>=s[t+1]&&n<=s[t+2]))throw Error(g+r+": "+n);this[r]=n}if(r="crypto",i&&(this[r]=d[r]),void 0!==(n=e[r])){if(!0!==n&&!1!==n&&0!==n&&1!==n)throw Error(g+r+": "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(x);this[r]=!0}else this[r]=!1}return this}function pe(e){return new this(e).cos()}function me(e){return new this(e).cosh()}function ge(e,t){return new this(e).div(t)}function fe(e){return new this(e).exp()}function xe(e){return F(e=new this(e),e.e+1,3)}function _e(){var e,t,r=new this(0);for(p=!1,e=0;e<arguments.length;)if((t=new this(arguments[e++])).d)r.d&&(r=r.plus(t.times(t)));else{if(t.s)return p=!0,new this(1/0);r=t}return p=!0,r.sqrt()}function Ee(e){return e instanceof i||e&&e.toStringTag===_||!1}function Te(e){return new this(e).ln()}function ye(e,t){return new this(e).log(t)}function Le(e){return new this(e).log(2)}function Ae(e){return new this(e).log(10)}function Ce(){return Q(this,arguments,-1)}function Se(){return Q(this,arguments,1)}function Ne(e,t){return new this(e).mod(t)}function Me(e,t){return new this(e).mul(t)}function Ie(e,t){return new this(e).pow(t)}function Re(e){var t,r,n,i,s=0,a=new this(1),o=[];if(void 0===e?e=this.precision:b(e,1,l),n=Math.ceil(e/7),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(n));s<n;)(i=t[s])>=429e7?t[s]=crypto.getRandomValues(new Uint32Array(1))[0]:o[s++]=i%1e7;else{if(!crypto.randomBytes)throw Error(x);for(t=crypto.randomBytes(n*=4);s<n;)(i=t[s]+(t[s+1]<<8)+(t[s+2]<<16)+((127&t[s+3])<<24))>=214e7?crypto.randomBytes(4).copy(t,s):(o.push(i%1e7),s+=4);s=n/4}else for(;s<n;)o[s++]=1e7*Math.random()|0;for(e%=7,(n=o[--s])&&e&&(i=T(10,7-e),o[s]=(n/i|0)*i);0===o[s];s--)o.pop();if(s<0)r=0,o=[0];else{for(r=-1;0===o[0];r-=7)o.shift();for(n=1,i=o[0];i>=10;i/=10)n++;n<7&&(r-=7-n)}return a.e=r,a.d=o,a}function be(e){return F(e=new this(e),e.e+1,this.rounding)}function Oe(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function we(e){return new this(e).sin()}function ve(e){return new this(e).sinh()}function Fe(e){return new this(e).sqrt()}function De(e,t){return new this(e).sub(t)}function Pe(){var e=0,t=arguments,r=new this(t[e]);for(p=!1;r.s&&++e<t.length;)r=r.plus(t[e]);return p=!0,F(r,this.precision,this.rounding)}function ke(e){return new this(e).tan()}function Ue(e){return new this(e).tanh()}function He(e){return F(e=new this(e),e.e+1,1)}(i=function e(t){var r,n,i;function s(e){var t,r,n,i=this;if(!(i instanceof s))return new s(e);if(i.constructor=s,Ee(e))return i.s=e.s,void(p?!e.d||e.e>s.maxE?(i.e=NaN,i.d=null):e.e<s.minE?(i.e=0,i.d=[0]):(i.e=e.e,i.d=e.d.slice()):(i.e=e.e,i.d=e.d?e.d.slice():e.d));if("number"==(n=typeof e)){if(0===e)return i.s=1/e<0?-1:1,i.e=0,void(i.d=[0]);if(e<0?(e=-e,i.s=-1):i.s=1,e===~~e&&e<1e7){for(t=0,r=e;r>=10;r/=10)t++;return void(p?t>s.maxE?(i.e=NaN,i.d=null):t<s.minE?(i.e=0,i.d=[0]):(i.e=t,i.d=[e]):(i.e=t,i.d=[e]))}return 0*e!=0?(e||(i.s=NaN),i.e=NaN,void(i.d=null)):j(i,e.toString())}if("string"===n)return 45===(r=e.charCodeAt(0))?(e=e.slice(1),i.s=-1):(43===r&&(e=e.slice(1)),i.s=1),C.test(e)?j(i,e):z(i,e);if("bigint"===n)return e<0?(e=-e,i.s=-1):i.s=1,j(i,e.toString());throw Error(g+e)}if(s.prototype=I,s.ROUND_UP=0,s.ROUND_DOWN=1,s.ROUND_CEIL=2,s.ROUND_FLOOR=3,s.ROUND_HALF_UP=4,s.ROUND_HALF_DOWN=5,s.ROUND_HALF_EVEN=6,s.ROUND_HALF_CEIL=7,s.ROUND_HALF_FLOOR=8,s.EUCLID=9,s.config=s.set=de,s.clone=e,s.isDecimal=Ee,s.abs=ee,s.acos=te,s.acosh=re,s.add=ne,s.asin=ie,s.asinh=se,s.atan=ae,s.atanh=oe,s.atan2=le,s.cbrt=ce,s.ceil=he,s.clamp=ue,s.cos=pe,s.cosh=me,s.div=ge,s.exp=fe,s.floor=xe,s.hypot=_e,s.ln=Te,s.log=ye,s.log10=Ae,s.log2=Le,s.max=Ce,s.min=Se,s.mod=Ne,s.mul=Me,s.pow=Ie,s.random=Re,s.round=be,s.sign=Oe,s.sin=we,s.sinh=ve,s.sqrt=Fe,s.sub=De,s.sum=Pe,s.tan=ke,s.tanh=Ue,s.trunc=He,void 0===t&&(t={}),t&&!0!==t.defaults)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],r=0;r<i.length;)t.hasOwnProperty(n=i[r++])||(t[n]=this[n]);return s.config(t),s}(d)).prototype.constructor=i,i.default=i.Decimal=i,h=new i(h),u=new i(u),void 0===(n=function(){return i}.call(t,r,t,e))||(e.exports=n)}()},139:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ComplexInterfaceKeyTable=void 0,t.ComplexInterfaceKeyTable=["re","im","type","parent","unparse","copy","toLogical"]},142:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.signFactory=t.roundFactory=t.floorFactory=t.ceilFactory=t.fixFactory=t.remFactory=t.modFactory=t.conjFactory=t.argFactory=t.hypotFactory=t.absFactory=t.absValueFactory=t.rootFactory=t.powerFactory=t.invFactory=t.rdivFactory=t.mulFactory=t.literalFactory=t.notFactory=t.xorFactory=t.orFactory=t.andFactory=t.logicalFactory=t.comparisonFactory=t.minMaxWiseFactory=t.minMaxFactory=t.minMaxArrayComplexWithIndexFactory=t.minMaxArrayComplexFactory=t.minMaxArrayRealWithIndexFactory=t.minMaxArrayRealFactory=t.cmpFactory=t.equalsFactory=t.epsilonFactory=t.copyFactory=t.toMaxPrecisionFactory=t.unparseMathMLFactory=t.precedenceFactory=t.unparseMathMLValueFactory=t.unparseFactory=t.unparseValueFactory=t.parseFactory=t.createFactory=t.setNumberTypeFactory=t.numberClass=t.moduloName=t.roundingName=t.roundingMode=t.ComplexInterfaceStaticKeyTable=t.ComplexInterfaceKeyTable=t.ComplexConfigKeyTable=void 0,t.twoArgFunctionFactory=t.mapFunctionFactory=t.applyFunctionFactory=t.factorialFactory=t.gammaFactory=t.acothFactory=t.asechFactory=t.acschFactory=t.atanhFactory=t.acoshFactory=t.asinhFactory=t.cothFactory=t.sechFactory=t.cschFactory=t.tanhFactory=t.coshFactory=t.sinhFactory=t.acotdFactory=t.acotFactory=t.asecdFactory=t.asecFactory=t.acscdFactory=t.acscFactory=t.atandFactory=t.atanFactory=t.acosdFactory=t.acosFactory=t.asindFactory=t.asinFactory=t.cotdFactory=t.cotFactory=t.secdFactory=t.secFactory=t.cscdFactory=t.cscFactory=t.tandFactory=t.tanFactory=t.cosdFactory=t.cosFactory=t.sindFactory=t.sinFactory=t.rad2degFactory=t.deg2radFactory=t.log10Factory=t.log2Factory=t.logbFactory=t.logFactory=t.expFactory=t.sqrtFactory=void 0;var n=r(34);Object.defineProperty(t,"ComplexConfigKeyTable",{enumerable:!0,get:function(){return n.ComplexConfigKeyTable}});var i=r(139);Object.defineProperty(t,"ComplexInterfaceKeyTable",{enumerable:!0,get:function(){return i.ComplexInterfaceKeyTable}});var s=r(377);Object.defineProperty(t,"ComplexInterfaceStaticKeyTable",{enumerable:!0,get:function(){return s.ComplexInterfaceStaticKeyTable}}),t.roundingMode={ROUND_UP:0,ROUND_DOWN:1,ROUND_CEIL:2,ROUND_FLOOR:3,ROUND_HALF_UP:4,ROUND_HALF_DOWN:5,ROUND_HALF_EVEN:6,ROUND_HALF_CEIL:7,ROUND_HALF_FLOOR:8,EUCLID:9},t.roundingName=["up","down","ceil","floor","half_up","half_down","half_even","half_ceil","half_floor"],t.moduloName=["up","down",void 0,"floor",void 0,void 0,"half_even",void 0,void 0,"euclid"],t.numberClass={LOGICAL:0,REAL:1,COMPLEX:2},t.setNumberTypeFactory=e=>t=>{e.imagIsZero(t)?(e.realIsZero(t)||e.realEquals(t,1))&&t.type===e.LOGICAL||(t.type=e.REAL):t.type=e.COMPLEX},t.createFactory=e=>(t,r,n,i)=>new e(t,r,n,i),t.parseFactory=e=>t=>{const r="0"!==t[0]||"x"!==t[1]&&"X"!==t[1]?t.replace(/[dD]/,"e"):t.replace("_","");return/[ijIJ]$/.test(r)?e.create(0,r.slice(0,-1)):e.create(r,0)},t.unparseValueFactory=(e,t)=>r=>{if(e.isFinite(r)){const n=e.unparse(r).split("e");return 1===n.length?n[0].slice(0,t.settings.toExpPos):n[0].slice(0,t.settings.toExpPos)+"e"+Number(n[1])}return e.isNaN(r)?"NaN":(e.isNeg(r)?"-":"")+"&infin;"},t.unparseFactory=e=>(t,r=0)=>{if(t.type!==e.LOGICAL){const r=e.toMaxPrecision(t);return e.realIsZero(r)||e.imagIsZero(r)?e.realIsZero(r)?e.imagIsZero(r)?e.realIsNegative(r)||e.imagIsNegative(r)?e.realIsNegative(r)&&e.imagIsNegative(r)?"-0":e.realIsNegative(r)&&!e.imagIsNegative(r)?"(-0+0i)":"(0-0i)":"0":(e.imagEquals(r,1)?"":e.imagEquals(r,-1)?"-":e.unparseValue(r.im))+"i":e.unparseValue(r.re):"("+e.unparseValue(r.re)+(e.imagGreaterThan(r,0)?"+":"")+(e.imagEquals(r,1)?"":e.imagEquals(r,-1)?"-":e.unparseValue(r.im))+"i)"}return e.realIsZero(t)?"false":"true"},t.unparseMathMLValueFactory=(e,t)=>r=>{if(e.isFinite(r)){const n=e.unparse(r).split("e");return 1==n.length?"<mn>"+n[0].slice(0,t.settings.toExpPos)+"</mn>":"<mn>"+n[0].slice(0,t.settings.toExpPos)+"</mn><mo>&sdot;</mo><msup><mrow><mn>10</mn></mrow><mrow><mn>"+Number(n[1])+"</mn></mrow></msup>"}return e.isNaN(r)?"<mi><b>NaN</b></mi>":(e.isNeg(r)?"<mo>-</mo>":"")+"<mi>&infin;</mi>"},t.precedenceFactory=e=>(t,r)=>{if(t.type!==e.LOGICAL){const n=e.toMaxPrecision(t);return e.realIsZero(n)||e.imagIsZero(n)?e.realIsZero(n)?e.imagIsZero(n)?e.realIsNegative(n)||e.imagIsNegative(n)?e.realIsNegative(n)&&e.imagIsNegative(n)?r.precedenceTable["-_"]:r.precedenceTable["+"]:r.precedenceTable["()"]:e.imagIsNegative(n)?r.precedenceTable["-_"]:r.precedenceTable["()"]:e.realIsNegative(n)?r.precedenceTable["-_"]:r.precedenceTable["()"]:r.precedenceTable["+"]}return r.precedenceTable["()"]},t.unparseMathMLFactory=e=>(t,r,n=0)=>{if(t.type!==e.LOGICAL){const i=e.toMaxPrecision(t);if(e.realIsZero(i)||e.imagIsZero(i)){if(e.realIsZero(i)){if(e.imagIsZero(i)){if(e.realIsNegative(i)||e.imagIsNegative(i)){if(e.realIsNegative(i)&&e.imagIsNegative(i)){const e="<mn>-0</mn>";return n>r.precedenceTable["-_"]?`<mo fence="true" stretchy="true">(</mo>${e}<mo fence="true" stretchy="true">)</mo>`:e}if(e.realIsNegative(i)&&!e.imagIsNegative(i)){const e="<mn>-0</mn><mo>+</mo><mn>0</mn><mi>i</mi>";return n>r.precedenceTable["+"]?`<mo fence="true" stretchy="true">(</mo>${e}<mo fence="true" stretchy="true">)</mo>`:e}{const e="<mn>0</mn><mo>-</mo><mn>0</mn><mi>i</mi>";return n>r.precedenceTable["+"]?`<mo fence="true" stretchy="true">(</mo>${e}<mo fence="true" stretchy="true">)</mo>`:e}}{const e="<mn>0</mn>";return n>r.precedenceTable["()"]?`<mo fence="true" stretchy="true">(</mo>${e}<mo fence="true" stretchy="true">)</mo>`:e}}{const t=(e.imagEquals(i,1)?"":e.imagEquals(i,-1)?"<mo>-</mo>":e.unparseMathMLValue(i.im))+"<mi>i</mi>";return n>(e.imagIsNegative(i)?r.precedenceTable["-_"]:r.precedenceTable["()"])?`<mo fence="true" stretchy="true">(</mo>${t}<mo fence="true" stretchy="true">)</mo>`:t}}{const t=e.unparseMathMLValue(i.re);return n>(e.realIsNegative(i)?r.precedenceTable["-_"]:r.precedenceTable["()"])?`<mo fence="true" stretchy="true">(</mo>${t}<mo fence="true" stretchy="true">)</mo>`:t}}{const t=e.unparseMathMLValue(i.re)+(e.imagGreaterThan(i,0)?"<mo>+</mo>":"")+(e.imagEquals(i,1)?"":e.imagEquals(i,-1)?"<mo>-</mo>":e.unparseMathMLValue(i.im))+"<mi>i</mi>";return n>r.precedenceTable["+"]?`<mo fence="true" stretchy="true">(</mo>${t}<mo fence="true" stretchy="true">)</mo>`:t}}return e.realIsZero(t)?"<mi>false</mi>":"<mi>true</mi>"},t.toMaxPrecisionFactory=e=>t=>new e(e.toMaxPrecisionValue(t.re),e.toMaxPrecisionValue(t.im)),t.copyFactory=e=>t=>new e(t.re,t.im,t.type),t.epsilonFactory=e=>()=>new e(e.epsilonValue()),t.equalsFactory=(e,t=!0)=>t?(t,r)=>{const n=e.toMaxPrecision(t),i=e.toMaxPrecision(r);return e.realEquals(n,i.re)&&e.imagEquals(n,i.im)?e.true():e.false()}:(t,r)=>{const n=e.toMaxPrecision(t),i=e.toMaxPrecision(r);return e.realEquals(n,i.re)&&e.imagEquals(n,i.im)?e.false():e.true()},t.cmpFactory=e=>(t,r,n)=>{const i=e.toMaxPrecision(r),s=e.toMaxPrecision(n);if(e.imagIsZero(i)&&e.imagIsZero(s))return e.compareValue(t,i.re,s.re)?e.true():e.false();const a=e.toMaxPrecisionValue(e.abs(r).re),o=e.toMaxPrecisionValue(e.abs(n).re);return e.compareValue("eq",a,o)?e.compareValue(t,e.toMaxPrecisionValue(e.arg(r).re),e.toMaxPrecisionValue(e.arg(n).re))?e.true():e.false():e.compareValue(t,a,o)?e.true():e.false()},t.minMaxArrayRealFactory=e=>(t,...r)=>r.reduce((r,n)=>e.compareValue(t,r.re,n.re)?r:n,r[0]),t.minMaxArrayRealWithIndexFactory=e=>(t,...r)=>{let n=0;return[r.reduceRight((r,i,s)=>e.compareValue(t,r.re,i.re)?r:(n=s,i),r[r.length-1]),n]},t.minMaxArrayComplexFactory=e=>(t,...r)=>r.reduce((r,n)=>{const i=e.abs(r).re,s=e.abs(n).re;return e.compareValue("eq",i,s)?e.compareValue(t,e.arg(r).re,e.arg(n).re)?r:n:e.compareValue(t,i,s)?r:n},r[0]),t.minMaxArrayComplexWithIndexFactory=e=>(t,...r)=>{let n=0;return[r.reduceRight((r,i,s)=>{const a=e.abs(r).re,o=e.abs(i).re;return e.compareValue("eq",a,o)?e.compareValue(t,e.arg(r).re,e.arg(i).re)?r:(n=s,i):e.compareValue(t,a,o)?r:(n=s,i)},r[r.length-1]),n]},t.minMaxFactory=(e,t)=>(r,n)=>{if(e.imagIsZero(r)&&e.imagIsZero(n))return e.compareValue(t,r.re,n.re)?r:n;{const i=e.abs(r).re,s=e.abs(n).re;return e.compareValue("eq",i,s)?e.compareValue(t,e.arg(r).re,e.arg(n).re)?r:n:e.compareValue(t,i,s)?r:n}},t.minMaxWiseFactory=(e,t)=>(r,n)=>{if(r.type<=e.REAL&&r.type<=e.REAL)return e.compareValue(t,r.re,n.re)?r:n;{const i=e.abs(r).re,s=e.abs(n).re;return e.compareValue("eq",i,s)?e.compareValue(t,e.arg(r).re,e.arg(n).re)?r:n:e.compareValue(t,i,s)?r:n}},t.comparisonFactory=(e,t)=>(r,n)=>e.cmp(t,r,n),t.logicalFactory=e=>t=>{const r=e.toMaxPrecision(t);return new e(e.realIsZero(r)&&e.imagIsZero(r)?0:1,0,e.LOGICAL)},t.andFactory=e=>(t,r)=>{const n=e.toMaxPrecision(t),i=e.toMaxPrecision(r);return e.realIsZero(n)&&e.imagIsZero(n)||e.realIsZero(i)&&e.imagIsZero(i)?e.false():e.true()},t.orFactory=e=>(t,r)=>{const n=e.toMaxPrecision(t),i=e.toMaxPrecision(r);return e.realIsZero(n)&&e.imagIsZero(n)&&e.realIsZero(i)&&e.imagIsZero(i)?e.false():e.true()},t.xorFactory=e=>(t,r)=>{const n=e.toMaxPrecision(t),i=e.toMaxPrecision(r);return e.realIsZero(n)&&e.imagIsZero(n)&&(!e.realIsZero(i)||!e.imagIsZero(i))||(!e.realIsZero(n)||!e.imagIsZero(n))&&e.realIsZero(i)&&e.imagIsZero(i)?e.true():e.false()},t.notFactory=e=>t=>{const r=e.toMaxPrecision(t);return e.realIsZero(r)&&e.imagIsZero(r)?e.true():e.false()},t.literalFactory=(e,t,r,n)=>()=>new e(t,r,n),t.mulFactory=(e,t)=>(r,n)=>t.imagIsZero(r)&&t.imagIsZero(n)?new t(e.mul(r.re,n.re),e.ZERO):new t(e.sub(e.mul(r.re,n.re),e.mul(r.im,n.im)),e.add(e.mul(r.re,n.im),e.mul(r.im,n.re))),t.rdivFactory=(e,t)=>(r,n)=>{const i=e.add(e.mul(n.re,n.re),e.mul(n.im,n.im));return e.isFinite(i)?e.isZero(i)?new t(e.mul(r.re,e.INF),t.imagIsZero(r)?e.ZERO:e.mul(r.im,e.INF)):new t(e.div(e.add(e.mul(r.re,n.re),e.mul(r.im,n.im)),i),e.div(e.sub(e.mul(r.im,n.re),e.mul(r.re,n.im)),i)):e.isNaN(i)?(t.realIsFinite(n)||t.realIsNaN(n))&&(t.imagIsFinite(n)||t.imagIsNaN(n))?new t(NaN,0):t.zero():t.realIsFinite(r)&&t.imagIsFinite(r)?t.zero():new t(NaN,0)},t.invFactory=(e,t)=>r=>{const n=e.add(e.mul(r.re,r.re),e.mul(r.im,r.im));return e.isFinite(n)?e.isZero(n)?new t(1/0,0):new t(e.div(r.re,n),e.neg(e.div(r.im,n))):e.isNaN(n)&&(t.realIsFinite(r)||t.realIsNaN(r))&&(t.imagIsFinite(r)||t.imagIsNaN(r))?new t(NaN,0):t.zero()},t.powerFactory=(e,t)=>(r,n)=>{if(t.imagIsZero(r)&&t.imagIsZero(n)&&t.realGreaterThanOrEqualTo(r,0))return new t(e.pow(r.re,n.re),0);{const i=e.atan2(t.imagIsZero(r)?e.ZERO:r.im,t.realIsZero(r)?e.ZERO:r.re),s=e.add(e.mul(r.re,r.re),e.mul(r.im,r.im)),a=e.mul(e.pow(s,e.div(n.re,e.TWO)),e.exp(e.mul(e.mul(e.MINUSONE,n.im),i))),o=e.add(e.mul(n.re,i),e.mul(e.div(n.im,e.TWO),e.ln(s)));return new t(e.mul(a,e.cos(o)),t.imagIsZero(r)&&t.imagIsZero(n)&&(t.realGreaterThanOrEqualTo(n,1)||t.realLessThanOrEqualTo(n,-1))?0:e.mul(a,e.sin(o)))}},t.rootFactory=e=>(t,r)=>e.power(t,e.inv(r)),t.absValueFactory=e=>t=>e.sqrt(e.add(e.mul(t.re,t.re),e.mul(t.im,t.im))),t.absFactory=(e,t)=>r=>t.imagIsZero(r)?new t(e.abs(r.re)):new t(t.absValue(r)),t.hypotFactory=e=>(t,r)=>new e(e.absValue(new e(e.absValue(t),e.absValue(r)))),t.argFactory=(e,t)=>r=>new t(e.atan2(t.imagIsZero(r)?e.ZERO:r.im,r.re),0),t.conjFactory=(e,t)=>r=>new t(r.re,e.neg(r.im)),t.modFactory=(e,t)=>(r,n)=>{if(!t.imagIsZero(r)||!t.imagIsZero(n))throw new Error("mod: not defined for complex numbers");return t.realIsZero(n)?r:new t(e.mod(r.re,n.re))},t.remFactory=(e,t)=>(r,n)=>{if(!t.imagIsZero(r)||!t.imagIsZero(n))throw new Error("rem: not defined for complex numbers");return new t(e.mod(r.re,n.re))},t.fixFactory=(e,t)=>r=>new t(e.trunc(r.re),e.trunc(r.im)),t.ceilFactory=(e,t)=>r=>new t(e.ceil(r.re),e.ceil(r.im)),t.floorFactory=(e,t)=>r=>new t(e.floor(r.re),e.floor(r.im)),t.roundFactory=(e,t)=>r=>new t(e.round(r.re),e.round(r.im)),t.signFactory=(e,t)=>r=>t.realIsZero(r)?t.imagIsZero(r)?t.zero():new t(0,e.div(r.im,t.absValue(r))):t.imagIsZero(r)?new t(e.div(r.re,t.absValue(r)),0):new t(e.div(r.re,t.absValue(r)),e.div(r.im,t.absValue(r))),t.sqrtFactory=(e,t)=>r=>{const n=t.absValue(r),i=e.atan2(t.imagIsZero(r)?e.ZERO:r.im,r.re);return new t(e.mul(e.sqrt(n),e.cos(e.div(i,e.TWO))),e.mul(e.sqrt(n),e.sin(e.div(i,e.TWO))))},t.expFactory=(e,t)=>r=>new t(e.mul(e.exp(r.re),e.cos(r.im)),e.mul(e.exp(r.re),e.sin(r.im))),t.logFactory=(e,t)=>r=>new t(e.ln(t.absValue(r)),e.atan2(t.imagIsZero(r)?e.ZERO:r.im,r.re)),t.logbFactory=(e,t)=>(r,n)=>{const i=t.absValue(r);if(e.isZero(i))return t.zero();{const s=e.atan2(t.imagIsZero(r)?e.ZERO:r.im,r.re),a=t.absValue(n),o=e.atan2(t.imagIsZero(n)?e.ZERO:n.im,n.re),l=e.add(e.mul(e.ln(i),e.ln(i)),e.mul(s,s));return new t(e.div(e.add(e.mul(e.ln(a),e.ln(i)),e.mul(o,s)),l),e.div(e.sub(e.mul(o,e.ln(i)),e.mul(e.ln(a),s)),l))}},t.log2Factory=e=>t=>e.logb(new e(2),t),t.log10Factory=e=>t=>e.logb(new e(10),t),t.deg2radFactory=(e,t)=>r=>new t(e.mul(e.div(e.PI,e.PI_DEG),r.re),e.mul(e.div(e.PI,e.PI_DEG),r.im)),t.rad2degFactory=(e,t)=>r=>new t(e.mul(e.div(e.PI_DEG,e.PI),r.re),e.mul(e.div(e.PI_DEG,e.PI),r.im)),t.sinFactory=(e,t)=>r=>new t(e.mul(e.sin(r.re),e.cosh(r.im)),e.mul(e.cos(r.re),e.sinh(r.im))),t.sindFactory=e=>t=>e.sin(e.deg2rad(t)),t.cosFactory=(e,t)=>r=>new t(e.mul(e.cos(r.re),e.cosh(r.im)),e.mul(e.sin(r.re),e.neg(e.sinh(r.im)))),t.cosdFactory=e=>t=>e.cos(e.deg2rad(t)),t.tanFactory=e=>t=>e.rdiv(e.sin(t),e.cos(t)),t.tandFactory=e=>t=>e.tan(e.deg2rad