@cortex-js/compute-engine 0.4.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -5
- package/dist/compute-engine.esm.js +16755 -10484
- package/dist/compute-engine.min.esm.js +2 -7
- package/dist/compute-engine.min.js +2 -7
- package/dist/math-json.esm.js +148 -12472
- package/dist/math-json.min.esm.js +2 -7
- package/dist/math-json.min.js +2 -7
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/signals.d.ts +90 -0
- package/dist/types/compute-engine/assume.d.ts +21 -6
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +107 -0
- package/dist/types/compute-engine/boxed-expression/box.d.ts +56 -0
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +39 -0
- package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +8 -0
- package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +2 -0
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +95 -0
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +83 -0
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +21 -0
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +23 -0
- package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +98 -0
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +74 -0
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +12 -0
- package/dist/types/compute-engine/boxed-expression/order.d.ts +53 -0
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +15 -0
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +37 -0
- package/dist/types/compute-engine/compute-engine.d.ts +284 -99
- package/dist/types/compute-engine/cost-function.d.ts +3 -0
- package/dist/types/compute-engine/dictionary/arithmetic-add.d.ts +11 -0
- package/dist/types/compute-engine/dictionary/arithmetic-divide.d.ts +9 -0
- package/dist/types/compute-engine/dictionary/arithmetic-multiply.d.ts +17 -0
- package/dist/types/compute-engine/dictionary/arithmetic-power.d.ts +9 -0
- package/dist/types/compute-engine/dictionary/arithmetic.d.ts +2 -12
- package/dist/types/compute-engine/dictionary/collections.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/core.d.ts +2 -2
- package/dist/types/compute-engine/dictionary/dictionary.d.ts +18 -11
- package/dist/types/compute-engine/dictionary/logic.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/polynomials.d.ts +2 -0
- package/dist/types/compute-engine/dictionary/relational-operator.d.ts +2 -0
- package/dist/types/compute-engine/dictionary/sets.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/trigonometry.d.ts +2 -2
- package/dist/types/compute-engine/domain-utils.d.ts +30 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +4 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +57 -0
- package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +23 -0
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +198 -0
- package/dist/types/compute-engine/latex-syntax/public.d.ts +576 -0
- package/dist/types/{common → compute-engine/latex-syntax}/serialize-number.d.ts +4 -5
- package/dist/types/{latex-syntax → compute-engine/latex-syntax}/serializer-style.d.ts +2 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +41 -0
- package/dist/types/{latex-syntax/core → compute-engine/latex-syntax}/tokenizer.d.ts +2 -2
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +3 -0
- package/dist/types/compute-engine/numerics/numeric-decimal.d.ts +12 -0
- package/dist/types/compute-engine/numerics/numeric.d.ts +35 -0
- package/dist/types/compute-engine/numerics/primes.d.ts +2 -0
- package/dist/types/compute-engine/public.d.ts +1416 -447
- package/dist/types/compute-engine/rules.d.ts +16 -6
- package/dist/types/compute-engine/simplify-rules.d.ts +17 -0
- package/dist/types/compute-engine/symbolic/expand.d.ts +11 -0
- package/dist/types/compute-engine/symbolic/flatten.d.ts +7 -0
- package/dist/types/compute-engine/symbolic/negate.d.ts +12 -0
- package/dist/types/compute-engine/symbolic/polynomials.d.ts +52 -0
- package/dist/types/compute-engine/symbolic/product.d.ts +45 -0
- package/dist/types/compute-engine/symbolic/sum.d.ts +25 -0
- package/dist/types/compute-engine/symbolic/utils.d.ts +47 -0
- package/dist/types/compute-engine.d.ts +3 -5
- package/dist/types/math-json/math-json-format.d.ts +101 -0
- package/dist/types/math-json/utils.d.ts +97 -0
- package/dist/types/math-json.d.ts +4 -3
- package/package.json +29 -28
- package/dist/compute-engine.js +0 -17296
- package/dist/cortex.esm.js +0 -20989
- package/dist/cortex.js +0 -21011
- package/dist/cortex.min.esm.js +0 -7
- package/dist/cortex.min.js +0 -7
- package/dist/math-json.js +0 -12517
- package/dist/types/common/debug.d.ts +0 -28
- package/dist/types/common/utils.d.ts +0 -153
- package/dist/types/compute-engine/canonical-forms.d.ts +0 -74
- package/dist/types/compute-engine/dictionary/domains.d.ts +0 -26
- package/dist/types/compute-engine/dictionary/utils.d.ts +0 -5
- package/dist/types/compute-engine/domains.d.ts +0 -4
- package/dist/types/compute-engine/evaluate.d.ts +0 -13
- package/dist/types/compute-engine/expression-map.d.ts +0 -11
- package/dist/types/compute-engine/internal-compute-engine.d.ts +0 -108
- package/dist/types/compute-engine/numeric-complex.d.ts +0 -2
- package/dist/types/compute-engine/numeric-decimal.d.ts +0 -12
- package/dist/types/compute-engine/numeric.d.ts +0 -21
- package/dist/types/compute-engine/numerical-eval.d.ts +0 -5
- package/dist/types/compute-engine/order.d.ts +0 -18
- package/dist/types/compute-engine/patterns.d.ts +0 -22
- package/dist/types/compute-engine/predicates.d.ts +0 -42
- package/dist/types/compute-engine/simplify.d.ts +0 -6
- package/dist/types/compute-engine/utils.d.ts +0 -15
- package/dist/types/cortex/formatter.d.ts +0 -165
- package/dist/types/cortex/parse-cortex.d.ts +0 -5
- package/dist/types/cortex/reserved-words.d.ts +0 -1
- package/dist/types/cortex/serialize-cortex.d.ts +0 -14
- package/dist/types/cortex.d.ts +0 -8
- package/dist/types/latex-syntax/definitions-algebra.d.ts +0 -2
- package/dist/types/latex-syntax/definitions-arithmetic.d.ts +0 -3
- package/dist/types/latex-syntax/definitions-calculus.d.ts +0 -2
- package/dist/types/latex-syntax/definitions-core.d.ts +0 -3
- package/dist/types/latex-syntax/definitions-inequalities.d.ts +0 -2
- package/dist/types/latex-syntax/definitions-other.d.ts +0 -3
- package/dist/types/latex-syntax/definitions-sets.d.ts +0 -2
- package/dist/types/latex-syntax/definitions-symbols.d.ts +0 -3
- package/dist/types/latex-syntax/definitions-trigonometry.d.ts +0 -3
- package/dist/types/latex-syntax/definitions.d.ts +0 -40
- package/dist/types/latex-syntax/latex-syntax.d.ts +0 -27
- package/dist/types/latex-syntax/parse.d.ts +0 -138
- package/dist/types/latex-syntax/public.d.ts +0 -456
- package/dist/types/latex-syntax/serializer.d.ts +0 -26
- package/dist/types/latex-syntax/utils.d.ts +0 -10
- package/dist/types/point-free-parser/characters.d.ts +0 -25
- package/dist/types/point-free-parser/combinators.d.ts +0 -46
- package/dist/types/point-free-parser/core-combinators.d.ts +0 -78
- package/dist/types/point-free-parser/grammar.d.ts +0 -12
- package/dist/types/point-free-parser/identifier-parsers.d.ts +0 -7
- package/dist/types/point-free-parser/numeric-parsers.d.ts +0 -8
- package/dist/types/point-free-parser/parsers.d.ts +0 -130
- package/dist/types/point-free-parser/string-parsers.d.ts +0 -29
- package/dist/types/point-free-parser/whitespace-parsers.d.ts +0 -17
- package/dist/types/public.d.ts +0 -163
package/dist/math-json.min.js
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((e="undefined"!=typeof globalThis?globalThis:e||self).MathJson={})}(this,(function(e){const i=8205,t=[127462,127487];function r(e){return e===i||65038===e||65039===e||e>=127995&&e<=128e3||e>=129456&&e<=129460||e>=917536&&e<=917632}function n(e){return e>=t[0]&&e<=t[1]}class s{constructor(e){this.obeyspaces=!1,this.s=function(e){if(/^[\u0020-\u00FF]*$/.test(e))return e;const t=[],s=function(e){const i=[];for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);if(r>=55296&&r<=56319){const i=e.charCodeAt(t+1);i>=56320&&i<=57343&&(r=65536+1024*(r-55296)+(i-56320),t++)}i.push(r)}return i}(e);let a=0;for(;a<s.length;){const e=s[a++],o=s[a];if(o===i){const e=a-1;for(a+=2;s[a]===i;)a+=2;t.push(String.fromCodePoint(...s.slice(e,2*a-e+1)))}else if(r(o)){const e=a-1;for(;r(s[a]);)a+=s[a]===i?2:1;t.push(String.fromCodePoint(...s.slice(e,2*a-e-1)))}else n(e)?(a+=1,t.push(String.fromCodePoint(...s.slice(a-2,2)))):t.push(String.fromCodePoint(e))}return t}(e),this.pos=0}end(){return this.pos>=this.s.length}get(){return this.pos<this.s.length?this.s[this.pos++]:""}peek(){return this.s[this.pos]}match(e){let i;return i="string"==typeof this.s?e.exec(this.s.slice(this.pos)):e.exec(this.s.slice(this.pos).join("")),(null==i?void 0:i[0])?(this.pos+=i[0].length,i[0]):null}next(){if(this.end())return null;if(!this.obeyspaces&&this.match(/^[ \f\n\r\t\v\xA0\u2028\u2029]+/))return"<space>";if(this.obeyspaces&&this.match(/^[ \f\n\r\t\v\xA0\u2028\u2029]/))return"<space>";const e=this.get();if("\\"===e){if(!this.end()){let e=this.match(/^[a-zA-Z*]+/);if(e)this.match(/^[ \f\n\r\t\v\xA0\u2028\u2029]*/);else if(e=this.get()," "===e)return"<space>";return"\\"+e}}else{if("{"===e)return"<{>";if("}"===e)return"<}>";if("^"===e){if("^"===this.peek()){this.get();const e=this.match(/^(\^(\^(\^(\^[0-9a-f])?[0-9a-f])?[0-9a-f])?[0-9a-f])?[0-9a-f][0-9a-f]/);if(e)return String.fromCodePoint(parseInt(e.slice(e.lastIndexOf("^")+1),16))}return e}if("#"===e){if(!this.end()){let e=!1;if(/[0-9?]/.test(this.peek())&&(e=!0,this.pos+1<this.s.length)){const i=this.s[this.pos+1];e=/[^0-9A-Za-z]/.test(i)}return e?"#"+this.get():"#"}}else if("$"===e)return"$"===this.peek()?(this.get(),"<$$>"):"<$>"}return e}}function a(e,i){var t,r,n,s;let a=[],l=e.next();if(l)if("\\relax"===l);else if("\\noexpand"===l)l=e.next(),l&&a.push(l);else if("\\obeyspaces"===l)e.obeyspaces=!0;else if("\\space"===l||"~"===l)a.push("<space>");else if("\\bgroup"===l)a.push("<{>");else if("\\egroup"===l)a.push("<}>");else if("\\string"===l)l=e.next(),l&&("\\"===l[0]?Array.from(l).forEach((e=>a.push("\\"===e?"\\backslash":e))):"<{>"===l?a.push("\\{"):"<space>"===l?a.push("~"):"<}>"===l&&a.push("\\}"));else if("\\csname"===l){for(;"<space>"===e.peek();)e.next();let n="",s=!1,u=[];do{if(0===u.length)if(/^#[0-9?]$/.test(e.peek())){const n=e.get().slice(1);u=o(null!==(r=null!==(t=null==i?void 0:i[n])&&void 0!==t?t:null==i?void 0:i["?"])&&void 0!==r?r:"\\placeholder{}",i),l=u[0]}else l=e.next(),u=l?[l]:[];s=0===u.length,s||"\\endcsname"!==l||(s=!0,u.shift()),s||(s="<$>"===l||"<$$>"===l||"<{>"===l||"<}>"===l||!!l&&l.length>1&&"\\"===l[0]),s||(n+=u.shift())}while(!s);n&&a.push("\\"+n),a=a.concat(u)}else if("\\endcsname"===l);else if(l.length>1&&"#"===l[0]){const e=l.slice(1);a=a.concat(o(null!==(s=null!==(n=null==i?void 0:i[e])&&void 0!==n?n:null==i?void 0:i["?"])&&void 0!==s?s:"\\placeholder{}",i))}else a.push(l);return a}function o(e,i){const t=e.toString().split(/\r?\n/);let r="",n="";for(const e of t){r+=n,n=" ";const i=e.match(/((?:\\%)|[^%])*/);null!==i&&(r+=i[0])}const o=new s(r);let l=[];do{l=l.concat(a(o,i))}while(!o.end());return l}function l(e){let i="",t="";for(const r of e)r&&(/[a-zA-Z*]/.test(r[0])&&(t+=i),i=/\\[a-zA-Z]+\*?$/.test(r)?" ":"",t+=r);return t}function u(e){let i=[];if(Array.isArray(e))for(const t of e)Array.isArray(t)?i=[...i,...t]:i.push(t);else i=[e];return l(i.map((e=>{var i;return null!==(i={"<space>":" ","<$$>":"$$","<$>":"$","<{>":"{","<}>":"}"}[e])&&void 0!==i?i:e})))}var c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},h={exports:{}};!function(e){!function(i){var t,r,n,s,a=9e15,o=1e9,l="0123456789abcdef",u="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",c="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",h={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-a,maxE:a,crypto:!1},g=!0,p="[DecimalError] ",f=p+"Invalid argument: ",m=p+"Precision limit exceeded",d=p+"crypto unavailable",v=Math.floor,x=Math.pow,y=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,b=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,w=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,N=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,E=1e7,q=u.length-1,M=c.length-1,S={name:"[object Decimal]"};function A(e){var i,t,r,n=e.length-1,s="",a=e[0];if(n>0){for(s+=a,i=1;i<n;i++)(t=7-(r=e[i]+"").length)&&(s+=R(t)),s+=r;(t=7-(r=(a=e[i])+"").length)&&(s+=R(t))}else if(0===a)return"0";for(;a%10==0;)a/=10;return s+a}function z(e,i,t){if(e!==~~e||e<i||e>t)throw Error(f+e)}function k(e,i,t,r){var n,s,a,o;for(s=e[0];s>=10;s/=10)--i;return--i<0?(i+=7,n=0):(n=Math.ceil((i+1)/7),i%=7),s=x(10,7-i),o=e[n]%s|0,null==r?i<3?(0==i?o=o/100|0:1==i&&(o=o/10|0),a=t<4&&99999==o||t>3&&49999==o||5e4==o||0==o):a=(t<4&&o+1==s||t>3&&o+1==s/2)&&(e[n+1]/s/100|0)==x(10,i-2)-1||(o==s/2||0==o)&&0==(e[n+1]/s/100|0):i<4?(0==i?o=o/1e3|0:1==i?o=o/100|0:2==i&&(o=o/10|0),a=(r||t<4)&&9999==o||!r&&t>3&&4999==o):a=((r||t<4)&&o+1==s||!r&&t>3&&o+1==s/2)&&(e[n+1]/s/1e3|0)==x(10,i-3)-1,a}function I(e,i,t){for(var r,n,s=[0],a=0,o=e.length;a<o;){for(n=s.length;n--;)s[n]*=i;for(s[0]+=l.indexOf(e.charAt(a++)),r=0;r<s.length;r++)s[r]>t-1&&(void 0===s[r+1]&&(s[r+1]=0),s[r+1]+=s[r]/t|0,s[r]%=t)}return s.reverse()}S.absoluteValue=S.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),L(e)},S.ceil=function(){return L(new this.constructor(this),this.e+1,2)},S.comparedTo=S.cmp=function(e){var i,t,r,n,s=this,a=s.d,o=(e=new s.constructor(e)).d,l=s.s,u=e.s;if(!a||!o)return l&&u?l!==u?l:a===o?0:!a^l<0?1:-1:NaN;if(!a[0]||!o[0])return a[0]?l:o[0]?-u:0;if(l!==u)return l;if(s.e!==e.e)return s.e>e.e^l<0?1:-1;for(i=0,t=(r=a.length)<(n=o.length)?r:n;i<t;++i)if(a[i]!==o[i])return a[i]>o[i]^l<0?1:-1;return r===n?0:r>n^l<0?1:-1},S.cosine=S.cos=function(){var e,i,t=this,r=t.constructor;return t.d?t.d[0]?(e=r.precision,i=r.rounding,r.precision=e+Math.max(t.e,t.sd())+7,r.rounding=1,t=function(e,i){var t,r,n=i.d.length;n<32?r=(1/V(4,t=Math.ceil(n/3))).toString():(t=16,r="2.3283064365386962890625e-10"),e.precision+=t,i=W(e,1,i.times(r),new e(1));for(var s=t;s--;){var a=i.times(i);i=a.times(a).minus(a).times(8).plus(1)}return e.precision-=t,i}(r,Q(r,t)),r.precision=e,r.rounding=i,L(2==s||3==s?t.neg():t,e,i,!0)):new r(1):new r(NaN)},S.cubeRoot=S.cbrt=function(){var e,i,t,r,n,s,a,o,l,u,c=this,h=c.constructor;if(!c.isFinite()||c.isZero())return new h(c);for(g=!1,(s=c.s*x(c.s*c,1/3))&&Math.abs(s)!=1/0?r=new h(s.toString()):(t=A(c.d),(s=((e=c.e)-t.length+1)%3)&&(t+=1==s||-2==s?"0":"00"),s=x(t,1/3),e=v((e+1)/3)-(e%3==(e<0?-1:2)),(r=new h(t=s==1/0?"5e"+e:(t=s.toExponential()).slice(0,t.indexOf("e")+1)+e)).s=c.s),a=(e=h.precision)+3;;)if(u=(l=(o=r).times(o).times(o)).plus(c),r=O(u.plus(c).times(o),u.plus(l),a+2,1),A(o.d).slice(0,a)===(t=A(r.d)).slice(0,a)){if("9999"!=(t=t.slice(a-3,a+1))&&(n||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(L(r,e+1,1),i=!r.times(r).times(r).eq(c));break}if(!n&&(L(o,e+1,0),o.times(o).times(o).eq(c))){r=o;break}a+=4,n=1}return g=!0,L(r,e,h.rounding,i)},S.decimalPlaces=S.dp=function(){var e,i=this.d,t=NaN;if(i){if(t=7*((e=i.length-1)-v(this.e/7)),e=i[e])for(;e%10==0;e/=10)t--;t<0&&(t=0)}return t},S.dividedBy=S.div=function(e){return O(this,new this.constructor(e))},S.dividedToIntegerBy=S.divToInt=function(e){var i=this.constructor;return L(O(this,new i(e),0,1,1),i.precision,i.rounding)},S.equals=S.eq=function(e){return 0===this.cmp(e)},S.floor=function(){return L(new this.constructor(this),this.e+1,3)},S.greaterThan=S.gt=function(e){return this.cmp(e)>0},S.greaterThanOrEqualTo=S.gte=function(e){var i=this.cmp(e);return 1==i||0===i},S.hyperbolicCosine=S.cosh=function(){var e,i,t,r,n,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;t=a.precision,r=a.rounding,a.precision=t+Math.max(s.e,s.sd())+4,a.rounding=1,(n=s.d.length)<32?i=(1/V(4,e=Math.ceil(n/3))).toString():(e=16,i="2.3283064365386962890625e-10"),s=W(a,1,s.times(i),new a(1),!0);for(var l,u=e,c=new a(8);u--;)l=s.times(s),s=o.minus(l.times(c.minus(l.times(c))));return L(s,a.precision=t,a.rounding=r,!0)},S.hyperbolicSine=S.sinh=function(){var e,i,t,r,n=this,s=n.constructor;if(!n.isFinite()||n.isZero())return new s(n);if(i=s.precision,t=s.rounding,s.precision=i+Math.max(n.e,n.sd())+4,s.rounding=1,(r=n.d.length)<3)n=W(s,2,n,n,!0);else{e=(e=1.4*Math.sqrt(r))>16?16:0|e,n=W(s,2,n=n.times(1/V(5,e)),n,!0);for(var a,o=new s(5),l=new s(16),u=new s(20);e--;)a=n.times(n),n=n.times(o.plus(a.times(l.times(a).plus(u))))}return s.precision=i,s.rounding=t,L(n,i,t,!0)},S.hyperbolicTangent=S.tanh=function(){var e,i,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(e=r.precision,i=r.rounding,r.precision=e+7,r.rounding=1,O(t.sinh(),t.cosh(),r.precision=e,r.rounding=i)):new r(t.s)},S.inverseCosine=S.acos=function(){var e,i=this,t=i.constructor,r=i.abs().cmp(1),n=t.precision,s=t.rounding;return-1!==r?0===r?i.isNeg()?T(t,n,s):new t(0):new t(NaN):i.isZero()?T(t,n+4,s).times(.5):(t.precision=n+6,t.rounding=1,i=i.asin(),e=T(t,n+4,s).times(.5),t.precision=n,t.rounding=s,e.minus(i))},S.inverseHyperbolicCosine=S.acosh=function(){var e,i,t=this,r=t.constructor;return t.lte(1)?new r(t.eq(1)?0:NaN):t.isFinite()?(e=r.precision,i=r.rounding,r.precision=e+Math.max(Math.abs(t.e),t.sd())+4,r.rounding=1,g=!1,t=t.times(t).minus(1).sqrt().plus(t),g=!0,r.precision=e,r.rounding=i,t.ln()):new r(t)},S.inverseHyperbolicSine=S.asinh=function(){var e,i,t=this,r=t.constructor;return!t.isFinite()||t.isZero()?new r(t):(e=r.precision,i=r.rounding,r.precision=e+2*Math.max(Math.abs(t.e),t.sd())+6,r.rounding=1,g=!1,t=t.times(t).plus(1).sqrt().plus(t),g=!0,r.precision=e,r.rounding=i,t.ln())},S.inverseHyperbolicTangent=S.atanh=function(){var e,i,t,r,n=this,s=n.constructor;return n.isFinite()?n.e>=0?new s(n.abs().eq(1)?n.s/0:n.isZero()?n:NaN):(e=s.precision,i=s.rounding,r=n.sd(),Math.max(r,e)<2*-n.e-1?L(new s(n),e,i,!0):(s.precision=t=r-n.e,n=O(n.plus(1),new s(1).minus(n),t+e,1),s.precision=e+4,s.rounding=1,n=n.ln(),s.precision=e,s.rounding=i,n.times(.5))):new s(NaN)},S.inverseSine=S.asin=function(){var e,i,t,r,n=this,s=n.constructor;return n.isZero()?new s(n):(i=n.abs().cmp(1),t=s.precision,r=s.rounding,-1!==i?0===i?((e=T(s,t+4,r).times(.5)).s=n.s,e):new s(NaN):(s.precision=t+6,s.rounding=1,n=n.div(new s(1).minus(n.times(n)).sqrt().plus(1)).atan(),s.precision=t,s.rounding=r,n.times(2)))},S.inverseTangent=S.atan=function(){var e,i,t,r,n,s,a,o,l,u=this,c=u.constructor,h=c.precision,p=c.rounding;if(u.isFinite()){if(u.isZero())return new c(u);if(u.abs().eq(1)&&h+4<=M)return(a=T(c,h+4,p).times(.25)).s=u.s,a}else{if(!u.s)return new c(NaN);if(h+4<=M)return(a=T(c,h+4,p).times(.5)).s=u.s,a}for(c.precision=o=h+10,c.rounding=1,e=t=Math.min(28,o/7+2|0);e;--e)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(g=!1,i=Math.ceil(o/7),r=1,l=u.times(u),a=new c(u),n=u;-1!==e;)if(n=n.times(l),s=a.minus(n.div(r+=2)),n=n.times(l),void 0!==(a=s.plus(n.div(r+=2))).d[i])for(e=i;a.d[e]===s.d[e]&&e--;);return t&&(a=a.times(2<<t-1)),g=!0,L(a,c.precision=h,c.rounding=p,!0)},S.isFinite=function(){return!!this.d},S.isInteger=S.isInt=function(){return!!this.d&&v(this.e/7)>this.d.length-2},S.isNaN=function(){return!this.s},S.isNegative=S.isNeg=function(){return this.s<0},S.isPositive=S.isPos=function(){return this.s>0},S.isZero=function(){return!!this.d&&0===this.d[0]},S.lessThan=S.lt=function(e){return this.cmp(e)<0},S.lessThanOrEqualTo=S.lte=function(e){return this.cmp(e)<1},S.logarithm=S.log=function(e){var i,t,r,n,s,a,o,l,u=this,c=u.constructor,h=c.precision,p=c.rounding;if(null==e)e=new c(10),i=!0;else{if(t=(e=new c(e)).d,e.s<0||!t||!t[0]||e.eq(1))return new c(NaN);i=e.eq(10)}if(t=u.d,u.s<0||!t||!t[0]||u.eq(1))return new c(t&&!t[0]?-1/0:1!=u.s?NaN:t?0:1/0);if(i)if(t.length>1)s=!0;else{for(n=t[0];n%10==0;)n/=10;s=1!==n}if(g=!1,a=j(u,o=h+5),r=i?F(c,o+10):j(e,o),k((l=O(a,r,o,1)).d,n=h,p))do{if(a=j(u,o+=10),r=i?F(c,o+10):j(e,o),l=O(a,r,o,1),!s){+A(l.d).slice(n+1,n+15)+1==1e14&&(l=L(l,h+1,0));break}}while(k(l.d,n+=10,p));return g=!0,L(l,h,p)},S.minus=S.sub=function(e){var i,t,r,n,s,a,o,l,u,c,h,p,f=this,m=f.constructor;if(e=new m(e),!f.d||!e.d)return f.s&&e.s?f.d?e.s=-e.s:e=new m(e.d||f.s!==e.s?f:NaN):e=new m(NaN),e;if(f.s!=e.s)return e.s=-e.s,f.plus(e);if(u=f.d,p=e.d,o=m.precision,l=m.rounding,!u[0]||!p[0]){if(p[0])e.s=-e.s;else{if(!u[0])return new m(3===l?-0:0);e=new m(f)}return g?L(e,o,l):e}if(t=v(e.e/7),c=v(f.e/7),u=u.slice(),s=c-t){for((h=s<0)?(i=u,s=-s,a=p.length):(i=p,t=c,a=u.length),s>(r=Math.max(Math.ceil(o/7),a)+2)&&(s=r,i.length=1),i.reverse(),r=s;r--;)i.push(0);i.reverse()}else{for((h=(r=u.length)<(a=p.length))&&(a=r),r=0;r<a;r++)if(u[r]!=p[r]){h=u[r]<p[r];break}s=0}for(h&&(i=u,u=p,p=i,e.s=-e.s),a=u.length,r=p.length-a;r>0;--r)u[a++]=0;for(r=p.length;r>s;){if(u[--r]<p[r]){for(n=r;n&&0===u[--n];)u[n]=E-1;--u[n],u[r]+=E}u[r]-=p[r]}for(;0===u[--a];)u.pop();for(;0===u[0];u.shift())--t;return u[0]?(e.d=u,e.e=P(u,t),g?L(e,o,l):e):new m(3===l?-0:0)},S.modulo=S.mod=function(e){var i,t=this,r=t.constructor;return e=new r(e),!t.d||!e.s||e.d&&!e.d[0]?new r(NaN):!e.d||t.d&&!t.d[0]?L(new r(t),r.precision,r.rounding):(g=!1,9==r.modulo?(i=O(t,e.abs(),0,3,1)).s*=e.s:i=O(t,e,0,r.modulo,1),i=i.times(e),g=!0,t.minus(i))},S.naturalExponential=S.exp=function(){return _(this)},S.naturalLogarithm=S.ln=function(){return j(this)},S.negated=S.neg=function(){var e=new this.constructor(this);return e.s=-e.s,L(e)},S.plus=S.add=function(e){var i,t,r,n,s,a,o,l,u,c,h=this,p=h.constructor;if(e=new p(e),!h.d||!e.d)return h.s&&e.s?h.d||(e=new p(e.d||h.s===e.s?h:NaN)):e=new p(NaN),e;if(h.s!=e.s)return e.s=-e.s,h.minus(e);if(u=h.d,c=e.d,o=p.precision,l=p.rounding,!u[0]||!c[0])return c[0]||(e=new p(h)),g?L(e,o,l):e;if(s=v(h.e/7),r=v(e.e/7),u=u.slice(),n=s-r){for(n<0?(t=u,n=-n,a=c.length):(t=c,r=s,a=u.length),n>(a=(s=Math.ceil(o/7))>a?s+1:a+1)&&(n=a,t.length=1),t.reverse();n--;)t.push(0);t.reverse()}for((a=u.length)-(n=c.length)<0&&(n=a,t=c,c=u,u=t),i=0;n;)i=(u[--n]=u[n]+c[n]+i)/E|0,u[n]%=E;for(i&&(u.unshift(i),++r),a=u.length;0==u[--a];)u.pop();return e.d=u,e.e=P(u,r),g?L(e,o,l):e},S.precision=S.sd=function(e){var i,t=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(f+e);return t.d?(i=C(t.d),e&&t.e+1>i&&(i=t.e+1)):i=NaN,i},S.round=function(){var e=this,i=e.constructor;return L(new i(e),e.e+1,i.rounding)},S.sine=S.sin=function(){var e,i,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(e=r.precision,i=r.rounding,r.precision=e+Math.max(t.e,t.sd())+7,r.rounding=1,t=function(e,i){var t,r=i.d.length;if(r<3)return W(e,2,i,i);t=(t=1.4*Math.sqrt(r))>16?16:0|t,i=W(e,2,i=i.times(1/V(5,t)),i);for(var n,s=new e(5),a=new e(16),o=new e(20);t--;)n=i.times(i),i=i.times(s.plus(n.times(a.times(n).minus(o))));return i}(r,Q(r,t)),r.precision=e,r.rounding=i,L(s>2?t.neg():t,e,i,!0)):new r(NaN)},S.squareRoot=S.sqrt=function(){var e,i,t,r,n,s,a=this,o=a.d,l=a.e,u=a.s,c=a.constructor;if(1!==u||!o||!o[0])return new c(!u||u<0&&(!o||o[0])?NaN:o?a:1/0);for(g=!1,0==(u=Math.sqrt(+a))||u==1/0?(((i=A(o)).length+l)%2==0&&(i+="0"),u=Math.sqrt(i),l=v((l+1)/2)-(l<0||l%2),r=new c(i=u==1/0?"5e"+l:(i=u.toExponential()).slice(0,i.indexOf("e")+1)+l)):r=new c(u.toString()),t=(l=c.precision)+3;;)if(r=(s=r).plus(O(a,s,t+2,1)).times(.5),A(s.d).slice(0,t)===(i=A(r.d)).slice(0,t)){if("9999"!=(i=i.slice(t-3,t+1))&&(n||"4999"!=i)){+i&&(+i.slice(1)||"5"!=i.charAt(0))||(L(r,l+1,1),e=!r.times(r).eq(a));break}if(!n&&(L(s,l+1,0),s.times(s).eq(a))){r=s;break}t+=4,n=1}return g=!0,L(r,l,c.rounding,e)},S.tangent=S.tan=function(){var e,i,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(e=r.precision,i=r.rounding,r.precision=e+10,r.rounding=1,(t=t.sin()).s=1,t=O(t,new r(1).minus(t.times(t)).sqrt(),e+10,0),r.precision=e,r.rounding=i,L(2==s||4==s?t.neg():t,e,i,!0)):new r(NaN)},S.times=S.mul=function(e){var i,t,r,n,s,a,o,l,u,c=this,h=c.constructor,p=c.d,f=(e=new h(e)).d;if(e.s*=c.s,!(p&&p[0]&&f&&f[0]))return new h(!e.s||p&&!p[0]&&!f||f&&!f[0]&&!p?NaN:p&&f?0*e.s:e.s/0);for(t=v(c.e/7)+v(e.e/7),(l=p.length)<(u=f.length)&&(s=p,p=f,f=s,a=l,l=u,u=a),s=[],r=a=l+u;r--;)s.push(0);for(r=u;--r>=0;){for(i=0,n=l+r;n>r;)o=s[n]+f[r]*p[n-r-1]+i,s[n--]=o%E|0,i=o/E|0;s[n]=(s[n]+i)%E|0}for(;!s[--a];)s.pop();return i?++t:s.shift(),e.d=s,e.e=P(s,t),g?L(e,h.precision,h.rounding):e},S.toBinary=function(e,i){return Y(this,2,e,i)},S.toDecimalPlaces=S.toDP=function(e,i){var t=this,r=t.constructor;return t=new r(t),void 0===e?t:(z(e,0,o),void 0===i?i=r.rounding:z(i,0,8),L(t,e+t.e+1,i))},S.toExponential=function(e,i){var t,r=this,n=r.constructor;return void 0===e?t=D(r,!0):(z(e,0,o),void 0===i?i=n.rounding:z(i,0,8),t=D(r=L(new n(r),e+1,i),!0,e+1)),r.isNeg()&&!r.isZero()?"-"+t:t},S.toFixed=function(e,i){var t,r,n=this,s=n.constructor;return void 0===e?t=D(n):(z(e,0,o),void 0===i?i=s.rounding:z(i,0,8),t=D(r=L(new s(n),e+n.e+1,i),!1,e+r.e+1)),n.isNeg()&&!n.isZero()?"-"+t:t},S.toFraction=function(e){var i,t,r,n,s,a,o,l,u,c,h,p,m=this,d=m.d,v=m.constructor;if(!d)return new v(m);if(u=t=new v(1),r=l=new v(0),a=(s=(i=new v(r)).e=C(d)-m.e-1)%7,i.d[0]=x(10,a<0?7+a:a),null==e)e=s>0?i:u;else{if(!(o=new v(e)).isInt()||o.lt(u))throw Error(f+o);e=o.gt(i)?s>0?i:u:o}for(g=!1,o=new v(A(d)),c=v.precision,v.precision=s=7*d.length*2;h=O(o,i,0,1,1),1!=(n=t.plus(h.times(r))).cmp(e);)t=r,r=n,n=u,u=l.plus(h.times(n)),l=n,n=i,i=o.minus(h.times(n)),o=n;return n=O(e.minus(t),r,0,1,1),l=l.plus(n.times(u)),t=t.plus(n.times(r)),l.s=u.s=m.s,p=O(u,r,s,1).minus(m).abs().cmp(O(l,t,s,1).minus(m).abs())<1?[u,r]:[l,t],v.precision=c,g=!0,p},S.toHexadecimal=S.toHex=function(e,i){return Y(this,16,e,i)},S.toNearest=function(e,i){var t=this,r=t.constructor;if(t=new r(t),null==e){if(!t.d)return t;e=new r(1),i=r.rounding}else{if(e=new r(e),void 0===i?i=r.rounding:z(i,0,8),!t.d)return e.s?t:e;if(!e.d)return e.s&&(e.s=t.s),e}return e.d[0]?(g=!1,t=O(t,e,0,i,1).times(e),g=!0,L(t)):(e.s=t.s,t=e),t},S.toNumber=function(){return+this},S.toOctal=function(e,i){return Y(this,8,e,i)},S.toPower=S.pow=function(e){var i,t,r,n,s,a,o=this,l=o.constructor,u=+(e=new l(e));if(!(o.d&&e.d&&o.d[0]&&e.d[0]))return new l(x(+o,u));if((o=new l(o)).eq(1))return o;if(r=l.precision,s=l.rounding,e.eq(1))return L(o,r,s);if((i=v(e.e/7))>=e.d.length-1&&(t=u<0?-u:u)<=9007199254740991)return n=$(l,o,t,r),e.s<0?new l(1).div(n):L(n,r,s);if((a=o.s)<0){if(i<e.d.length-1)return new l(NaN);if(0==(1&e.d[i])&&(a=1),0==o.e&&1==o.d[0]&&1==o.d.length)return o.s=a,o}return(i=0!=(t=x(+o,u))&&isFinite(t)?new l(t+"").e:v(u*(Math.log("0."+A(o.d))/Math.LN10+o.e+1)))>l.maxE+1||i<l.minE-1?new l(i>0?a/0:0):(g=!1,l.rounding=o.s=1,t=Math.min(12,(i+"").length),(n=_(e.times(j(o,r+t)),r)).d&&k((n=L(n,r+5,1)).d,r,s)&&(i=r+10,+A((n=L(_(e.times(j(o,i+t)),i),i+5,1)).d).slice(r+1,r+15)+1==1e14&&(n=L(n,r+1,0))),n.s=a,g=!0,l.rounding=s,L(n,r,s))},S.toPrecision=function(e,i){var t,r=this,n=r.constructor;return void 0===e?t=D(r,r.e<=n.toExpNeg||r.e>=n.toExpPos):(z(e,1,o),void 0===i?i=n.rounding:z(i,0,8),t=D(r=L(new n(r),e,i),e<=r.e||r.e<=n.toExpNeg,e)),r.isNeg()&&!r.isZero()?"-"+t:t},S.toSignificantDigits=S.toSD=function(e,i){var t=this.constructor;return void 0===e?(e=t.precision,i=t.rounding):(z(e,1,o),void 0===i?i=t.rounding:z(i,0,8)),L(new t(this),e,i)},S.toString=function(){var e=this,i=e.constructor,t=D(e,e.e<=i.toExpNeg||e.e>=i.toExpPos);return e.isNeg()&&!e.isZero()?"-"+t:t},S.truncated=S.trunc=function(){return L(new this.constructor(this),this.e+1,1)},S.valueOf=S.toJSON=function(){var e=this,i=e.constructor,t=D(e,e.e<=i.toExpNeg||e.e>=i.toExpPos);return e.isNeg()?"-"+t:t};var O=function(){function e(e,i,t){var r,n=0,s=e.length;for(e=e.slice();s--;)r=e[s]*i+n,e[s]=r%t|0,n=r/t|0;return n&&e.unshift(n),e}function i(e,i,t,r){var n,s;if(t!=r)s=t>r?1:-1;else for(n=s=0;n<t;n++)if(e[n]!=i[n]){s=e[n]>i[n]?1:-1;break}return s}function t(e,i,t,r){for(var n=0;t--;)e[t]-=n,n=e[t]<i[t]?1:0,e[t]=n*r+e[t]-i[t];for(;!e[0]&&e.length>1;)e.shift()}return function(n,s,a,o,l,u){var c,h,g,p,f,m,d,x,y,b,w,N,q,M,S,A,z,k,I,O,D=n.constructor,P=n.s==s.s?1:-1,F=n.d,T=s.d;if(!(F&&F[0]&&T&&T[0]))return new D(n.s&&s.s&&(F?!T||F[0]!=T[0]:T)?F&&0==F[0]||!T?0*P:P/0:NaN);for(u?(f=1,h=n.e-s.e):(u=E,f=7,h=v(n.e/f)-v(s.e/f)),I=T.length,z=F.length,b=(y=new D(P)).d=[],g=0;T[g]==(F[g]||0);g++);if(T[g]>(F[g]||0)&&h--,null==a?(M=a=D.precision,o=D.rounding):M=l?a+(n.e-s.e)+1:a,M<0)b.push(1),m=!0;else{if(M=M/f+2|0,g=0,1==I){for(p=0,T=T[0],M++;(g<z||p)&&M--;g++)S=p*u+(F[g]||0),b[g]=S/T|0,p=S%T|0;m=p||g<z}else{for((p=u/(T[0]+1)|0)>1&&(T=e(T,p,u),F=e(F,p,u),I=T.length,z=F.length),A=I,N=(w=F.slice(0,I)).length;N<I;)w[N++]=0;(O=T.slice()).unshift(0),k=T[0],T[1]>=u/2&&++k;do{p=0,(c=i(T,w,I,N))<0?(q=w[0],I!=N&&(q=q*u+(w[1]||0)),(p=q/k|0)>1?(p>=u&&(p=u-1),1==(c=i(d=e(T,p,u),w,x=d.length,N=w.length))&&(p--,t(d,I<x?O:T,x,u))):(0==p&&(c=p=1),d=T.slice()),(x=d.length)<N&&d.unshift(0),t(w,d,N,u),-1==c&&(c=i(T,w,I,N=w.length))<1&&(p++,t(w,I<N?O:T,N,u)),N=w.length):0===c&&(p++,w=[0]),b[g++]=p,c&&w[0]?w[N++]=F[A]||0:(w=[F[A]],N=1)}while((A++<z||void 0!==w[0])&&M--);m=void 0!==w[0]}b[0]||b.shift()}if(1==f)y.e=h,r=m;else{for(g=1,p=b[0];p>=10;p/=10)g++;y.e=g+h*f-1,L(y,l?a+y.e+1:a,o,m)}return y}}();function L(e,i,t,r){var n,s,a,o,l,u,c,h,p,f=e.constructor;e:if(null!=i){if(!(h=e.d))return e;for(n=1,o=h[0];o>=10;o/=10)n++;if((s=i-n)<0)s+=7,a=i,l=(c=h[p=0])/x(10,n-a-1)%10|0;else if((p=Math.ceil((s+1)/7))>=(o=h.length)){if(!r)break e;for(;o++<=p;)h.push(0);c=l=0,n=1,a=(s%=7)-7+1}else{for(c=o=h[p],n=1;o>=10;o/=10)n++;l=(a=(s%=7)-7+n)<0?0:c/x(10,n-a-1)%10|0}if(r=r||i<0||void 0!==h[p+1]||(a<0?c:c%x(10,n-a-1)),u=t<4?(l||r)&&(0==t||t==(e.s<0?3:2)):l>5||5==l&&(4==t||r||6==t&&(s>0?a>0?c/x(10,n-a):0:h[p-1])%10&1||t==(e.s<0?8:7)),i<1||!h[0])return h.length=0,u?(i-=e.e+1,h[0]=x(10,(7-i%7)%7),e.e=-i||0):h[0]=e.e=0,e;if(0==s?(h.length=p,o=1,p--):(h.length=p+1,o=x(10,7-s),h[p]=a>0?(c/x(10,n-a)%x(10,a)|0)*o:0),u)for(;;){if(0==p){for(s=1,a=h[0];a>=10;a/=10)s++;for(a=h[0]+=o,o=1;a>=10;a/=10)o++;s!=o&&(e.e++,h[0]==E&&(h[0]=1));break}if(h[p]+=o,h[p]!=E)break;h[p--]=0,o=1}for(s=h.length;0===h[--s];)h.pop()}return g&&(e.e>f.maxE?(e.d=null,e.e=NaN):e.e<f.minE&&(e.e=0,e.d=[0])),e}function D(e,i,t){if(!e.isFinite())return U(e);var r,n=e.e,s=A(e.d),a=s.length;return i?(t&&(r=t-a)>0?s=s.charAt(0)+"."+s.slice(1)+R(r):a>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(e.e<0?"e":"e+")+e.e):n<0?(s="0."+R(-n-1)+s,t&&(r=t-a)>0&&(s+=R(r))):n>=a?(s+=R(n+1-a),t&&(r=t-n-1)>0&&(s=s+"."+R(r))):((r=n+1)<a&&(s=s.slice(0,r)+"."+s.slice(r)),t&&(r=t-a)>0&&(n+1===a&&(s+="."),s+=R(r))),s}function P(e,i){var t=e[0];for(i*=7;t>=10;t/=10)i++;return i}function F(e,i,t){if(i>q)throw g=!0,t&&(e.precision=t),Error(m);return L(new e(u),i,1,!0)}function T(e,i,t){if(i>M)throw Error(m);return L(new e(c),i,t,!0)}function C(e){var i=e.length-1,t=7*i+1;if(i=e[i]){for(;i%10==0;i/=10)t--;for(i=e[0];i>=10;i/=10)t++}return t}function R(e){for(var i="";e--;)i+="0";return i}function $(e,i,t,r){var n,s=new e(1),a=Math.ceil(r/7+4);for(g=!1;;){if(t%2&&J((s=s.times(i)).d,a)&&(n=!0),0===(t=v(t/2))){t=s.d.length-1,n&&0===s.d[t]&&++s.d[t];break}J((i=i.times(i)).d,a)}return g=!0,s}function Z(e){return 1&e.d[e.d.length-1]}function B(e,i,t){for(var r,n=new e(i[0]),s=0;++s<i.length;){if(!(r=new e(i[s])).s){n=r;break}n[t](r)&&(n=r)}return n}function _(e,i){var t,r,n,s,a,o,l,u=0,c=0,h=0,p=e.constructor,f=p.rounding,m=p.precision;if(!e.d||!e.d[0]||e.e>17)return new p(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(null==i?(g=!1,l=m):l=i,o=new p(.03125);e.e>-2;)e=e.times(o),h+=5;for(l+=r=Math.log(x(2,h))/Math.LN10*2+5|0,t=s=a=new p(1),p.precision=l;;){if(s=L(s.times(e),l,1),t=t.times(++c),A((o=a.plus(O(s,t,l,1))).d).slice(0,l)===A(a.d).slice(0,l)){for(n=h;n--;)a=L(a.times(a),l,1);if(null!=i)return p.precision=m,a;if(!(u<3&&k(a.d,l-r,f,u)))return L(a,p.precision=m,f,g=!0);p.precision=l+=10,t=s=o=new p(1),c=0,u++}a=o}}function j(e,i){var t,r,n,s,a,o,l,u,c,h,p,f=1,m=e,d=m.d,v=m.constructor,x=v.rounding,y=v.precision;if(m.s<0||!d||!d[0]||!m.e&&1==d[0]&&1==d.length)return new v(d&&!d[0]?-1/0:1!=m.s?NaN:d?0:m);if(null==i?(g=!1,c=y):c=i,v.precision=c+=10,r=(t=A(d)).charAt(0),!(Math.abs(s=m.e)<15e14))return u=F(v,c+2,y).times(s+""),m=j(new v(r+"."+t.slice(1)),c-10).plus(u),v.precision=y,null==i?L(m,y,x,g=!0):m;for(;r<7&&1!=r||1==r&&t.charAt(1)>3;)r=(t=A((m=m.times(e)).d)).charAt(0),f++;for(s=m.e,r>1?(m=new v("0."+t),s++):m=new v(r+"."+t.slice(1)),h=m,l=a=m=O(m.minus(1),m.plus(1),c,1),p=L(m.times(m),c,1),n=3;;){if(a=L(a.times(p),c,1),A((u=l.plus(O(a,new v(n),c,1))).d).slice(0,c)===A(l.d).slice(0,c)){if(l=l.times(2),0!==s&&(l=l.plus(F(v,c+2,y).times(s+""))),l=O(l,new v(f),c,1),null!=i)return v.precision=y,l;if(!k(l.d,c-10,x,o))return L(l,v.precision=y,x,g=!0);v.precision=c+=10,u=a=m=O(h.minus(1),h.plus(1),c,1),p=L(m.times(m),c,1),n=o=1}l=u,n+=2}}function U(e){return String(e.s*e.s/0)}function H(e,i){var t,r,n;for((t=i.indexOf("."))>-1&&(i=i.replace(".","")),(r=i.search(/e/i))>0?(t<0&&(t=r),t+=+i.slice(r+1),i=i.substring(0,r)):t<0&&(t=i.length),r=0;48===i.charCodeAt(r);r++);for(n=i.length;48===i.charCodeAt(n-1);--n);if(i=i.slice(r,n)){if(n-=r,e.e=t=t-r-1,e.d=[],r=(t+1)%7,t<0&&(r+=7),r<n){for(r&&e.d.push(+i.slice(0,r)),n-=7;r<n;)e.d.push(+i.slice(r,r+=7));r=7-(i=i.slice(r)).length}else r-=n;for(;r--;)i+="0";e.d.push(+i),g&&(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 G(e,i){var r,n,s,a,o,l,u,c,h;if("Infinity"===i||"NaN"===i)return+i||(e.s=NaN),e.e=NaN,e.d=null,e;if(b.test(i))r=16,i=i.toLowerCase();else if(y.test(i))r=2;else{if(!w.test(i))throw Error(f+i);r=8}for((a=i.search(/p/i))>0?(u=+i.slice(a+1),i=i.substring(2,a)):i=i.slice(2),o=(a=i.indexOf("."))>=0,n=e.constructor,o&&(a=(l=(i=i.replace(".","")).length)-a,s=$(n,new n(r),a,2*a)),a=h=(c=I(i,r,E)).length-1;0===c[a];--a)c.pop();return a<0?new n(0*e.s):(e.e=P(c,h),e.d=c,g=!1,o&&(e=O(e,s,4*l)),u&&(e=e.times(Math.abs(u)<54?x(2,u):t.pow(2,u))),g=!0,e)}function W(e,i,t,r,n){var s,a,o,l,u=e.precision,c=Math.ceil(u/7);for(g=!1,l=t.times(t),o=new e(r);;){if(a=O(o.times(l),new e(i++*i++),u,1),o=n?r.plus(a):r.minus(a),r=O(a.times(l),new e(i++*i++),u,1),void 0!==(a=o.plus(r)).d[c]){for(s=c;a.d[s]===o.d[s]&&s--;);if(-1==s)break}s=o,o=r,r=a,a=s}return g=!0,a.d.length=c+1,a}function V(e,i){for(var t=e;--i;)t*=e;return t}function Q(e,i){var t,r=i.s<0,n=T(e,e.precision,1),a=n.times(.5);if((i=i.abs()).lte(a))return s=r?4:1,i;if((t=i.divToInt(n)).isZero())s=r?3:2;else{if((i=i.minus(t.times(n))).lte(a))return s=Z(t)?r?2:3:r?4:1,i;s=Z(t)?r?1:4:r?3:2}return i.minus(n).abs()}function Y(e,i,t,n){var s,a,u,c,h,g,p,f,m,d=e.constructor,v=void 0!==t;if(v?(z(t,1,o),void 0===n?n=d.rounding:z(n,0,8)):(t=d.precision,n=d.rounding),e.isFinite()){for(v?(s=2,16==i?t=4*t-3:8==i&&(t=3*t-2)):s=i,(u=(p=D(e)).indexOf("."))>=0&&(p=p.replace(".",""),(m=new d(1)).e=p.length-u,m.d=I(D(m),10,s),m.e=m.d.length),a=h=(f=I(p,10,s)).length;0==f[--h];)f.pop();if(f[0]){if(u<0?a--:((e=new d(e)).d=f,e.e=a,f=(e=O(e,m,t,n,0,s)).d,a=e.e,g=r),u=f[t],c=s/2,g=g||void 0!==f[t+1],g=n<4?(void 0!==u||g)&&(0===n||n===(e.s<0?3:2)):u>c||u===c&&(4===n||g||6===n&&1&f[t-1]||n===(e.s<0?8:7)),f.length=t,g)for(;++f[--t]>s-1;)f[t]=0,t||(++a,f.unshift(1));for(h=f.length;!f[h-1];--h);for(u=0,p="";u<h;u++)p+=l.charAt(f[u]);if(v){if(h>1)if(16==i||8==i){for(u=16==i?4:3,--h;h%u;h++)p+="0";for(h=(f=I(p,s,i)).length;!f[h-1];--h);for(u=1,p="1.";u<h;u++)p+=l.charAt(f[u])}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>h)for(a-=h;a--;)p+="0";else a<h&&(p=p.slice(0,a)+"."+p.slice(a))}else p=v?"0p+0":"0";p=(16==i?"0x":2==i?"0b":8==i?"0o":"")+p}else p=U(e);return e.s<0?"-"+p:p}function J(e,i){if(e.length>i)return e.length=i,!0}function K(e){return new this(e).abs()}function X(e){return new this(e).acos()}function ee(e){return new this(e).acosh()}function ie(e,i){return new this(e).plus(i)}function te(e){return new this(e).asin()}function re(e){return new this(e).asinh()}function ne(e){return new this(e).atan()}function se(e){return new this(e).atanh()}function ae(e,i){e=new this(e),i=new this(i);var t,r=this.precision,n=this.rounding,s=r+4;return e.s&&i.s?e.d||i.d?!i.d||e.isZero()?(t=i.s<0?T(this,r,n):new this(0)).s=e.s:!e.d||i.isZero()?(t=T(this,s,1).times(.5)).s=e.s:i.s<0?(this.precision=s,this.rounding=1,t=this.atan(O(e,i,s,1)),i=T(this,s,1),this.precision=r,this.rounding=n,t=e.s<0?t.minus(i):t.plus(i)):t=this.atan(O(e,i,s,1)):(t=T(this,s,1).times(i.s>0?.25:.75)).s=e.s:t=new this(NaN),t}function oe(e){return new this(e).cbrt()}function le(e){return L(e=new this(e),e.e+1,2)}function ue(e){if(!e||"object"!=typeof e)throw Error(p+"Object expected");var i,t,r,n=!0===e.defaults,s=["precision",1,o,"rounding",0,8,"toExpNeg",-a,0,"toExpPos",0,a,"maxE",0,a,"minE",-a,0,"modulo",0,9];for(i=0;i<s.length;i+=3)if(t=s[i],n&&(this[t]=h[t]),void 0!==(r=e[t])){if(!(v(r)===r&&r>=s[i+1]&&r<=s[i+2]))throw Error(f+t+": "+r);this[t]=r}if(t="crypto",n&&(this[t]=h[t]),void 0!==(r=e[t])){if(!0!==r&&!1!==r&&0!==r&&1!==r)throw Error(f+t+": "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(d);this[t]=!0}else this[t]=!1}return this}function ce(e){return new this(e).cos()}function he(e){return new this(e).cosh()}function ge(e,i){return new this(e).div(i)}function pe(e){return new this(e).exp()}function fe(e){return L(e=new this(e),e.e+1,3)}function me(){var e,i,t=new this(0);for(g=!1,e=0;e<arguments.length;)if((i=new this(arguments[e++])).d)t.d&&(t=t.plus(i.times(i)));else{if(i.s)return g=!0,new this(1/0);t=i}return g=!0,t.sqrt()}function de(e){return e instanceof t||e&&"[object Decimal]"===e.name||!1}function ve(e){return new this(e).ln()}function xe(e,i){return new this(e).log(i)}function ye(e){return new this(e).log(2)}function be(e){return new this(e).log(10)}function we(){return B(this,arguments,"lt")}function Ne(){return B(this,arguments,"gt")}function Ee(e,i){return new this(e).mod(i)}function qe(e,i){return new this(e).mul(i)}function Me(e,i){return new this(e).pow(i)}function Se(e){var i,t,r,n,s=0,a=new this(1),l=[];if(void 0===e?e=this.precision:z(e,1,o),r=Math.ceil(e/7),this.crypto)if(crypto.getRandomValues)for(i=crypto.getRandomValues(new Uint32Array(r));s<r;)(n=i[s])>=429e7?i[s]=crypto.getRandomValues(new Uint32Array(1))[0]:l[s++]=n%1e7;else{if(!crypto.randomBytes)throw Error(d);for(i=crypto.randomBytes(r*=4);s<r;)(n=i[s]+(i[s+1]<<8)+(i[s+2]<<16)+((127&i[s+3])<<24))>=214e7?crypto.randomBytes(4).copy(i,s):(l.push(n%1e7),s+=4);s=r/4}else for(;s<r;)l[s++]=1e7*Math.random()|0;for(e%=7,(r=l[--s])&&e&&(n=x(10,7-e),l[s]=(r/n|0)*n);0===l[s];s--)l.pop();if(s<0)t=0,l=[0];else{for(t=-1;0===l[0];t-=7)l.shift();for(r=1,n=l[0];n>=10;n/=10)r++;r<7&&(t-=7-r)}return a.e=t,a.d=l,a}function Ae(e){return L(e=new this(e),e.e+1,this.rounding)}function ze(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function ke(e){return new this(e).sin()}function Ie(e){return new this(e).sinh()}function Oe(e){return new this(e).sqrt()}function Le(e,i){return new this(e).sub(i)}function De(e){return new this(e).tan()}function Pe(e){return new this(e).tanh()}function Fe(e){return L(e=new this(e),e.e+1,1)}(t=function e(i){var t,r,n;function s(e){var i,t,r,n=this;if(!(n instanceof s))return new s(e);if(n.constructor=s,e instanceof s)return n.s=e.s,void(g?!e.d||e.e>s.maxE?(n.e=NaN,n.d=null):e.e<s.minE?(n.e=0,n.d=[0]):(n.e=e.e,n.d=e.d.slice()):(n.e=e.e,n.d=e.d?e.d.slice():e.d));if("number"==(r=typeof e)){if(0===e)return n.s=1/e<0?-1:1,n.e=0,void(n.d=[0]);if(e<0?(e=-e,n.s=-1):n.s=1,e===~~e&&e<1e7){for(i=0,t=e;t>=10;t/=10)i++;return void(g?i>s.maxE?(n.e=NaN,n.d=null):i<s.minE?(n.e=0,n.d=[0]):(n.e=i,n.d=[e]):(n.e=i,n.d=[e]))}return 0*e!=0?(e||(n.s=NaN),n.e=NaN,void(n.d=null)):H(n,e.toString())}if("string"!==r)throw Error(f+e);return 45===(t=e.charCodeAt(0))?(e=e.slice(1),n.s=-1):(43===t&&(e=e.slice(1)),n.s=1),N.test(e)?H(n,e):G(n,e)}if(s.prototype=S,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=ue,s.clone=e,s.isDecimal=de,s.abs=K,s.acos=X,s.acosh=ee,s.add=ie,s.asin=te,s.asinh=re,s.atan=ne,s.atanh=se,s.atan2=ae,s.cbrt=oe,s.ceil=le,s.cos=ce,s.cosh=he,s.div=ge,s.exp=pe,s.floor=fe,s.hypot=me,s.ln=ve,s.log=xe,s.log10=be,s.log2=ye,s.max=we,s.min=Ne,s.mod=Ee,s.mul=qe,s.pow=Me,s.random=Se,s.round=Ae,s.sign=ze,s.sin=ke,s.sinh=Ie,s.sqrt=Oe,s.sub=Le,s.tan=De,s.tanh=Pe,s.trunc=Fe,void 0===i&&(i={}),i&&!0!==i.defaults)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<n.length;)i.hasOwnProperty(r=n[t++])||(i[r]=this[r]);return s.config(i),s}(h)).default=t.Decimal=t,u=new t(u),c=new t(c),e.exports?("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator&&(S[Symbol.for("nodejs.util.inspect.custom")]=S.toString,S[Symbol.toStringTag]="Decimal"),e.exports=t):(i||(i="undefined"!=typeof self&&self&&self.self==self?self:window),n=i.Decimal,t.noConflict=function(){return i.Decimal=n,t},i.Decimal=t)}(c)}(h);var g={exports:{}};
|
|
2
|
-
|
|
3
|
-
* @license Complex.js v2.0.13 12/05/2020
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2020, Robert Eisele (robert@xarg.org)
|
|
6
|
-
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
7
|
-
**/!function(e,i){!function(i){var t=function(e){return.5*(Math.exp(e)+Math.exp(-e))},r=function(e){return.5*(Math.exp(e)-Math.exp(-e))},n=function(){throw SyntaxError("Invalid Param")};function s(e,i){var t=Math.abs(e),r=Math.abs(i);return 0===e?Math.log(r):0===i?Math.log(t):t<3e3&&r<3e3?.5*Math.log(e*e+i*i):Math.log(e/Math.cos(Math.atan2(i,e)))}function a(e,i){if(!(this instanceof a))return new a(e,i);var t=function(e,i){var t={re:0,im:0};if(null==e)t.re=t.im=0;else if(void 0!==i)t.re=e,t.im=i;else switch(typeof e){case"object":if("im"in e&&"re"in e)t.re=e.re,t.im=e.im;else if("abs"in e&&"arg"in e){if(!Number.isFinite(e.abs)&&Number.isFinite(e.arg))return a.INFINITY;t.re=e.abs*Math.cos(e.arg),t.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 a.INFINITY;t.re=e.r*Math.cos(e.phi),t.im=e.r*Math.sin(e.phi)}else 2===e.length?(t.re=e[0],t.im=e[1]):n();break;case"string":t.im=t.re=0;var r=e.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),s=1,o=0;null===r&&n();for(var l=0;l<r.length;l++){var u=r[l];" "===u||"\t"===u||"\n"===u||("+"===u?s++:"-"===u?o++:"i"===u||"I"===u?(s+o===0&&n()," "===r[l+1]||isNaN(r[l+1])?t.im+=parseFloat((o%2?"-":"")+"1"):(t.im+=parseFloat((o%2?"-":"")+r[l+1]),l++),s=o=0):((s+o===0||isNaN(u))&&n(),"i"===r[l+1]||"I"===r[l+1]?(t.im+=parseFloat((o%2?"-":"")+u),l++):t.re+=parseFloat((o%2?"-":"")+u),s=o=0))}s+o>0&&n();break;case"number":t.im=0,t.re=e;break;default:n()}return isNaN(t.re)||isNaN(t.im),t}(e,i);this.re=t.re,this.im=t.im}a.prototype={re:0,im:0,sign:function(){var e=this.abs();return new a(this.re/e,this.im/e)},add:function(e,i){var t=new a(e,i);return this.isInfinite()&&t.isInfinite()?a.NAN:this.isInfinite()||t.isInfinite()?a.INFINITY:new a(this.re+t.re,this.im+t.im)},sub:function(e,i){var t=new a(e,i);return this.isInfinite()&&t.isInfinite()?a.NAN:this.isInfinite()||t.isInfinite()?a.INFINITY:new a(this.re-t.re,this.im-t.im)},mul:function(e,i){var t=new a(e,i);return this.isInfinite()&&t.isZero()||this.isZero()&&t.isInfinite()?a.NAN:this.isInfinite()||t.isInfinite()?a.INFINITY:0===t.im&&0===this.im?new a(this.re*t.re,0):new a(this.re*t.re-this.im*t.im,this.re*t.im+this.im*t.re)},div:function(e,i){var t=new a(e,i);if(this.isZero()&&t.isZero()||this.isInfinite()&&t.isInfinite())return a.NAN;if(this.isInfinite()||t.isZero())return a.INFINITY;if(this.isZero()||t.isInfinite())return a.ZERO;e=this.re,i=this.im;var r,n,s=t.re,o=t.im;return 0===o?new a(e/s,i/s):Math.abs(s)<Math.abs(o)?new a((e*(n=s/o)+i)/(r=s*n+o),(i*n-e)/r):new a((e+i*(n=o/s))/(r=o*n+s),(i-e*n)/r)},pow:function(e,i){var t=new a(e,i);if(e=this.re,i=this.im,t.isZero())return a.ONE;if(0===t.im){if(0===i&&e>0)return new a(Math.pow(e,t.re),0);if(0===e)switch((t.re%4+4)%4){case 0:return new a(Math.pow(i,t.re),0);case 1:return new a(0,Math.pow(i,t.re));case 2:return new a(-Math.pow(i,t.re),0);case 3:return new a(0,-Math.pow(i,t.re))}}if(0===e&&0===i&&t.re>0&&t.im>=0)return a.ZERO;var r=Math.atan2(i,e),n=s(e,i);return e=Math.exp(t.re*n-t.im*r),i=t.im*n+t.re*r,new a(e*Math.cos(i),e*Math.sin(i))},sqrt:function(){var e,i,t=this.re,r=this.im,n=this.abs();if(t>=0){if(0===r)return new a(Math.sqrt(t),0);e=.5*Math.sqrt(2*(n+t))}else e=Math.abs(r)/Math.sqrt(2*(n-t));return i=t<=0?.5*Math.sqrt(2*(n-t)):Math.abs(r)/Math.sqrt(2*(n+t)),new a(e,r<0?-i:i)},exp:function(){var e=Math.exp(this.re);return this.im,new a(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){var e=this.re,i=this.im;return new a(Math.expm1(e)*Math.cos(i)+function(e){var i=Math.PI/4;if(e<-i||e>i)return Math.cos(e)-1;var t=e*e;return t*(t*(1/24+t*(-1/720+t*(1/40320+t*(-1/3628800+t*(1/4790014600+t*(-1/87178291200+t*(1/20922789888e3)))))))-.5)}(i),Math.exp(e)*Math.sin(i))},log:function(){var e=this.re,i=this.im;return new a(s(e,i),Math.atan2(i,e))},abs:function(){return e=this.re,i=this.im,t=Math.abs(e),r=Math.abs(i),t<3e3&&r<3e3?Math.sqrt(t*t+r*r):(t<r?(t=r,r=e/i):r=i/e,t*Math.sqrt(1+r*r));var e,i,t,r},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var e=this.re,i=this.im;return new a(Math.sin(e)*t(i),Math.cos(e)*r(i))},cos:function(){var e=this.re,i=this.im;return new a(Math.cos(e)*t(i),-Math.sin(e)*r(i))},tan:function(){var e=2*this.re,i=2*this.im,n=Math.cos(e)+t(i);return new a(Math.sin(e)/n,r(i)/n)},cot:function(){var e=2*this.re,i=2*this.im,n=Math.cos(e)-t(i);return new a(-Math.sin(e)/n,r(i)/n)},sec:function(){var e=this.re,i=this.im,n=.5*t(2*i)+.5*Math.cos(2*e);return new a(Math.cos(e)*t(i)/n,Math.sin(e)*r(i)/n)},csc:function(){var e=this.re,i=this.im,n=.5*t(2*i)-.5*Math.cos(2*e);return new a(Math.sin(e)*t(i)/n,-Math.cos(e)*r(i)/n)},asin:function(){var e=this.re,i=this.im,t=new a(i*i-e*e+1,-2*e*i).sqrt(),r=new a(t.re-i,t.im+e).log();return new a(r.im,-r.re)},acos:function(){var e=this.re,i=this.im,t=new a(i*i-e*e+1,-2*e*i).sqrt(),r=new a(t.re-i,t.im+e).log();return new a(Math.PI/2-r.im,r.re)},atan:function(){var e=this.re,i=this.im;if(0===e){if(1===i)return new a(0,1/0);if(-1===i)return new a(0,-1/0)}var t=e*e+(1-i)*(1-i),r=new a((1-i*i-e*e)/t,-2*e/t).log();return new a(-.5*r.im,.5*r.re)},acot:function(){var e=this.re,i=this.im;if(0===i)return new a(Math.atan2(1,e),0);var t=e*e+i*i;return 0!==t?new a(e/t,-i/t).atan():new a(0!==e?e/0:0,0!==i?-i/0:0).atan()},asec:function(){var e=this.re,i=this.im;if(0===e&&0===i)return new a(0,1/0);var t=e*e+i*i;return 0!==t?new a(e/t,-i/t).acos():new a(0!==e?e/0:0,0!==i?-i/0:0).acos()},acsc:function(){var e=this.re,i=this.im;if(0===e&&0===i)return new a(Math.PI/2,1/0);var t=e*e+i*i;return 0!==t?new a(e/t,-i/t).asin():new a(0!==e?e/0:0,0!==i?-i/0:0).asin()},sinh:function(){var e=this.re,i=this.im;return new a(r(e)*Math.cos(i),t(e)*Math.sin(i))},cosh:function(){var e=this.re,i=this.im;return new a(t(e)*Math.cos(i),r(e)*Math.sin(i))},tanh:function(){var e=2*this.re,i=2*this.im,n=t(e)+Math.cos(i);return new a(r(e)/n,Math.sin(i)/n)},coth:function(){var e=2*this.re,i=2*this.im,n=t(e)-Math.cos(i);return new a(r(e)/n,-Math.sin(i)/n)},csch:function(){var e=this.re,i=this.im,n=Math.cos(2*i)-t(2*e);return new a(-2*r(e)*Math.cos(i)/n,2*t(e)*Math.sin(i)/n)},sech:function(){var e=this.re,i=this.im,n=Math.cos(2*i)+t(2*e);return new a(2*t(e)*Math.cos(i)/n,-2*r(e)*Math.sin(i)/n)},asinh:function(){var e=this.im;this.im=-this.re,this.re=e;var i=this.asin();return this.re=-this.im,this.im=e,e=i.re,i.re=-i.im,i.im=e,i},acosh:function(){var e=this.acos();if(e.im<=0){var i=e.re;e.re=-e.im,e.im=i}else i=e.im,e.im=-e.re,e.re=i;return e},atanh:function(){var e=this.re,i=this.im,t=e>1&&0===i,r=1-e,n=1+e,o=r*r+i*i,l=0!==o?new a((n*r-i*i)/o,(i*r+n*i)/o):new a(-1!==e?e/0:0,0!==i?i/0:0),u=l.re;return l.re=s(l.re,l.im)/2,l.im=Math.atan2(l.im,u)/2,t&&(l.im=-l.im),l},acoth:function(){var e=this.re,i=this.im;if(0===e&&0===i)return new a(0,Math.PI/2);var t=e*e+i*i;return 0!==t?new a(e/t,-i/t).atanh():new a(0!==e?e/0:0,0!==i?-i/0:0).atanh()},acsch:function(){var e=this.re,i=this.im;if(0===i)return new a(0!==e?Math.log(e+Math.sqrt(e*e+1)):1/0,0);var t=e*e+i*i;return 0!==t?new a(e/t,-i/t).asinh():new a(0!==e?e/0:0,0!==i?-i/0:0).asinh()},asech:function(){var e=this.re,i=this.im;if(this.isZero())return a.INFINITY;var t=e*e+i*i;return 0!==t?new a(e/t,-i/t).acosh():new a(0!==e?e/0:0,0!==i?-i/0:0).acosh()},inverse:function(){if(this.isZero())return a.INFINITY;if(this.isInfinite())return a.ZERO;var e=this.re,i=this.im,t=e*e+i*i;return new a(e/t,-i/t)},conjugate:function(){return new a(this.re,-this.im)},neg:function(){return new a(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new a(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new a(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new a(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,i){var t=new a(e,i);return Math.abs(t.re-this.re)<=a.EPSILON&&Math.abs(t.im-this.im)<=a.EPSILON},clone:function(){return new a(this.re,this.im)},toString:function(){var e=this.re,i=this.im,t="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)<a.EPSILON&&(e=0),Math.abs(i)<a.EPSILON&&(i=0),0===i?t+e:(0!==e?(t+=e,t+=" ",i<0?(i=-i,t+="-"):t+="+",t+=" "):i<0&&(i=-i,t+="-"),1!==i&&(t+=i),t+"i"))},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.im&&0===this.re},isFinite:function(){return isFinite(this.re)&&isFinite(this.im)},isInfinite:function(){return!(this.isNaN()||this.isFinite())}},a.ZERO=new a(0,0),a.ONE=new a(1,0),a.I=new a(0,1),a.PI=new a(Math.PI,0),a.E=new a(Math.E,0),a.INFINITY=new a(1/0,1/0),a.NAN=new a(NaN,NaN),a.EPSILON=1e-15,Object.defineProperty(a,"__esModule",{value:!0}),a.default=a,a.Complex=a,e.exports=a}()}(g),new h.exports.Decimal(0),new h.exports.Decimal(1),new h.exports.Decimal(-1),new h.exports.Decimal(NaN),new h.exports.Decimal(1/0),new h.exports.Decimal(-1/0),[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,1.5056327351493116e-7].map((e=>new h.exports.Decimal(e))),new h.exports.Decimal(607).div(128),[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22].map((e=>new h.exports.Decimal(e)));const p="Parentheses",f="LatexTokens",m="List",d="Missing",v="Nothing",x="Sequence",y="Sequence2",b="Add",w="Derivative",N="Divide",E="InverseFunction",q="Multiply",M="Negate",S="Power",A="Prime",z="Root",k="Sqrt",I="Subtract",O="ComplexInfinity",L="ImaginaryUnit";function D(e){return null!==e&&"object"==typeof e&&"num"in e}function P(e){return null!==e&&"object"==typeof e&&"sym"in e}function F(e){return null!==e&&"object"==typeof e&&"fn"in e}function T(e){if("number"==typeof e)return e;if(null===e)return null;if(D(e))return e.num.endsWith("d")||e.num.endsWith("n")?null:parseFloat(e.num);const i=_(e);return null===i?null:"NaN"===i?NaN:"+Infinity"===i?1/0:"-Infinity"===i?-1/0:"Complex"===B(e)&&0===T(H(e,2))?T(H(e,1)):null}function C(e){return null===e?null:"object"==typeof e&&"str"in e?e.str:"string"!=typeof e||e.length<2||"'"!==e[0]||"'"!==e[e.length-1]?null:e.substring(1,e.length-1)}function R(e){var i,t,r,n,s,a;const o=_(e);if("ThreeQuarter"===o)return[3,4];if("TwoThird"===o)return[2,3];if("Half"===o)return[1,2];if("Third"===o)return[1,3];if("Quarter"===o)return[1,4];if(Z(e))return[null,null];const l=B(e);if(!l)return[null,null];let u=null,c=null;if(l===S){const r=T(H(e,2));1===r?(u=null!==(i=T(H(e,1)))&&void 0!==i?i:null,c=1):-1===r&&(u=1,c=null!==(t=T(H(e,1)))&&void 0!==t?t:null)}return l===N&&(u=null!==(r=T(H(e,1)))&&void 0!==r?r:null,c=null!==(n=T(H(e,2)))&&void 0!==n?n:null),l===q&&B(H(e,2))===S&&-1===T(H(H(e,2),2))&&(u=null!==(s=T(H(e,1)))&&void 0!==s?s:null,c=null!==(a=T(H(H(e,2),1)))&&void 0!==a?a:null),null===u||null===c?[null,null]:Number.isInteger(u)&&Number.isInteger(c)?[u,c]:[null,null]}function $(e){return null===e?null:Array.isArray(e)?e[0]:F(e)?e.fn[0]:null}function Z(e){return null===e||!Array.isArray(e)&&("object"!=typeof e||!("fn"in e||"dic"in e))}function B(e){if(null===e)return"";const i=$(e);return"string"==typeof i?i:""}function _(e){return null===e?null:"string"==typeof e?e.length>=2&&"'"===e[0]&&"'"===e[e.length-1]?null:e:P(e)?e.sym:null}function j(e){return Array.isArray(e)?e.slice(1):F(e)?e.fn.slice(1):[]}function U(e,i){let t=null;if(Array.isArray(e)&&(t=e),F(e)&&(t=e.fn),null===t)return[];let r=1;const n=[];for(;r<t.length;)n.push(i(t[r])),r+=1;return n}function H(e,i){var t,r;return null===e?null:Array.isArray(e)?null!==(t=e[i])&&void 0!==t?t:null:F(e)&&null!==(r=e.fn[i])&&void 0!==r?r:null}function G(e){return Array.isArray(e)?Math.max(0,e.length-1):F(e)?Math.max(0,e.fn.length-1):0}function W(e){return"object"==typeof e&&"dict"in e?e.dict:null}const V=[{name:"Overscript",trigger:{infix:"\\overset"},precedence:700},{name:"Underscript",trigger:{infix:"\\underset"},precedence:700},{name:"Increment",trigger:{postfix:["+","+"]},precedence:880},{name:"Decrement",trigger:{postfix:["-","-"]},precedence:880},{name:"PreIncrement",trigger:{prefix:["+","+"]},precedence:880},{name:"PreDecrement",trigger:{prefix:["-","-"]},precedence:880},{name:"Ring",trigger:{infix:"\\circ"},precedence:265},{name:"Transpose",trigger:{superfix:"T"}},{name:"ConjugateTranspose",trigger:{superfix:"H"}},{name:"StringJoin",trigger:{infix:["\\lt","\\gt"]},precedence:780},{name:"Starstar",trigger:{infix:["\\star","\\star"]},precedence:780},{name:"PartialDerivative",trigger:{prefix:"\\partial"},parse:(e,i,t)=>{var r,n;let s=!1,a=v,o=v;for(;!s;)i.skipSpace(),i.match("_")?o=i.matchRequiredLatexArgument():i.match("^")?a=i.matchRequiredLatexArgument():s=!0;if(B(o)===x&&(o=[m,...j(o)]),!o||!a)return[e,null];let l=null!==(r=i.matchRequiredLatexArgument())&&void 0!==r?r:v;return l!==v&&(l=[l,...null!==(n=i.matchArguments("group"))&&void 0!==n?n:v]),[null,["PartialDerivative",l,o,a]]},serialize:(e,i)=>{let t="\\partial";const r=H(i,1),n=H(i,2),s=H(i,3);return null!==n&&n!==v&&($(n)===m?t+="_{"+e.serialize([x,...j(n)])+"}":t+="_{"+e.serialize(n)+"}"),null!==s&&s!==v&&(t+="^{"+e.serialize(s)+"}"),null!==r&&r!==v&&(t+=e.serialize(r)),t},precedence:740},{name:"OverBar",trigger:{symbol:"\\overline"},requiredLatexArg:1},{name:"UnderBar",trigger:{symbol:"\\underline"},requiredLatexArg:1},{name:"OverVector",trigger:{symbol:"\\vec"},requiredLatexArg:1},{name:"OverTile",trigger:{symbol:"\\tilde"},requiredLatexArg:1},{name:"OverHat",trigger:{symbol:"\\hat"},requiredLatexArg:1},{name:"OverHat",trigger:{symbol:"\\hat"},requiredLatexArg:1},{name:"OverRightArrow",trigger:{symbol:"\\overrightarrow"},requiredLatexArg:1},{name:"OverLeftArrow",trigger:{symbol:"\\overleftarrow"},requiredLatexArg:1},{name:"OverRightDoubleArrow",trigger:{symbol:"\\Overrightarrow"},requiredLatexArg:1},{name:"OverLeftHarpoon",trigger:{symbol:"\\overleftharpoon"},requiredLatexArg:1},{name:"OverRightHarpoon",trigger:{symbol:"\\overrightharpoon"},requiredLatexArg:1},{name:"OverLeftRightArrow",trigger:{symbol:"\\overleftrightarrow"},requiredLatexArg:1},{name:"OverBrace",trigger:{symbol:"\\overbrace"},requiredLatexArg:1},{name:"OverLineSegment",trigger:{symbol:"\\overlinesegment"},requiredLatexArg:1},{name:"OverGroup",trigger:{symbol:"\\overgroup"},requiredLatexArg:1}];function Q(e,i){return i>2?"solidus":"radical"}function Y(e){return"<space>"===e||"\\qquad"===e||"\\quad"===e||"\\enskip"===e||"\\;"===e||"\\,"===e||"\\ "===e||"~"===e}function J(e,i,t){return(r,n,s)=>{if(s>=i)return[r,null];n.skipSpace(),n.match(t),"Missing"===r&&(r=v);const a=[e,null!=r?r:v];let o=!1;for(;!o;){for(o=!0,n.skipSpace();n.match(t);)a.push(v),n.skipSpace();if(n.atEnd)a.push(v);else{const e=n.matchExpression(i);a.push(null!=e?e:v),o=null===e}o||(n.skipSpace(),o=!n.match(t))}return[null,a]}}function K(e){return(i,t)=>j(t).map((e=>i.serialize(e))).join(e)}const X=[{name:f,serialize:function(e,i){return j(i).map((i=>{const t=C(i);return null===t?e.serialize(i):"<{>"===t?"{":"<}>"===t?"}":"<$>"===t?"$":"<$$>"===t?"$$":"<space>'"===t?" ":t})).join("")}},{name:p,trigger:{matchfix:"("},parse:(e,i,t)=>{var r;const n=i.index;if(!i.match("("))return[e,null];let s=!1,a=!0,o=!1,l=0,u="";for(;!s&&a;){const e=i.next();i.atEnd||")"===e?s=!0:"\\mathtt"===e?(i.match("<{>"),o=!0):Y(e)||(/^[0-9a-zA-Z]$/.test(e)?(l=Math.max(l,parseInt(e,36)),u+=e):a=!1),o&&i.match("<}>")}if(i.skipSpace(),a&&i.match("_")){const t=null!==(r=T(i.matchRequiredLatexArgument()))&&void 0!==r?r:NaN;return!isFinite(t)||t<2||t>36||l>=t?(i.onError({code:"base-out-of-range"}),[e,v]):[e,["BaseForm",parseInt(u,t),t]]}i.index=n;const c=i.matchBalancedExpression("(",")",i.onError);return c?B(c)===x?[e,[p,...j(c)]]:[e,[p,c]]:[e,[p]]},serialize:(e,i)=>e.wrapString(K(",")(e,i),(e.level,"paren")),separator:",",closeFence:")",precedence:20},{name:m,trigger:{matchfix:"\\lbrack"},separator:",",closeFence:"\\rbrack",precedence:20,parse:(e,i,t)=>{if(null===e){const t=i.matchBalancedExpression("\\lbrack","\\rbrack",i.onError);return t?B(t)===x?[e,[m,...j(t)]]:[e,[m,t]]:[null,[m]]}return[e,null]}},{name:"BaseForm",serialize:(e,i)=>{var t,r;const n=null!==(t=T(H(i,2)))&&void 0!==t?t:NaN;if(isFinite(n)&&n>=2&&n<=36){const e=null!==(r=T(H(i,1)))&&void 0!==r?r:NaN;if(isFinite(e)){let i=Number(e).toString(n),t=0;if(2===n||10===n?t=4:16===n?t=2:n>16&&(t=4),t>0){const e=i;i="";for(let r=0;r<e.length;r++)r>0&&r%t==0&&(i="\\, "+i),i=e[e.length-r-1]+i}return`(\\mathtt{${i}})_{${n}}`}}return"\\operatorname{BaseForm}("+e.serialize(H(i,1))+", "+e.serialize(H(i,2))+")"}},{name:"Set",trigger:{matchfix:"\\lbrace"},separator:",",closeFence:"\\rbrace",precedence:20},{name:x,trigger:{infix:","},parse:J(x,20,","),serialize:K(", "),precedence:20},{name:y,trigger:{infix:";"},parse:J(y,19,";"),serialize:K("; "),precedence:19},{name:d,trigger:"\\placeholder",serialize:"\\placeholder",requiredLatexArg:1},{name:"Subscript",trigger:{infix:"_"},precedence:720,serialize:(e,i)=>2===G(i)?e.serialize(H(i,1))+"_{"+e.serialize(H(i,2))+"}":"_{"+e.serialize(H(i,1))+"}",parse:(e,i,t)=>{var r;if(!i.match("_"))return[e,null];const n=null!==(r=i.matchRequiredLatexArgument())&&void 0!==r?r:d;return e?[null,["Subscript",e,n]]:[null,["Subscript",n]]}},{name:"Superplus",trigger:{superfix:"+"}},{name:"Subplus",trigger:{subfix:"+"}},{name:"Superminus",trigger:{superfix:"-"}},{name:"Subminus",trigger:{subfix:"-"}},{name:"Superstar",trigger:{superfix:"*"}},{name:"Superstar",trigger:{superfix:"\\star"}},{name:"Substar",trigger:{subfix:"*"}},{name:"Substar",trigger:{subfix:"\\star"}},{name:"Superdagger",trigger:{superfix:"\\dagger"}},{name:"Superdagger",trigger:{superfix:"\\dag"}},{name:A,trigger:{superfix:"\\prime"},arguments:"group"},{trigger:{superfix:"\\doubleprime"},parse:(e,i)=>[null,[A,null!=e?e:v,2]],arguments:"group"},{name:E,serialize:(e,i)=>e.serialize(H(i,1))+"^{-1}"},{name:w,trigger:"D",parse:(e,i)=>[e,[w,1]],serialize:(e,i)=>{var t;const r=null!==(t=T(H(i,1)))&&void 0!==t?t:NaN;if(!isFinite(r))return"";const n=e.serialize(H(i,2));return 1===r?n+"^{\\prime}":2===r?n+"^{\\doubleprime}":n+"^{("+Number(r).toString()+")}"}},{name:"Piecewise",trigger:{environment:"cases"},parse:(e,i)=>{var t;return[e,["Piecewise",null!==(t=i.matchTabular())&&void 0!==t?t:v]]},serialize:(e,i)=>{if(B(H(i,1))!==m)return"";const t=j(H(i,1));let r="",n="";for(const i of t){r+=n;const t=H(i,1);if(null!==t){r+=e.serialize(t);const n=H(i,2);null!==n&&(r+="&"+e.serialize(n))}n="\\\\"}return"\\begin{cases}"+r+"\\end{cases}"}}];function ee(e){var i,t,r,n;if("number"==typeof(e=ie(e)))return-e;if(e&&D(e))return"-"===e.num[0]?{num:e.num.slice(1)}:"+"===e.num[0]?{num:"-"+e.num.slice(1)}:{num:"-"+e.num};if(e instanceof h.exports.Decimal)return e.mul(-1);if(e instanceof g.exports.Complex)return e.mul(-1);const s=B(e),a=G(e);if(s===M&&1===a)return null!==(i=H(e,1))&&void 0!==i?i:d;if(s===q){const i=ee(null!==(t=H(e,1))&&void 0!==t?t:d);return[q,i,...j(e).slice(1)]}return s===b?[b,...U(e,ee)]:s===I?[I,null!==(r=H(e,2))&&void 0!==r?r:d,null!==(n=H(e,1))&&void 0!==n?n:d]:s===p&&1===a?ee(H(H(e,1),1)):[M,null!=e?e:d]}function ie(e){return null===e?v:Z(e)?e:$(e)===p&&1===G(e)?ie(H(e,1)):function(e,i){const t=$(e);if(null!==t)return[i(t),...j(e).map(i)];const r=W(e);if(null!==r){const e=Object.keys(r),t={};for(const n of e)t[n]=i(r[n]);return{dict:t}}return i(e)}(e,ie)}function te(e,i,t,r){return null===t?"\\sqrt{}":(r=null!=r?r:2,"solidus"===i?e.wrapShort(t)+"^{1\\/"+e.serialize(r)+"}":"quotient"===i?e.wrapShort(t)+"^{\\frac{1}{"+e.serialize(r)+"}}":2===T(r)?"\\sqrt{"+e.serialize(t)+"}":"\\sqrt["+e.serialize(r)+"]{"+e.serialize(t)+"}")}function re(e,i,t){if(!i.match("\\sqrt"))return[e,null];const r=i.matchOptionalLatexArgument(),n=i.matchRequiredLatexArgument();return null===n?null!==r?[e,[z,v,r]]:[e,[k]]:null!==r?[e,[z,n,r]]:[e,[k,n]]}function ne(e,i,t){if(276<t)return[e,null];const r=i.index;if(!i.match("-"))return[e,null];const n=i.matchExpression(null===e?400:277);return null===n?(i.index=r,[e,null]):null===e?[null,[M,n]]:[null,[I,e,n]]}function se(e,i){var t;if(null===i)return"";e.level-=1;let r="";const[n,s]=function(e){var i,t,r,n,s,a;if(B(e)!==q)return[[],[]];const o=[],l=[],u=j(e);for(const e of u)if(B(e)===S)if(B(H(e,2))===M){const r=null!==(i=H(e,1))&&void 0!==i?i:v,n=null!==(t=H(H(e,2),1))&&void 0!==t?t:v;l.push([S,r,n])}else{const i=null!==(r=T(H(e,2)))&&void 0!==r?r:NaN;-1===i?l.push(null!==(n=H(e,1))&&void 0!==n?n:v):i<0?l.push([S,null!==(s=H(e,1))&&void 0!==s?s:v,null!==(a=ee(H(e,2)))&&void 0!==a?a:v]):o.push(e)}else o.push(e);return[o,l]}(i);if(s.length>0&&(r=1===s.length&&1===s[0]?0===n.length?"1":1===n.length?e.serialize(n[0]):se(e,[q,...n]):e.serialize([N,1===n.length?n[0]:[q,...n],1===s.length?s[0]:[q,...s]])),r)return e.level+=1,r;let a=!1,o=null;const u=G(i)+1;let c=!1;for(let n=1;n<u;n++)if(o=H(i,n),null!==o){let i;"number"==typeof o||D(o)?(i=e.serialize(o),"-1"!==i||r?("-"===i[0]&&(i=i.slice(1),a=!a),r=r?l([r,e.options.multiply,i]):i):r="-",c=!0):B(o)!==S||isNaN(null!==(t=T(H(o,1)))&&void 0!==t?t:NaN)?(B(o)===M&&(o=H(o,1),a=!a),i=e.wrap(o,390),r=r?c&&B(o)===N?l([r,"\\times",i]):e.options.invisibleMultiply?l([r,e.options.invisibleMultiply,i]):l([r,i]):i,c=!1):(r=r?l([r,e.options.multiply,e.serialize(o)]):e.serialize(o),c=!0)}return e.level+=1,a?"-"+r:r}function ae(e,i){if(null===i)return"";if(1===G(i))return e.serialize(H(i,1));const t=e.level>3?"inline-solidus":"quotient";if("inline-solidus"===t||"nice-solidus"===t){const r=e.wrapShort(H(i,1)),n=e.wrapShort(H(i,2));return"nice-solidus"===t?`^{${r}}\\!\\!/\\!_{${n}}`:`${r}\\/${n}`}return"reciprocal"===t?e.wrap(H(i,1))+e.wrap(H(i,2))+"^{-1}":"factor"===t?"\\frac{1}{"+e.serialize(H(i,2))+"}"+e.wrap(H(i,1)):"\\frac{"+e.serialize(H(i,1))+"}{"+e.serialize(H(i,2))+"}"}function oe(e,i){var t;const r=H(i,1),n=H(i,2);if(null===n)return e.serialize(r);if(null===r)return"";const s=B(i);if(s===k||s===z)return te(e,Q(0,e.level),H(i,1),H(i,2));const a=null!==(t=T(n))&&void 0!==t?t:1;if(-1===a)return e.serialize([N,"1",r]);if(a<0)return e.serialize([N,"1",[S,r,-a]]);if(B(n)===N){if(1===T(H(n,1)))return te(e,Q(0,e.level),r,H(n,2))}else if(B(n)===S&&-1===T(H(n,2)))return te(e,Q(0,e.level),r,H(n,1));return e.wrapShort(r)+"^{"+e.serialize(n)+"}"}function le(e,i,t){var r;const n=i.next();let s=!1,a=0;if(i.skipSpace(),i.match("^")){if(i.skipSpace(),i.match("<{>")){i.skipSpace(),i.match("-")&&i.match("1")&&(s=!0);do{i.match("\\doubleprime")&&(a+=2),i.match("\\prime")&&(a+=1),i.match("'")&&(a+=1)}while(!i.match("<}>")&&!i.atEnd)}let e=!1;for(;!e;)i.skipSpace(),i.match("\\doubleprime")?a+=2:i.match("\\prime")||i.match("'")?a+=1:e=!0}let o=null!==(r={"\\arcsin":"Arcsin","\\arccos":"Arccos","\\arctan":"Arctan","\\arctg":"Arctan","\\arcctg":"Arctan","\\arcsec":"Arcsec","\\arccsc":" Arccsc","\\arsinh":"Arsinh","\\arcosh":"Arcosh","\\artanh":"Artanh","\\arcsech":"Arcsech","\\arccsch":"Arcsch","\\ch":"Cosh","\\cos":"Cos","\\cosec":"Csc","\\cosh":"Csch","\\cot":"Cot","\\cotg":"Cot","\\coth":"Coth","\\csc":"Csc","\\ctg":"Cot","\\cth":"Coth","\\sec":"Sec","\\sin":"Sin","\\sinh":"Sinh","\\sh":"Sinh","\\tan":"Tan","\\tanh":"Tanh","\\tg":"Tan","\\th":"Tanh"}[n])&&void 0!==r?r:n;s&&(o=[E,o]),a>=1&&(o=[w,a,o]);const l=i.matchArguments("implicit");return null===l?[null,o]:[null,[o,...l]]}function ue(e){return u(e)}Number.EPSILON.toString();const ce={algebra:[{name:"To",trigger:{infix:"\\to"},precedence:270}],arithmetic:[{name:"ThreeQuarter",serialize:"\\frac{3}{4}"},{name:"TwoThird",serialize:"\\frac{2}{3}"},{name:"Half",serialize:"\\frac{1}{2}"},{name:"Third",serialize:"\\frac{1}{3}"},{name:"Quarter",serialize:"\\frac{1}{4}"},{name:"CatalanConstant",serialize:"G"},{name:"GoldenRatio",serialize:"\\varphi"},{name:"EulerGamma",serialize:"\\gamma"},{name:"Degrees",serialize:"\\frac{\\pi}{180}"},{name:"MinusDoublePi",serialize:"-2\\pi"},{name:"MinusPi",serialize:"-\\pi"},{name:"MinusHalfPi",serialize:"-\\frac{\\pi}{2}"},{name:"QuarterPi",serialize:"\\frac{\\pi}{4}"},{name:"ThirdPi",serialize:"\\frac{\\pi}{3}"},{name:"HalfPi",serialize:"\\frac{\\pi}{2}"},{name:"TwoThirdPi",serialize:"\\frac{2\\pi}{3}"},{name:"ThreeQuarterPi",serialize:"\\frac{3\\pi}{4}"},{name:"DoublePi",serialize:"2\\pi"},{name:"Complex",precedence:275,serialize:(e,i)=>{const t=T(H(i,1)),r=T(H(i,2));if(0===r)return e.serialize(H(i,1));const n=1===r?"\\imaginaryI":-1===r?"-\\imaginaryI":l([e.serialize(H(i,2)),"\\imaginaryI"]);return 0===t?n:l([e.serialize(H(i,1)),"+",n])}},{name:"Exp",serialize:(e,i)=>{var t;return l(["\\exponentialE^{",e.serialize(null!==(t=H(i,1))&&void 0!==t?t:v),"}"])}},{name:"Square",serialize:(e,i)=>e.wrapShort(H(i,1))+"^2"},{trigger:{symbol:"\\infty"},parse:{num:"+Infinity"}},{name:O,trigger:{symbol:["\\tilde","\\infty"]},serialize:"\\tilde\\infty"},{name:O,trigger:{symbol:["\\tilde","<{>","\\infty","<}>"]},serialize:"\\tilde\\infty"},{name:"Pi",trigger:{symbol:"\\pi"}},{name:"Pi",trigger:{symbol:"π"},serialize:"\\pi"},{name:"ExponentialE",trigger:{symbol:"e"},serialize:"e"},{name:L,trigger:{symbol:"i"},serialize:"\\imaginaryI"},{name:L,trigger:{symbol:"\\imaginaryI"}},{name:b,trigger:{prefix:"+",infix:"+"},parse:function(e,i,t){if(275<t)return[e,null];const r=i.index;if(!i.match("+"))return[e,null];const n=i.matchExpression(null===e?400:275);return null===n?(i.index=r,[e,null]):null===e?[null,n]:i.applyOperator(b,e,n)},serialize:function(e,i){var t,r;e.level-=1;const n=B(i);let s="",a=H(i,1),o=!Number.isNaN(null!==(t=T(a))&&void 0!==t?t:NaN);if(n===M)s="-"+e.wrap(a,276);else if(n===b){s=e.serialize(a);const t=G(i)+1;for(let n=2;n<t;n++){a=H(i,n);const t=null!==(r=T(a))&&void 0!==r?r:NaN,l=!Number.isNaN(t);let u=!1;if(null!==a&&o){const[i,t]=R(a);null!==i&&null!==t&&isFinite(i)&&isFinite(t)&&1!==t&&(s+=e.options.invisiblePlus+e.serialize(a),u=!0)}if(!u)if(t<0)s+=e.serialize(a);else if(B(a)===M)s+=e.wrap(a,275);else{const i=e.wrap(a,275);"-"===i[0]||"+"===i[0]?s+=i:s=s+"+"+i}o=l}}else if(n===I){const t=H(i,2);s=null!==t?e.wrap(a,275)+"-"+e.wrap(t,275):e.wrap(a,275)}return e.level+=1,s},associativity:"both",precedence:275},{name:M,trigger:{prefix:"-"},parse:ne,associativity:"left",precedence:275},{name:I,trigger:{infix:"-"},parse:ne,associativity:"both",precedence:275},{name:"PlusMinus",trigger:{infix:"\\pm"},associativity:"both",precedence:270},{name:"MinusPlus",trigger:{infix:"\\mp"},associativity:"both",precedence:270},{name:q,trigger:{infix:"\\times"},serialize:se,associativity:"both",precedence:390},{name:q,trigger:{infix:"\\cdot"},serialize:se,associativity:"both",precedence:390},{name:q,trigger:{infix:"*"},serialize:se,associativity:"both",precedence:390},{name:N,trigger:"\\frac",parse:function(e,i,t){var r,n,s,a;if(!i.match("\\frac"))return[e,null];const o=null!==(r=i.matchRequiredLatexArgument())&&void 0!==r?r:d,l=null!==(n=i.matchRequiredLatexArgument())&&void 0!==n?n:d;if("PartialDerivative"===B(o)&&("PartialDerivative"===B(l)||B(l)===q&&"PartialDerivative"===B(H(l,1)))){const t=null!==(s=H(o,3))&&void 0!==s?s:v;let r=H(o,1);null!==r&&r!==v||(r=null!==(a=i.matchExpression())&&void 0!==a?a:v);let n=[];if(B(l)===q){for(const e of j(l))if("PartialDerivative"===$(e)){const i=H(e,2);i&&n.push(i)}}else{const e=H(l,2);e&&n.push(e)}return n.length>1&&(n=[m,...n]),[e,["PartialDerivative",r,n,t===v?1:t]]}return[e,[N,o,l]]},serialize:ae,requiredLatexArg:2},{name:N,trigger:{infix:"\\/"},serialize:ae,associativity:"non",precedence:660},{name:N,trigger:{infix:"/"},serialize:ae,associativity:"non",precedence:660},{name:N,trigger:{infix:"\\div"},serialize:ae,associativity:"non",precedence:660},{name:S,trigger:{infix:"^"},associativity:"non",precedence:720,serialize:oe},{name:S,trigger:{infix:["*","*"]},associativity:"non",precedence:720,serialize:oe},{name:k,trigger:"\\sqrt",optionalLatexArg:1,requiredLatexArg:1,parse:re,serialize:oe},{name:z,trigger:"\\sqrt",optionalLatexArg:1,requiredLatexArg:1,parse:re},{name:"Norm",trigger:{matchfix:"\\lVert"},closeFence:"\\rVert"},{name:"Norm",trigger:{matchfix:"\\|"},closeFence:"\\|"},{name:"Norm",trigger:{matchfix:["|","|"]},closeFence:["|","|"]},{name:"Abs",trigger:{matchfix:"|"},closeFence:"|"},{name:"Abs",trigger:{matchfix:"\\lvert"},closeFence:"\\rvert"},{name:"Factorial",trigger:{postfix:"!"},precedence:810},{name:"Factorial2",trigger:{postfix:["!","!"]},precedence:810},{name:"Lcm",trigger:{symbol:["\\operatorname","<{>","l","c","m","<}>"]}},{name:"Gcd",trigger:{symbol:["\\operatorname","<{>","g","c","d","<}>"]}},{name:"Ceil",trigger:{symbol:["\\operatorname","<{>","c","e","i","l","<}>"]}},{name:"Floor",trigger:{symbol:["\\operatorname","<{>","f","l","o","o","r","<}>"]}},{name:"Round",trigger:{symbol:["\\operatorname","<{>","r","o","u","n","d","<}>"]}},{name:"Sign",trigger:{symbol:["\\operatorname","<{>","s","g","n","<}>"]}}],calculus:[{trigger:{symbol:"\\int"},parse:function(e,i,t){if(!i.match("\\int"))return[e,null];let r=v,n=v,s=!1;for(;!s;)i.skipSpace(),i.match("_")?n=i.matchRequiredLatexArgument():i.match("^")?r=i.matchRequiredLatexArgument():s=!0;const a=i.matchBalancedExpression("<{>","<}>");return[e,["Integral",null!=a?a:"",null!=r?r:v,null!=n?n:v]]},serialize:function(e,i){return""}}],core:X,inequalities:[{name:"NotLess",trigger:{infix:["!","<"]},associativity:"right",precedence:246},{name:"NotLess",trigger:{infix:"\\nless"},associativity:"right",precedence:246},{name:"Less",trigger:{infix:"<"},associativity:"right",precedence:245},{name:"Less",trigger:{infix:"\\lt"},associativity:"right",precedence:245},{name:"LessEqual",trigger:{infix:["<","="]},associativity:"right",precedence:241},{name:"LessEqual",trigger:{infix:"\\le"},associativity:"right",precedence:241},{name:"LessEqual",trigger:{infix:"\\leq"},associativity:"right",precedence:241},{name:"LessEqual",trigger:{infix:"\\leqslant"},associativity:"right",precedence:265},{name:"LessNotEqual",trigger:{infix:"\\lneqq"},associativity:"right",precedence:260},{name:"NotLessNotEqual",trigger:{infix:"\\nleqq"},associativity:"right",precedence:260},{name:"LessOverEqual",trigger:{infix:"\\leqq"},associativity:"right",precedence:265},{name:"GreaterOverEqual",trigger:{infix:"\\geqq"},associativity:"right",precedence:265},{name:"Equal",trigger:{infix:"="},associativity:"right",precedence:260},{name:"StarEqual",trigger:{infix:["*","="]},associativity:"right",precedence:260},{name:"StarEqual",trigger:{infix:["\\star","="]},associativity:"right",precedence:260},{name:"PlusEqual",trigger:{infix:["+","="]},associativity:"right",precedence:260},{name:"MinusEqual",trigger:{infix:["-","="]},associativity:"right",precedence:260},{name:"SlashEqual",trigger:{infix:["/","="]},associativity:"right",precedence:260},{name:"EqualEqual",trigger:{infix:["=","="]},associativity:"right",precedence:260},{name:"EqualEqualEqual",trigger:{infix:["=","=","="]},associativity:"right",precedence:265},{name:"TildeFullEqual",trigger:{infix:"\\cong"},associativity:"right",precedence:260},{name:"NotTildeFullEqual",trigger:{infix:"\\ncong"},associativity:"right",precedence:260},{name:"Assign",trigger:{infix:[":","="]},associativity:"right",precedence:260},{name:"Assign",trigger:{infix:"\\coloneq"},associativity:"right",precedence:260},{name:"Approx",trigger:{infix:"\\approx"},associativity:"right",precedence:247},{name:"NotApprox",trigger:{infix:"\\approx"},associativity:"right",precedence:247},{name:"ApproxEqual",trigger:{infix:"\\approxeq"},associativity:"right",precedence:260},{name:"NotApproxEqual",trigger:{infix:["!","\\approxeq"]},associativity:"right",precedence:250},{name:"NotEqual",trigger:{infix:"\\ne"},associativity:"right",precedence:255},{name:"Unequal",trigger:{infix:["!","="]},associativity:"right",precedence:260},{name:"GreaterEqual",trigger:{infix:"\\ge"},associativity:"right",precedence:242},{name:"GreaterEqual",trigger:{infix:"\\geq"},associativity:"right",precedence:242},{name:"GreaterEqual",trigger:{infix:[">","="]},associativity:"right",precedence:243},{name:"GreaterEqual",trigger:{infix:"\\geqslant"},associativity:"right",precedence:265},{name:"GreaterNotEqual",trigger:{infix:"\\gneqq"},associativity:"right",precedence:260},{name:"NotGreaterNotEqual",trigger:{infix:"\\ngeqq"},associativity:"right",precedence:260},{name:"Greater",trigger:{infix:">"},associativity:"right",precedence:245},{name:"Greater",trigger:{infix:"\\gt"},associativity:"right",precedence:245},{name:"NotGreater",trigger:{infix:"\\ngtr"},associativity:"right",precedence:244},{name:"NotGreater",trigger:{infix:["!",">"]},associativity:"right",precedence:244},{name:"RingEqual",trigger:{infix:"\\circeq"},associativity:"right",precedence:260},{name:"TriangleEqual",trigger:{infix:"\\triangleq"},associativity:"right",precedence:260},{name:"DotEqual",trigger:{infix:"\\doteq"},associativity:"right",precedence:265},{name:"DotEqualDot",trigger:{infix:"\\doteqdot"},associativity:"right",precedence:265},{name:"FallingDotEqual",trigger:{infix:"\\fallingdotseq"},associativity:"right",precedence:265},{name:"RisingDotEqual",trigger:{infix:"\\fallingdotseq"},associativity:"right",precedence:265},{name:"QuestionEqual",trigger:{infix:"\\questeq"},associativity:"right",precedence:260},{name:"Equivalent",trigger:{infix:"\\equiv"},associativity:"right",precedence:260},{name:"MuchLess",trigger:{infix:"\\ll"},associativity:"right",precedence:260},{name:"MuchGreater",trigger:{infix:"\\gg"},associativity:"right",precedence:260},{name:"Precedes",trigger:{infix:"\\prec"},associativity:"right",precedence:260},{name:"Succeeds",trigger:{infix:"\\succ"},associativity:"right",precedence:260},{name:"PrecedesEqual",trigger:{infix:"\\preccurlyeq"},associativity:"right",precedence:260},{name:"SucceedsEqual",trigger:{infix:"\\curlyeqprec"},associativity:"right",precedence:260},{name:"NotPrecedes",trigger:{infix:"\\nprec"},associativity:"right",precedence:260},{name:"NotSucceeds",trigger:{infix:"\\nsucc"},associativity:"right",precedence:260},{name:"Between",trigger:{infix:"\\between"},associativity:"right",precedence:265}],other:V,physics:[{name:"mu-0",trigger:{symbol:["\\mu","_","0"]}}],sets:[{trigger:{symbol:"\\N"},parse:"NaturalNumber"},{trigger:{symbol:"\\Z"},parse:"Integer"},{trigger:{symbol:"\\Q"},parse:"RationalNumber"},{trigger:{symbol:["\\mathbb","<{>","A","<}>"]},parse:"AlgebraicNumber"},{trigger:{symbol:"\\R"},parse:"RealNumber"},{trigger:{symbol:"\\C"},parse:"ComplexNumber"},{trigger:{symbol:"\\varnothing"},parse:"EmptySet"},{trigger:{symbol:"\\emptyset"},parse:"EmptySet"},{name:"Complement",trigger:{infix:"\\complement"},precedence:240},{name:"Element",trigger:{infix:"\\in"},precedence:240},{name:"Intersection",trigger:{infix:"\\Cap"},precedence:350},{name:"NotElement",trigger:{infix:"\\notin"},precedence:240},{name:"SetMinus",trigger:{infix:"\\setminus"},precedence:650},{name:"SubsetEqual",trigger:{infix:"\\subseteq"},precedence:240},{name:"SymmetricDifference",trigger:{infix:"\\triangle"},precedence:260},{name:"Union",trigger:{infix:"\\cup"},precedence:350},{name:"Contains",trigger:{infix:"\\ni"},associativity:"right",precedence:160},{name:"Subset",trigger:{infix:"\\subset"},associativity:"right",precedence:240},{name:"SquareSubset",trigger:{infix:"\\sqsubset"},associativity:"right",precedence:265},{name:"SquareSubsetEqual",trigger:{infix:"\\sqsubseteq"},associativity:"right",precedence:265},{name:"Superset",trigger:{infix:"\\supset"},associativity:"right",precedence:240},{name:"SquareSuperset",trigger:{infix:"\\sqsupset"},associativity:"right",precedence:265},{name:"SquareSupersetEqual",trigger:{infix:"\\sqsupseteq"},associativity:"right",precedence:265},{name:"NotSubset",trigger:{infix:"\\nsubset"},associativity:"right",precedence:240},{name:"NotSuperset",trigger:{infix:"\\nsupset"},associativity:"right",precedence:240},{name:"SupersetEqual",trigger:{infix:"\\supseteq"},associativity:"right",precedence:240},{name:"NotSubsetNotEqual",trigger:{infix:"\\nsubseteq"},associativity:"right",precedence:240},{name:"NotSupersetNotEqual",trigger:{infix:"\\nsupseteq"},associativity:"right",precedence:240},{name:"SubsetNotEqual",trigger:{infix:"\\subsetneq"},associativity:"right",precedence:240},{name:"SubsetNotEqual",trigger:{infix:"\\varsupsetneqq"},associativity:"right",precedence:240},{name:"SupersetNotEqual",trigger:{infix:"\\supsetneq"},associativity:"right",precedence:240},{name:"SupersetNotEqual",trigger:{infix:"\\varsupsetneq"},associativity:"right",precedence:240}],symbols:[{trigger:{symbol:"\\alpha"},parse:"α"},{trigger:{symbol:"\\beta"},parse:"β"},{trigger:{symbol:"\\gamma"},parse:"γ"},{trigger:{symbol:"\\delta"},parse:"δ"},{trigger:{symbol:"\\epsilon"},parse:"ϵ"},{trigger:{symbol:"\\varepsilon"},parse:"ε"},{trigger:{symbol:"\\zeta"},parse:"ζ"},{trigger:{symbol:"\\eta"},parse:"η"},{trigger:{symbol:"\\theta"},parse:"θ"},{trigger:{symbol:"\\vartheta"},parse:"ϑ"},{trigger:{symbol:"\\iota"},parse:"ι"},{trigger:{symbol:"\\kappa"},parse:"κ"},{trigger:{symbol:"\\varkappa"},parse:"ϰ"},{trigger:{symbol:"\\lambda"},parse:"λ"},{trigger:{symbol:"\\mu"},parse:"μ"},{trigger:{symbol:"\\nu"},parse:"ν"},{trigger:{symbol:"\\xi"},parse:"ξ"},{trigger:{symbol:"\\omicron"},parse:"ο"},{trigger:{symbol:"\\varpi"},parse:"ϖ"},{trigger:{symbol:"\\rho"},parse:"ρ"},{trigger:{symbol:"\\varrho"},parse:"ϱ"},{trigger:{symbol:"\\sigma"},parse:"σ"},{trigger:{symbol:"\\varsigma"},parse:"ς"},{trigger:{symbol:"\\tau"},parse:"τ"},{trigger:{symbol:"\\phi"},parse:"ϕ"},{trigger:{symbol:"\\varphi"},parse:"φ"},{trigger:{symbol:"\\upsilon"},parse:"υ"},{trigger:{symbol:"\\chi"},parse:"χ"},{trigger:{symbol:"\\psi"},parse:"ψ"},{trigger:{symbol:"\\omega"},parse:"ω"},{trigger:{symbol:"\\Gamma"},parse:"Γ"},{trigger:{symbol:"\\Delta"},parse:"Δ"},{trigger:{symbol:"\\Theta"},parse:"Θ"},{trigger:{symbol:"\\Lambda"},parse:"Λ"},{trigger:{symbol:"\\Xi"},parse:"Ξ"},{trigger:{symbol:"\\Pi"},parse:"Π"},{trigger:{symbol:"\\Sigma"},parse:"Σ"},{trigger:{symbol:"\\Upsilon"},parse:"Υ"},{trigger:{symbol:"\\Phi"},parse:"Φ"},{trigger:{symbol:"\\Psi"},parse:"Ψ"},{trigger:{symbol:"\\Omega"},parse:"Ω"},{trigger:{symbol:"\\digamma"},parse:"ϝ"},{trigger:{symbol:"\\aleph"},parse:"ℵ"},{trigger:{symbol:"\\beth"},parse:"ℶ"},{trigger:{symbol:"\\daleth"},parse:"ℸ"},{trigger:{symbol:"\\gimel"},parse:"ℷ"},{trigger:{symbol:"\\Finv"},parse:"Ⅎ"},{trigger:{symbol:"\\Game"},parse:"⅁"},{trigger:{symbol:"\\wp"},parse:"℘"},{trigger:{symbol:"\\eth"},parse:"ð"},{trigger:{symbol:"\\mho"},parse:"℧"},{trigger:{symbol:"\\clubsuit"},parse:"♣"},{trigger:{symbol:"\\heartsuit"},parse:"♡"},{trigger:{symbol:"\\spadesuit"},parse:"♠"},{trigger:{symbol:"\\diamondsuit"},parse:"♢"},{trigger:{symbol:"\\sharp"},parse:"♯"},{trigger:{symbol:"\\flat"},parse:"♭"},{trigger:{symbol:"\\natural"},parse:"♮"}],trigonometry:[{name:"Arcsin",trigger:"\\arcsin",arguments:"implicit",parse:le},{name:"Arccos",trigger:"\\arccos",arguments:"implicit",parse:le},{name:"Arctan",trigger:"\\arctan",arguments:"implicit",parse:le},{name:"Arctan",trigger:"\\arctg",arguments:"implicit",parse:le},{name:"Arccot",trigger:"\\arcctg",arguments:"implicit",parse:le},{name:"Arcsec",trigger:"\\arcsec",arguments:"implicit",parse:le},{name:"Arccsc",trigger:"\\arccsc",arguments:"implicit",parse:le},{name:"Arsinh",trigger:"\\arsinh",arguments:"implicit",parse:le},{name:"Arcosh",trigger:"\\arcosh",arguments:"implicit",parse:le},{name:"Artanh",trigger:"\\artanh",arguments:"implicit",parse:le},{name:"Arsech",trigger:"\\arsech",arguments:"implicit",parse:le},{name:"Arcsch",trigger:"\\arcsch",arguments:"implicit",parse:le},{name:"Cosh",trigger:"\\ch",arguments:"implicit",parse:le},{name:"Cosec",trigger:"\\cosec",arguments:"implicit",parse:le},{name:"Cosh",trigger:"\\cosh",arguments:"implicit",parse:le},{name:"Cot",trigger:"\\cot",arguments:"implicit",parse:le},{name:"Cot",trigger:"\\cotg",arguments:"implicit",parse:le},{name:"Coth",trigger:"\\coth",arguments:"implicit",parse:le},{name:"Csc",trigger:"\\csc",arguments:"implicit",parse:le},{name:"Cot",trigger:"\\ctg",arguments:"implicit",parse:le},{name:"Coth",trigger:"\\cth",arguments:"implicit",parse:le},{name:"Sec",trigger:"\\sec",arguments:"implicit",parse:le},{name:"Sinh",trigger:"\\sinh",arguments:"implicit",parse:le},{name:"Sinh",trigger:"\\sh",arguments:"implicit",parse:le},{name:"Tan",trigger:"\\tan",arguments:"implicit",parse:le},{name:"Tan",trigger:"\\tg",arguments:"implicit",parse:le},{name:"Tanh",trigger:"\\tanh",arguments:"implicit",parse:le},{name:"Tanh",trigger:"\\th",arguments:"implicit",parse:le},{name:"Cos",trigger:"\\cos",arguments:"implicit",parse:le},{name:"Sin",trigger:"\\sin",arguments:"implicit",parse:le}]},he={precision:15,positiveInfinity:"\\infty",negativeInfinity:"-\\infty",notANumber:"\\operatorname{NaN}",decimalMarker:".",groupSeparator:",",exponentProduct:"\\cdot",beginExponentMarker:"10^{",endExponentMarker:"}",notation:"auto",truncationMarker:"\\ldots",beginRepeatingDigits:"\\overline{",endRepeatingDigits:"}",imaginaryNumber:"\\imaginaryI"},ge={invisibleOperator:q,skipSpace:!0,parseArgumentsOfUnknownLatexCommands:!0,parseNumbers:!0,promoteUnknownSymbols:/^[a-zA-Z]$/,promoteUnknownFunctions:/^[fg]$/,ignoreCommands:["\\displaystyle","\\!","\\:","\\enskip","\\quad","\\,","\\;","\\enspace","\\qquad","\\selectfont","\\tiny","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"],idempotentCommands:["\\left","\\right","\\mleft","\\mright","\\middle","\\bigl","\\bigm","\\bigr","\\Bigl","\\Bigm","\\Bigr","\\biggl","\\biggm","\\biggr","\\Biggl","\\Biggm","\\Biggr"],invisiblePlusOperator:b,preserveLatex:!1},pe={invisibleMultiply:"",invisiblePlus:"",multiply:"\\times"};function fe(e,i){var t;let r=e;for(let e=0;e<i.length;e++){let n=null!==(t=i[e])&&void 0!==t?t:"";if(/[a-zA-Z*]/.test(n[0])){const i=r.match(new RegExp("(.*)#"+Number(e+1).toString()));i&&/\\[a-zA-Z*]+/.test(i[1])&&(n=" "+n)}r=r.replace("#"+Number(e+1).toString(),n)}return r}class me{constructor(e,i,t,r){let n;this.index=0,this.options={...he,...ge,...i},this.tokens=e,this.onError=e=>r({...e,before:this.latexBefore(),after:this.latexAfter()}),this.dictionary=t,this.invisibleOperatorPrecedence=0,this.options.invisibleOperator&&(n=this.dictionary.name.get(this.options.invisibleOperator),void 0===n?r({code:"unknown-operator",arg:"invisible operator "+this.options.invisibleOperator}):void 0===n.precedence?r({code:"expected-operator",arg:"invisible operator "+this.options.invisibleOperator}):this.invisibleOperatorPrecedence=n.precedence)}clone(e,i){return new me(this.tokens.slice(e,i),this.options,this.dictionary,this.onError)}balancedClone(e,i,t=!0){if(!this.matchAll(e))return t||this.onError({code:"syntax-error",arg:"Expected "+u(e)}),null;const r=this.index;let n=r,s=1;for(;!this.atEnd&&0!==s;)this.skipSpace(),n=this.index,this.matchAll(i)?s-=1:this.matchAll(e)?s+=1:this.next();return 0!==s?(t||this.onError({code:"unbalanced-symbols",arg:u(e)+u(i)}),this.index=r,null):this.clone(r,n)}get atEnd(){return this.index>=this.tokens.length}get peek(){return this.tokens[this.index]}latex(e,i){return u(this.tokens.slice(e,i))}latexAhead(e){return u(this.tokens.slice(this.index,this.index+e))}latexBefore(){return this.latex(0,this.index)}latexAfter(){return this.latex(this.index)}lookAhead(){let e=Math.min(this.dictionary.lookahead,this.tokens.length-this.index);const i=[];for(;e>0;)i[e]=this.latexAhead(e--);return i}peekDefinition(e){let i;i="operator"===e?this.lookAhead().map(((e,i)=>{var t,r,n,s,a;return null!==(s=null!==(r=null===(t=this.dictionary.infix[i])||void 0===t?void 0:t.get(e))&&void 0!==r?r:null===(n=this.dictionary.postfix[i])||void 0===n?void 0:n.get(e))&&void 0!==s?s:null===(a=this.dictionary.prefix[i])||void 0===a?void 0:a.get(e)})):this.lookAhead().map(((i,t)=>{var r;return null===(r=this.dictionary[e][t])||void 0===r?void 0:r.get(i)}));for(let e=i.length;e>0;e--)if(void 0!==i[e])return[i[e],e];return[null,0]}next(){return this.tokens[this.index++]}skipSpace(){if(!this.atEnd&&"<{>"===this.peek&&"<}>"===this.tokens[this.index+1])return this.index+=2,this.skipSpace(),!0;let e=!1;for(;!this.atEnd&&(this.options.ignoreCommands.includes(this.peek)||this.options.idempotentCommands.includes(this.peek));)this.index+=1,this.skipSpace(),e=!0;if(!this.options.skipSpace)return!1;for(;this.match("<space>");)e=!0;return e&&this.skipSpace(),e}match(e){return this.tokens[this.index]===e&&(this.index++,!0)}matchAll(e){let i=!0;"string"==typeof e&&(e=[e]);let t=0;do{i=this.tokens[this.index+t]===e[t++]}while(i&&t<e.length);return i&&(this.index+=t),i}matchAny(e){return e.includes(this.tokens[this.index])?this.tokens[this.index++]:""}matchWhile(e){const i=[];for(;e.includes(this.tokens[this.index]);)i.push(this.tokens[this.index++]);return i}matchSign(){let e=!1,i=!1;for(;!i;)this.skipSpace()?i=!1:this.match("-")?(e=!e,i=!1):i=!this.match("+");return e?"-":"+"}matchDecimalDigits(){let e="",i=!1;for(;!i;)if(e+=this.matchWhile(["0","1","2","3","4","5","6","7","8","9"]).join(""),i=!0,this.options.groupSeparator){const e=this.index;this.match(this.options.groupSeparator)&&(/[0-9]/.test(this.peek)?i=!1:this.index=e)}return e}matchSignedInteger(){const e=this.index,i=this.matchSign(),t=this.matchDecimalDigits();return t?("-"===i?"-":"")+t:(this.index=e,"")}matchExponent(){const e=this.index;let i="";if(this.matchAny(["e","E","d","D"])){const e=this.matchSignedInteger();e&&(i="e"+e)}if(i)return i;if(this.match("\\times")&&(this.skipSpace(),this.match("1")&&this.match("0")&&this.match("^"))){if(/[0-9]/.test(this.peek))return"e"+this.next();if(this.match("<{>")){this.skipSpace();const e=this.matchSignedInteger();if(this.skipSpace(),this.match("<}>")&&e)return"e"+e}}return this.index=e,""}matchNumber(){var e,i;if(!this.options.parseNumbers)return"";const t=this.index,r=this.matchSign();let n=this.matchDecimalDigits();if(!n)return this.index=t,"";n=("-"===r?"-":"")+n;let s=!1,a=!1;this.match(null!==(e=this.options.decimalMarker)&&void 0!==e?e:"")&&(s=!0,n+="."+(null!==(i=this.matchDecimalDigits())&&void 0!==i?i:"0"));const o=this.matchExponent();return o&&(a=!0),n?n.length+o.length>12?s||a?n+o+"d":n+"n":n+o:(this.index=t,"")}matchOperator(e,i=null,t=0){const[r,n]=this.peekDefinition(e);if(null===r)return null;if("function"==typeof r.parse){let e=null;return[i,e]=r.parse(i,this,t),null===e?null:this.applyInvisibleOperator(i,e)}let s=r.precedence;if(void 0===s||s<t)return null;s+="left"===r.associativity?1:0,this.index+=n;const a=this.matchExpression(s);return this.applyInvisibleOperator(...this.applyOperator(r.parse,i,a))}matchArguments(e){if(!e)return null;const i=this.index;let t=null;const r=this.matchMatchfixOperator();if("group"===e&&B(r)===p)t=j(r);else if("implicit"===e)if(B(r)===p)t=j(r);else if(null!==r)t=[r];else{const e=this.matchPrimary();null!==e&&(t=[e])}else this.index=i;return t}matchMatchfixOperator(){const[e]=this.peekDefinition("matchfix");if(null===e)return null;if("function"==typeof e.parse)return this.applyInvisibleOperator(...e.parse(null,this,0));const i="object"==typeof e.trigger?e.trigger.matchfix:e.trigger;if(!i||!e.closeFence||!e.parse)return null;const t=this.matchBalancedExpression(i,e.closeFence,this.onError);return t?[e.parse,t]:[e.parse]}matchDefinition(e){const[i,t]=this.peekDefinition(e);if("function"==typeof(null==i?void 0:i.parse)){const[,e]=i.parse(null,this,0);return[i,e]}return this.index+=t,[i,null]}matchSymbol(){var e,i,t,r;const[n,s]=this.matchDefinition("symbol");if(null!==s)return s;if(null===n){if(null===(e=this.options.promoteUnknownFunctions)||void 0===e?void 0:e.test(this.peek)){const e=this.next(),i=this.matchMatchfixOperator();return null===i?e:B(i)!==p?null:[e,...j(i)]}return(null===(i=this.options.promoteUnknownSymbols)||void 0===i?void 0:i.test(this.peek))?this.next():this.matchUnknownLatexCommand()}const a=[],o=[];let l,u=null!==(t=n.optionalLatexArg)&&void 0!==t?t:0;for(;u>0;)l=this.matchOptionalLatexArgument(),null!==l&&o.push(l),u--;for(u=null!==(r=n.requiredLatexArg)&&void 0!==r?r:0;u>0;)l=this.matchRequiredLatexArgument(),null===l&&this.onError({code:"expected-argument"}),null!==l&&a.push(l),u--;const c=this.matchArguments(n.arguments);return null===c?0===a.length&&0===o.length?n.parse:[n.parse,...a,...o]:[n.parse,...a,...c,...o]}matchOptionalLatexArgument(){return this.skipSpace(),this.matchBalancedExpression("[","]")}matchRequiredLatexArgument(){return this.skipSpace(),this.matchBalancedExpression("<{>","<}>")||(/^[0-9]$/.test(this.peek)?parseFloat(this.next()):/^[^\\#]$/.test(this.peek)?this.next():this.matchSymbol())}matchSupsub(e){if(null===e)return null;let i=null;return this.skipSpace(),[["^","superfix"],["_","subfix"]].forEach((t=>{var r,n,s;if(null!==i)return;const[a,o]=t,l=this.index;if(!this.match(a))return;const u=this.index;let c,h=0;if(this.match("<{>")?([c,h]=this.peekDefinition(o),c?"function"==typeof c.parse?i=c.parse(e,this,0)[1]:(this.index+=h,this.match("<}>")?i=[null!==(r=c.parse)&&void 0!==r?r:c.name,e]:this.index=u):this.index=u):([c,h]=this.peekDefinition(o),c?"function"==typeof c.parse?i=c.parse(e,this,0)[1]:(this.index+=h,i=[null!==(n=c.parse)&&void 0!==n?n:c.name,e]):this.index=u),null===i&&(c=null===(s=this.dictionary.infix[1])||void 0===s?void 0:s.get(a),"function"==typeof(null==c?void 0:c.parse)?(this.index=l,i=c.parse(e,this,0)[1]):"string"==typeof(null==c?void 0:c.parse)?([e,i]=this.applyOperator(c.parse,e,this.matchRequiredLatexArgument()),i=this.applyInvisibleOperator(e,i)):i=this.applyInvisibleOperator(e,a)),null!==i){const e=this.matchArguments(null==c?void 0:c.arguments);null!==e&&(i=[i,...e])}})),i}matchPostfix(e){if(null===e)return null;const[i,t]=this.peekDefinition("postfix");return null==i?null:"function"==typeof i.parse?([,e]=i.parse(e,this,0),null===e?null:e):(this.index+=t,[i.parse,e])}matchString(){let e="",i=this.atEnd;for(;!i;){if(this.match("<space>"))e+=" ";else{const t=this.peek;"]"===t?i=!0:/^<({|}|\$|\$\$|space)>$/.test(t)?"\\"===t[0]?(this.onError({code:"unexpected-command"}),e+=this.next()):i=!0:e+=this.next()}i=i||this.atEnd}return e}matchEnvironmentName(e,i){if(this.match(e)){const e=this.index;if(this.match("<{>")){const e=this.matchString();if(this.match("<}>")&&e===i)return!0}this.index=e}return!1}matchTabular(){const e=["list"];let i=["list"],t=null,r=!1;for(;!this.atEnd&&!r;)if(this.match("&"))i.push(null!=t?t:v),t=null;else if(this.match("\\\\")||this.match("\\cr"))this.skipSpace(),this.matchOptionalLatexArgument(),null!==t&&i.push(t),e.push(i),i=["list"],t=null;else{const e=this.matchExpression();null===e&&(r=!0),t=null!==t?this.applyInvisibleOperator(t,e):e}return i.length>1&&e.push(i),e}matchEnvironment(){var e;if(this.match("\\begin")&&this.match("<{>")){const i=this.matchString();if(this.match("<}>")){const t=this.index;let r=this.index,n=1;for(;!this.atEnd&&0!==n;)r=this.index,this.matchEnvironmentName("\\begin",i)?n+=1:this.matchEnvironmentName("\\end",i)?n-=1:this.next();const s=this.dictionary.environment.get(i);return"function"==typeof(null==s?void 0:s.parse)?s.parse(null,this.clone(t,r),0)[1]:null!==(e=null==s?void 0:s.parse)&&void 0!==e?e:null}}return null}applyOperator(e,i,t){var r,n,s,a;const o=this.dictionary.name.get(e);if(void 0===o)return this.onError({code:"unknown-operator"}),[i,t];if(void 0!==(null===(r=o.trigger)||void 0===r?void 0:r.prefix)&&null===i&&null!==t)return[null,[o.name,t]];if(void 0!==(null===(n=o.trigger)||void 0===n?void 0:n.postfix)&&null!==i)return[null,[o.name,i]];if(void 0!==(null===(s=o.trigger)||void 0===s?void 0:s.matchfix)||void 0!==(null===(a=o.trigger)||void 0===a?void 0:a.infix)){if("non"===o.associativity)return[null,[e,null!=i?i:"Missing",null!=t?t:"Missing"]];if(B(i)===e){if("both"===o.associativity){if(B(t)===e){if(Array.isArray(i))return[null,i.concat(j(t))];if(F(i))return[null,i.fn.concat(j(t))]}else t&&(Array.isArray(i)&&i.push(t),F(i)&&i.fn.push(t));return[null,i]}return"left"===o.associativity?[null,[e,null!=i?i:d,null!=t?t:d]]:Array.isArray(i)?[null,[e,i[1],[e,i[2],null!=t?t:d]]]:(F(i)&&(i.fn[2]=[e,i.fn[2],null!=t?t:d]),[null,i])}return B(t)===e?"both"===o.associativity?(Array.isArray(t)&&i&&t.splice(1,0,i),F(t)&&i&&t.fn.splice(1,0,i),[null,t]):"right"===o.associativity?[null,[e,null!=i?i:d,null!=t?t:d]]:Array.isArray(t)?[null,[e,t[1],[e,t[2],null!=i?i:d]]]:(F(t)&&(t.fn[2]=[e,t.fn[2],null!=i?i:d]),[null,t]):[null,[e,null!=i?i:"Missing",null!=t?t:"Missing"]]}return[i,null]}applyInvisibleOperator(e,i){if(null===e)return i;if(null===i)return e;if(this.options.invisiblePlusOperator&&("number"==typeof e||D(e))&&function(e){var i,t;const r=_(e);if(null!==r&&["ThreeQuarter","TwoThird","Half","Third","Quarter"].includes(r))return!0;if(B(e)!==N)return!1;const n=null!==(i=T(H(e,1)))&&void 0!==i?i:NaN,s=null!==(t=T(H(e,2)))&&void 0!==t?t:NaN;return Number.isInteger(n)&&Number.isInteger(s)}(i))return[e,i]=this.applyOperator(this.options.invisiblePlusOperator,e,i),null===e?i:null;if(this.options.invisibleOperator)return[e,i]=this.applyOperator(this.options.invisibleOperator,e,i),null===e?i:null;let t=[f];return B(e)===f?t=t.concat(j(e)):t.push(e),null!==i&&(B(i)===f?t=t.concat(j(i)):t.push(i)),this.options.invisibleOperator&&this.onError({code:"unexpected-sequence"}),t}matchUnknownLatexCommand(){var e;const i=this.peek;if(!i||"\\"!==i[0])return null;if(this.next(),"\\operatorname"===i){if(this.skipSpace(),"<{>"===this.peek){let e="";for(this.next();!this.atEnd&&"<}>"!==this.tokens[this.index];)e+=this.next();return e}return null!==(e=this.next())&&void 0!==e?e:d}const t=[],r=[];let n=!1;do{n=!0;let e=this.matchOptionalLatexArgument();null!==e&&(t.push(e),n=!1),this.skipSpace(),"<{>"===this.peek&&(e=this.matchRequiredLatexArgument(),null!==e&&(r.push(e),n=!1))}while(!n);return t.length>0||r.length>0?[i,...r,...t]:i}matchPrimary(e){let i=null;const t=this.index,r=this.matchNumber();r&&(i={num:r}),null===i&&(i=this.matchMatchfixOperator()),null===i&&(i=this.matchEnvironment()),null===i&&(i=this.matchSymbol());let n=null;do{n=this.matchSupsub(i),i=null!=n?n:i}while(null!==n);let s=null;do{s=this.matchPostfix(i),i=null!=s?s:i}while(null!==s);return this.decorate(i,t)}matchBalancedExpression(e,i,t){const r=this.balancedClone(e,i);if(!r)return null==t||t({code:"unbalanced-symbols",arg:u(e)+u(i)}),null;const n=r.matchExpression();return r.atEnd||null==t||t({code:"unbalanced-symbols",arg:u(e)+u(i)}),n}matchExpression(e=0){let i=null;const t=this.index;this.skipSpace(),i=this.matchPrimary(e),null===i&&(i=this.matchOperator("prefix"));let r=!1;for(;!this.atEnd&&!r;){this.skipSpace();let t=this.matchOperator("infix",i,e);if(null===t&&null!==i){const[e]=this.peekDefinition("operator");if(null===e){const e=this.matchExpression(this.invisibleOperatorPrecedence);null!==e&&(t=this.applyInvisibleOperator(i,e))}}null!==t?i=t:r=!0}return this.decorate(i,t)}decorate(e,i){if(null===e)return null;if(this.options.preserveLatex){const t=this.latex(i,this.index);Array.isArray(e)?e={latex:t,fn:e}:"number"==typeof e?e={latex:t,num:Number(e).toString()}:"string"==typeof e?e={latex:t,sym:e}:"object"==typeof e&&null!==e&&(e.latex=t)}return e}}function de(e,i){const t=e.length,r=e;e=e.slice(0,-1);for(let t=0;t<e.length-16;t++){const r=e.substr(0,t);for(let n=0;n<17;n++){const s=e.substr(t,n+1),a=Math.floor((e.length-r.length)/s.length);if(a>1&&(r+s.repeat(a+1)).startsWith(e))return"0"===s?r.replace(/(\d{3})/g,"$1"+i.groupSeparator):r.replace(/(\d{3})/g,"$1"+i.groupSeparator)+i.beginRepeatingDigits+s+i.endRepeatingDigits}}const n=t>i.precision-1;return e=r,n&&(e=e.substr(0,i.precision-1)),i.groupSeparator&&(e=e.replace(/(\d{3})/g,"$1"+i.groupSeparator)).endsWith(i.groupSeparator)&&(e=e.slice(0,-i.groupSeparator.length)),n?e+i.truncationMarker:e}function ve(e,i){var t;return e?i.beginExponentMarker?i.beginExponentMarker+e+(null!==(t=i.endExponentMarker)&&void 0!==t?t:""):"10^{"+e+"}":""}class xe{constructor(e,i,t){this.level=-1,this.options=e,e.invisibleMultiply&&(/#1/.test(e.invisibleMultiply)&&/#2/.test(e.invisibleMultiply)||t({code:"expected-argument",arg:"invisibleMultiply"})),this.onError=t,this.dictionary=i}wrap(e,i){if(null===e)return"";if(void 0===i)return"("+this.serialize(e)+")";if("number"==typeof e||D(e)||"string"==typeof e||P(e))return this.serialize(e);const t=B(e);if(t&&t!==p){const r=this.dictionary.name.get(t);if(r&&void 0!==r.precedence&&r.precedence<i)return this.wrapString(this.serialize(e),(this.level,"paren"))}return this.serialize(e)}wrapShort(e){if(null===e)return"";const i=this.serialize(e);return B(e)===p||"number"==typeof e||D(e)||/(^(.|\\[a-zA-Z*]+))$/.test(i)?i:this.wrapString(i,(this.level,"paren"))}wrapString(e,i){return"none"===i?e:"("+e+")"}serializeSymbol(e,i){const t=$(e);if(!t){if("string"==typeof(null==i?void 0:i.serialize))return i.serialize;const t=_(e);if(null===t)return"";switch(function(e,i){const t=_(e);return null===t?"asis":t.length>1?"upright":"asis"}(e,this.level)){case"upright":return"\\operatorname{"+t+"}";default:return t}}const r=j(e);if(!i){if("string"==typeof t&&t.length>0&&"\\"===t[0]){let e=t;for(const i of r)e+="{"+this.serialize(i)+"}";return e}return`${this.serialize(t)}(${r.map((e=>this.serialize(e))).join(", ")})`}if(i.requiredLatexArg>0){let e="",t="",n=0;for(;n<i.requiredLatexArg;)t+="{"+this.serialize(r[n++])+"}";for(;n<Math.min(r.length,i.optionalLatexArg+i.requiredLatexArg);){const i=this.serialize(r[1+n++]);i&&(e+="["+i+"]")}return i.serialize+(e+t)}return this.level,i.serialize+this.serialize([p,...r])}serializeDictionary(e){return`\\left[\\begin{array}{lll}${Object.keys(e).map((i=>`\\textbf{${i}} & \\rightarrow & ${this.serialize(e[i])}`)).join("\\\\")}\\end{array}\\right]`}serialize(e){if(null===e)return"";this.level+=1;const i=(()=>{var i,t,r,n;const s=function(e,i){var t,r;let n;if("number"==typeof e)n=e;else{if(!D(e))return"";n=e.num}if(n===1/0||"Infinity"===n||"+Infinity"===n)return i.positiveInfinity;if(n===-1/0||"-Infinity"===n)return i.negativeInfinity;if("NaN"===n||"number"==typeof n&&Number.isNaN(n))return i.notANumber;if("number"==typeof n)return"engineering"===i.notation?function(e,i){if(0===e)return"0";const t=Math.abs(e);let r=Math.round(Math.log10(t));r-=r%3,t<1e3&&(r=0);const n=t/Math.pow(10,r);let s="";const a=n.toString().match(/^(.*)\.(.*)$/);(null==a?void 0:a[1])&&a[2]&&(s=a[1]+i.decimalMarker+a[2]),i.groupSeparator&&(s=de(n.toExponential(),i));let o="";return 0!==r&&(o=ve(r.toString(),i)),(e<0?"-":"")+s+o}(n,i):function(e,i){let t,r=e.match(/^(.*)[e|E]([-+]?[0-9]+)$/i);(null==r?void 0:r[1])&&r[2]&&(t=ve(r[2],i),t&&(t=i.exponentProduct+t));let n=e,s="";return r=(t?r[1]:e).match(/^(.*)\.(.*)$/),(null==r?void 0:r[1])&&r[2]&&(n=r[1],s=r[2]),i.groupSeparator&&(n=n.replace(/\B(?=(\d{3})+(?!\d))/g,i.groupSeparator),s=de(s,i)),s&&(s=i.decimalMarker+s),n+s+(null!=t?t:"")}(n.toString(),i);/[a-zA-Z]$/.test(n)&&(n=n.slice(0,-1));let s="";for("-"===n[0]?(s="-",n=n.substr(1)):"+"===n[0]&&(n=n.substr(1));"0"===n[0];)n=n.substr(1);if(0===n.length)return s+"0";"."===n[0]&&(n="0"+n);let a="";if(n.indexOf(".")>=0){const e=n.match(/(\d*)\.(\d*)([e|E]([-+]?[0-9]*))?/);if(!e)return"";const r=e[1],o=e[2];if(a=null!==(t=e[4])&&void 0!==t?t:"","0"===r){let e=0;for(;"0"===o[e]&&e<o.length;)e+=1;let t="";if(e<=4)t="0"+i.decimalMarker,t+=o.substr(0,e),t+=de(n.substr(t.length),i);else if(e+1>=i.precision)t="0",s="";else{t=n[e];const r=de(n.substr(e+1),i);r&&(t+=i.decimalMarker+r)}"0"!==t&&(!(n.length-1>i.precision)||i.endRepeatingDigits&&t.endsWith(i.endRepeatingDigits)||!i.truncationMarker||t.endsWith(i.truncationMarker)||(t+=i.truncationMarker),e>4&&(t+=i.exponentProduct+ve((1-e).toString(),i))),n=t}else{n=r.replace(/\B(?=(\d{3})+(?!\d))/g,i.groupSeparator);const e=de(o,i);e&&(n+=i.decimalMarker+e)}}else if(n.length>i.precision){const e=n.length;let t=n[0];const r=de(n.substr(1),i);r&&(t+=i.decimalMarker+r,i.truncationMarker&&!t.endsWith(i.truncationMarker)&&i.endRepeatingDigits&&!t.endsWith(i.endRepeatingDigits)&&(t+=i.truncationMarker)),"1"!==t?t+=i.exponentProduct:t="",n=t+ve((e-1).toString(),i)}else{const e=n.match(/([0-9]*)\.?([0-9]*)([e|E]([-+]?[0-9]+))?/);e&&(n=e[1],e[2]&&(n+=i.decimalMarker+e[2]),a=null!==(r=e[4])&&void 0!==r?r:""),n=n.replace(/\B(?=(\d{3})+(?!\d))/g,i.groupSeparator)}const o=ve(a,i);return s+n+(o?i.exponentProduct+o:"")}(e,this.options);if(s)return s;const a=C(e);if(null!==a)return`\\text{${a}}`;const o=_(e);if(null!==o)return this.serializeSymbol(e,this.dictionary.name.get(o));const c=W(e);if(null!==c)return this.serializeDictionary(c);const h=B(e);if(h){if("\\"===h[0]){const i=j(e);return 0===i.length?h:h+"{"+i.map((e=>this.serialize(e))).filter((e=>Boolean(e))).join("}{")+"}"}const s=this.dictionary.name.get(h);if(s){let a="";return"function"==typeof s.serialize&&(a=s.serialize(this,e)),a||void 0===s.precedence&&!(null===(i=s.trigger)||void 0===i?void 0:i.superfix)&&!(null===(t=s.trigger)||void 0===t?void 0:t.subfix)||(a=function(e,i,t){var r,n,s,a,o;let l="";const u=G(i),c=B(i);if((null===(r=t.trigger)||void 0===r?void 0:r.superfix)||(null===(n=t.trigger)||void 0===n?void 0:n.subfix))return 1!==u&&e.onError({code:"operator-requires-one-operand",arg:e.serializeSymbol(c)}),fe(t.serialize,[e.serialize(H(i,1))]);if(null===(s=t.trigger)||void 0===s?void 0:s.postfix)return 1!==u&&e.onError({code:"postfix-operator-requires-one-operand",arg:e.serializeSymbol(c)}),fe(t.serialize,[e.wrap(H(i,1),t.precedence)]);if(null===(a=t.trigger)||void 0===a?void 0:a.prefix)return 1!==u&&e.onError({code:"prefix-operator-requires-one-operand",arg:e.serializeSymbol(c)}),fe(t.serialize,[e.wrap(H(i,1),t.precedence+1)]);if(null===(o=t.trigger)||void 0===o?void 0:o.infix){l=e.wrap(H(i,1),t.precedence);for(let r=2;r<u+1;r++){const n=H(i,r);null!==n&&(l=fe(t.serialize,[l,e.wrap(n,t.precedence)]))}}return l}(this,e,s)),!a&&(null===(r=s.trigger)||void 0===r?void 0:r.matchfix)&&(a=function(e,i,t){var r,n;let s=[];if("string"==typeof(null===(r=t.trigger)||void 0===r?void 0:r.matchfix)?s.push(null===(n=t.trigger)||void 0===n?void 0:n.matchfix):t.trigger&&Array.isArray(t.trigger.matchfix)&&(s=[...t.trigger.matchfix]),G(i)>=1){let r="";for(const n of j(i))n&&(s.push(r),s.push(e.serialize(n)),r=t.separator)}return s.push(u(t.closeFence)),l(s)}(this,e,s)),!a&&(null===(n=s.trigger)||void 0===n?void 0:n.symbol)&&(a=this.serializeSymbol(e,s)),a}}if(Array.isArray(e)||F(e))return this.serializeSymbol(e);this.onError({code:"syntax-error",arg:JSON.stringify(e)})})();return this.level-=1,null!=i?i:""}}class ye{constructor(e){var i,t;this.onError=null!==(i=null==e?void 0:e.onError)&&void 0!==i?i:e=>{"undefined"!=typeof window&&(!e.before||e.after)};const r={...null!=e?e:{}};delete r.dictionary,delete r.onError,this.options={...he,...pe,...ge,...r},this.dictionary=function(e,i){var t,r,n,s,a,o,l,u,c,h,g,p,f,m,d;const v={lookahead:1,name:new Map,prefix:[],infix:[],postfix:[],matchfix:[],superfix:[],subfix:[],symbol:[],environment:new Map};for(const x of e)void 0===x.parse&&(x.parse=x.name),"string"==typeof x.trigger&&(x.trigger={symbol:x.trigger}),"string"==typeof x.serialize&&void 0!==(null===(t=x.trigger)||void 0===t?void 0:t.symbol)&&/#[0-9]/.test(x.serialize)&&i({code:"unexpected-argument",arg:x.name}),void 0===x.serialize&&(void 0!==(null===(r=x.trigger)||void 0===r?void 0:r.postfix)?x.serialize="#1"+ue(x.trigger.postfix):void 0!==(null===(n=x.trigger)||void 0===n?void 0:n.prefix)?x.serialize=ue(x.trigger.prefix)+"#1":void 0!==(null===(s=x.trigger)||void 0===s?void 0:s.infix)?x.serialize="#1"+ue(x.trigger.infix)+"#2":void 0!==(null===(a=x.trigger)||void 0===a?void 0:a.symbol)?x.serialize=ue(x.trigger.symbol):void 0!==(null===(o=x.trigger)||void 0===o?void 0:o.superfix)?x.serialize="#1^{"+ue(null===(l=x.trigger)||void 0===l?void 0:l.superfix)+"}":void 0!==(null===(u=x.trigger)||void 0===u?void 0:u.subfix)?x.serialize="#1_{"+ue(null===(c=x.trigger)||void 0===c?void 0:c.subfix)+"}":x.serialize=""),void 0!==(null===(h=x.trigger)||void 0===h?void 0:h.infix)&&(void 0===x.precedence&&i({code:"syntax-error",arg:"Infix operators require a precedence"}),x.associativity||(x.associativity="non")),void 0!==(null===(g=x.trigger)||void 0===g?void 0:g.symbol)&&(x.arguments=null!==(p=x.arguments)&&void 0!==p?p:"",x.optionalLatexArg=null!==(f=x.optionalLatexArg)&&void 0!==f?f:0,x.requiredLatexArg=null!==(m=x.requiredLatexArg)&&void 0!==m?m:0),void 0!==(null===(d=x.trigger)||void 0===d?void 0:d.matchfix)&&("function"===x.parse||x.closeFence||i({code:"syntax-error",arg:"Matchfix operators require a close fence or a custom parse function"})),void 0!==x.trigger&&(["infix","prefix","postfix","symbol","matchfix","superfix","subfix"].forEach((e=>{if(x.trigger[e]){const t=(i=x.trigger[e],Array.isArray(i)?i.length:1);v.lookahead=Math.max(v.lookahead,t),void 0===v[e][t]&&(v[e][t]=new Map),v[e][t].set(ue(x.trigger[e]),x)}var i})),void 0!==x.trigger.environment&&v.environment.set(x.trigger.environment,x)),void 0!==x.name?v.name.set(ue(x.name),x):"string"==typeof x.parse&&v.name.set(x.parse,x),void 0!==x.trigger||x.name||i({code:"syntax-error",arg:"Need at least a trigger or a name"});return v}(null!==(t=null==e?void 0:e.dictionary)&&void 0!==t?t:ye.getDictionary(),this.onError)}static getDictionary(e="all"){if("all"===e){let e=[];for(const i of Object.keys(ce))e=[...e,...ce[i]];return e}return ce[e]?[...ce[e]]:[]}parse(e){var i;const t=new me(o(e,[]),this.options,this.dictionary,this.onError),r=t.matchExpression();return t.atEnd||null===(i=this.onError)||void 0===i||i.call(this,{code:"syntax-error"}),null!=r?r:""}serialize(e){return new xe(this.options,this.dictionary,this.onError).serialize(e)}}e.LatexSyntax=ye,e.parse=function(e,i){return new ye(i).parse(e)},e.serialize=function(e,i){return new ye(i).serialize(e)},e.version="0.4.2",Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
1
|
+
/** MathJSON 0.5.0 */
|
|
2
|
+
var global,factory;global=this,factory=function(n){function t(n){return null!==n&&"object"==typeof n&&"sym"in n}function r(n){return null!==n&&"object"==typeof n&&"fn"in n}function e(n){return null===n?null:Array.isArray(n)?n[0]:r(n)?n.fn[0]:null}function l(n){return Array.isArray(n)?n.slice(1):r(n)?n.fn.slice(1):[]}function i(n){return"object"==typeof n&&"dict"in n?n.dict:null}n.applyRecursively=function(n,t){const r=e(n);if(null!==r)return[t(r),...l(n).map(t)];const o=i(n);if(null!==o){const n=Object.keys(o),r={};for(const e of n)r[e]=t(o[e]);return{dict:r}}return t(n)},n.asValidJSONNumber=function(n){if("string"==typeof n){const t=Number(n);if("+"===n[0]&&(n=n.slice(1)),t.toString()===n)return isNaN(t)||!isFinite(t)?t.toString():t}return n},n.getDictionary=i,n.getStringValue=function(n){return null===n?null:"object"==typeof n&&"str"in n?n.str:"string"!=typeof n||n.length<2||"'"!==n[0]||"'"!==n[n.length-1]?null:n.substring(1,n.length-1)},n.head=e,n.headName=function(n){const t=e(n);return"string"==typeof t?t:""},n.isAtomic=function(n){return null===n||!Array.isArray(n)&&("object"!=typeof n||!("fn"in n||"dic"in n))},n.isDictionaryObject=function(n){return null!==n&&"object"==typeof n&&"dict"in n},n.isFunctionObject=r,n.isStringObject=function(n){return null!==n&&"object"==typeof n&&"str"in n},n.isSymbolObject=t,n.mapArgs=function(n,t){let e=null;if(Array.isArray(n)&&(e=n),r(n)&&(e=n.fn),null===e)return[];let l=1;const i=[];for(;l<e.length;)i.push(t(e[l])),l+=1;return i},n.nops=function(n){return Array.isArray(n)?Math.max(0,n.length-1):r(n)?Math.max(0,n.fn.length-1):0},n.op=function(n,t){var e,l;return null===n?null:Array.isArray(n)?null!==(e=n[t])&&void 0!==e?e:null:r(n)&&null!==(l=n.fn[t])&&void 0!==l?l:null},n.symbol=function(n){return null===n?null:"string"==typeof n?n.length>=2&&"'"===n[0]&&"'"===n[n.length-1]?null:n:t(n)?n.sym:null},n.tail=l,n.version="0.5.0",Object.defineProperty(n,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?factory(exports):"function"==typeof define&&define.amd?define(["exports"],factory):factory((global="undefined"!=typeof globalThis?globalThis:global||self).MathJson={});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/* 0.5.0 */
|
|
2
|
+
export declare type SignalCode = RuntimeSignalCode | ('invalid-name' | 'expected-predicate' | 'expected-symbol' | 'operator-requires-one-operand' | 'postfix-operator-requires-one-operand' | 'prefix-operator-requires-one-operand' | 'unbalanced-symbols' | 'expected-argument' | 'unexpected-command' | 'cyclic-definition' | 'invalid-supersets' | 'expected-supersets' | 'unknown-domain' | 'duplicate-wikidata' | 'invalid-dictionary-entry' | 'syntax-error');
|
|
3
|
+
export declare type SignalMessage = SignalCode | [SignalCode, ...any[]];
|
|
4
|
+
export declare type SignalOrigin = {
|
|
5
|
+
url?: string;
|
|
6
|
+
source?: string;
|
|
7
|
+
offset?: number;
|
|
8
|
+
line?: number;
|
|
9
|
+
column?: number;
|
|
10
|
+
around?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare type Signal = {
|
|
13
|
+
severity?: 'warning' | 'error';
|
|
14
|
+
/** An error/warning code or, a code with one or more arguments specific to
|
|
15
|
+
* the signal code.
|
|
16
|
+
*/
|
|
17
|
+
message: SignalMessage;
|
|
18
|
+
/** If applicable, the head of the function about which the
|
|
19
|
+
* signal was raised
|
|
20
|
+
*/
|
|
21
|
+
head?: string;
|
|
22
|
+
/** Location where the signal was raised. */
|
|
23
|
+
origin?: SignalOrigin;
|
|
24
|
+
};
|
|
25
|
+
export declare type ErrorSignal = Signal & {
|
|
26
|
+
severity: 'error';
|
|
27
|
+
};
|
|
28
|
+
export declare class CortexError extends Error {
|
|
29
|
+
constructor(errorSignal: Signal);
|
|
30
|
+
toString(): string;
|
|
31
|
+
}
|
|
32
|
+
export declare type WarningSignal = Signal & {
|
|
33
|
+
severity: 'warning';
|
|
34
|
+
};
|
|
35
|
+
export declare type WarningSignalHandler = (warnings: WarningSignal[]) => void;
|
|
36
|
+
/**
|
|
37
|
+
* The error codes can be used in an `ErrorCode` expression:
|
|
38
|
+
*
|
|
39
|
+
* `["ErrorCode", "'syntax-error'", arg1]`
|
|
40
|
+
*
|
|
41
|
+
* It evaluates to a localized, human-readable string.
|
|
42
|
+
*
|
|
43
|
+
*
|
|
44
|
+
* * `unknown-symbol`: a symbol was encountered which does not have a
|
|
45
|
+
* definition.
|
|
46
|
+
*
|
|
47
|
+
* * `unknown-operator`: a presumed operator was encountered which does not
|
|
48
|
+
* have a definition.
|
|
49
|
+
*
|
|
50
|
+
* * `unknown-function`: a LaTeX command was encountered which does not
|
|
51
|
+
* have a definition.
|
|
52
|
+
*
|
|
53
|
+
* * `unexpected-command`: a LaTeX command was encountered when only a string
|
|
54
|
+
* was expected
|
|
55
|
+
*
|
|
56
|
+
* * `unexpected-superscript`: a superscript was encountered in an unexpected
|
|
57
|
+
* context, or no `powerFunction` was defined. By default, superscript can
|
|
58
|
+
* be applied to numbers, symbols or expressions, but not to operators (e.g.
|
|
59
|
+
* `2+^34`) or to punctuation.
|
|
60
|
+
*
|
|
61
|
+
* * `unexpected-subscript`: a subscript was encountered in an unexpected
|
|
62
|
+
* context or no 'subscriptFunction` was defined. By default, subscripts
|
|
63
|
+
* are not expected on numbers, operators or symbols. Some commands (e.g. `\sum`)
|
|
64
|
+
* do expected a subscript.
|
|
65
|
+
*
|
|
66
|
+
* * `unexpected-sequence`: some adjacent elements were encountered (for
|
|
67
|
+
* example `xy`), but no `invisibleOperator` is defined, therefore the elements
|
|
68
|
+
* can't be combined. The default `invisibleOperator` is `Multiply`, but you
|
|
69
|
+
* can also use `list`.
|
|
70
|
+
*
|
|
71
|
+
* * `expected-argument`: a LaTeX command that requires one or more argument
|
|
72
|
+
* was encountered without the required arguments.
|
|
73
|
+
*
|
|
74
|
+
* * `expected-operand`: an operator was encountered without its required
|
|
75
|
+
* operands.
|
|
76
|
+
*
|
|
77
|
+
* * `non-associative-operator`: an operator which is not associative was
|
|
78
|
+
* encountered in an associative context, for example: `a < b < c` (assuming
|
|
79
|
+
* `<` is defined as non-associative)
|
|
80
|
+
*
|
|
81
|
+
* * `postfix-operator-requires-one-operand`: a postfix operator which requires
|
|
82
|
+
* a single argument was encountered with no arguments or more than one argument
|
|
83
|
+
*
|
|
84
|
+
* * `prefix-operator-requires-one-operand`: a prefix operator which requires
|
|
85
|
+
* a single argument was encountered with no arguments or more than one argument
|
|
86
|
+
*
|
|
87
|
+
* * `base-out-of-range`: The base is expected to be between 2 and 36.
|
|
88
|
+
*
|
|
89
|
+
*/
|
|
90
|
+
export declare type ErrorCode = 'expected-argument' | 'unexpected-argument' | 'expected-operator' | 'expected-operand' | 'invalid-name' | 'invalid-dictionary-entry' | 'unknown-symbol' | 'unknown-operator' | 'unknown-function' | 'unknown-command' | 'unexpected-command' | 'unbalanced-symbols' | 'unexpected-superscript' | 'unexpected-subscript' | 'unexpected-sequence' | 'non-associative-operator' | 'function-has-too-many-arguments' | 'function-has-too-few-arguments' | 'operator-requires-one-operand' | 'infix-operator-requires-two-operands' | 'prefix-operator-requires-one-operand' | 'postfix-operator-requires-one-operand' | 'associative-function-has-too-few-arguments' | 'commutative-function-has-too-few-arguments' | 'threadable-function-has-too-few-arguments' | 'hold-first-function-has-too-few-arguments' | 'hold-rest-function-has-too-few-arguments' | 'base-out-of-range' | 'syntax-error';
|
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
/* 0.5.0 */
|
|
2
|
+
/**
|
|
3
|
+
* Add an assumption, in the form of a predicate, for example:
|
|
4
|
+
*
|
|
5
|
+
* - `x = 5`
|
|
6
|
+
* - `x ∈ ℕ`
|
|
7
|
+
* - `x > 3`
|
|
8
|
+
* - `x + y = 5`
|
|
9
|
+
*
|
|
10
|
+
* Some assumptions are handled separately, specifically, those that can
|
|
11
|
+
* be represented as a symbol definition (equality to an expression,
|
|
12
|
+
* membership to Integer, RealNumber, etc..., >0, <=0, etc...). The result
|
|
13
|
+
* of these are stored directly in the current scope's symbols dictionary
|
|
14
|
+
* (and an entry for the symbol is created if necessary).
|
|
15
|
+
*
|
|
16
|
+
* Predicates that involve multiple symbols are simplified (for example
|
|
17
|
+
* `x + y = 5` becomes `x + y - 5 = 0`, then stored in the `assumptions` of the
|
|
18
|
+
* current context).
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
export declare function assume(_proposition: BoxedExpression): AssumeResult;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/* 0.5.0 */
|
|
2
|
+
import type { Complex } from 'complex.js';
|
|
3
|
+
import { Expression } from '../../math-json/math-json-format';
|
|
4
|
+
import { BoxedExpression, BoxedFunctionDefinition, BoxedRuleSet, BoxedSymbolDefinition, EvaluateOptions, IComputeEngine, LatexString, Metadata, NOptions, PatternMatchOption, SemiBoxedExpression, SimplifyOptions, Substitution } from '../public';
|
|
5
|
+
/**
|
|
6
|
+
* AbstractBoxedExpression
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class AbstractBoxedExpression implements BoxedExpression {
|
|
9
|
+
abstract get json(): Expression;
|
|
10
|
+
abstract get head(): BoxedExpression | string;
|
|
11
|
+
abstract isSame(rhs: BoxedExpression): boolean;
|
|
12
|
+
abstract isEqual(rhs: BoxedExpression): boolean;
|
|
13
|
+
abstract get isCanonical(): boolean;
|
|
14
|
+
abstract set isCanonical(_val: boolean);
|
|
15
|
+
abstract get hash(): number;
|
|
16
|
+
abstract match(rhs: BoxedExpression, options?: PatternMatchOption): Substitution | null;
|
|
17
|
+
readonly engine: IComputeEngine;
|
|
18
|
+
/** Authentic LaTeX, obtained from a source, i.e. from parsing, not generated
|
|
19
|
+
* synthetically */
|
|
20
|
+
protected _latex?: string;
|
|
21
|
+
protected _wikidata?: string;
|
|
22
|
+
constructor(ce: IComputeEngine, metadata?: Metadata);
|
|
23
|
+
/** Object.toJSON(), called by JSON.Stringify */
|
|
24
|
+
toJSON(): string;
|
|
25
|
+
/** Object.toString() */
|
|
26
|
+
toString(): string;
|
|
27
|
+
/** Object.valueOf(): return a primitive value for the object */
|
|
28
|
+
valueOf(): number | string | [number, number];
|
|
29
|
+
/** Object.is() */
|
|
30
|
+
is(rhs: any): boolean;
|
|
31
|
+
has(_v: string | string[]): boolean;
|
|
32
|
+
get description(): string[];
|
|
33
|
+
get url(): string;
|
|
34
|
+
_purge(): undefined;
|
|
35
|
+
get isPure(): boolean;
|
|
36
|
+
get isLiteral(): boolean;
|
|
37
|
+
get latex(): LatexString;
|
|
38
|
+
set latex(val: LatexString);
|
|
39
|
+
get wikidata(): string;
|
|
40
|
+
set wikidata(val: string);
|
|
41
|
+
get complexity(): number;
|
|
42
|
+
get ops(): null | BoxedExpression[];
|
|
43
|
+
get nops(): number;
|
|
44
|
+
get op1(): BoxedExpression;
|
|
45
|
+
get op2(): BoxedExpression;
|
|
46
|
+
get op3(): BoxedExpression;
|
|
47
|
+
get symbolDefinition(): BoxedSymbolDefinition | undefined;
|
|
48
|
+
get functionDefinition(): BoxedFunctionDefinition | undefined;
|
|
49
|
+
_repairDefinition(): void;
|
|
50
|
+
get keys(): IterableIterator<string> | null;
|
|
51
|
+
get keysCount(): number;
|
|
52
|
+
getKey(_key: string): BoxedExpression | undefined;
|
|
53
|
+
hasKey(_key: string): boolean;
|
|
54
|
+
get machineValue(): number | null;
|
|
55
|
+
get rationalValue(): [numer: number, denom: number] | [null, null];
|
|
56
|
+
get decimalValue(): Decimal | null;
|
|
57
|
+
get complexValue(): Complex | null;
|
|
58
|
+
get asFloat(): number | null;
|
|
59
|
+
get asSmallInteger(): number | null;
|
|
60
|
+
get asRational(): [number, number] | [null, null];
|
|
61
|
+
get sgn(): -1 | 0 | 1 | undefined | null;
|
|
62
|
+
get symbol(): string | null;
|
|
63
|
+
get isMissing(): boolean;
|
|
64
|
+
get value(): BoxedExpression | undefined;
|
|
65
|
+
set value(_value: BoxedExpression | number | undefined);
|
|
66
|
+
get numericValue(): BoxedExpression | undefined;
|
|
67
|
+
isSubsetOf(_d: BoxedExpression | string): undefined | boolean;
|
|
68
|
+
get domain(): BoxedExpression;
|
|
69
|
+
set domain(_domain: BoxedExpression);
|
|
70
|
+
get string(): string | null;
|
|
71
|
+
isLess(_rhs: BoxedExpression): boolean | undefined;
|
|
72
|
+
isLessEqual(_rhs: BoxedExpression): boolean | undefined;
|
|
73
|
+
isGreater(_rhs: BoxedExpression): boolean | undefined;
|
|
74
|
+
isGreaterEqual(_rhs: BoxedExpression): boolean | undefined;
|
|
75
|
+
get isZero(): boolean | undefined;
|
|
76
|
+
get isNotZero(): boolean | undefined;
|
|
77
|
+
get isPositive(): boolean | undefined;
|
|
78
|
+
get isNonNegative(): boolean | undefined;
|
|
79
|
+
get isNegative(): boolean | undefined;
|
|
80
|
+
get isNonPositive(): boolean | undefined;
|
|
81
|
+
get isInfinity(): boolean | undefined;
|
|
82
|
+
get isNaN(): boolean | undefined;
|
|
83
|
+
get isFinite(): boolean | undefined;
|
|
84
|
+
get isNumber(): boolean | undefined;
|
|
85
|
+
get isInteger(): boolean | undefined;
|
|
86
|
+
get isRational(): boolean | undefined;
|
|
87
|
+
get isAlgebraic(): boolean | undefined;
|
|
88
|
+
get isReal(): boolean | undefined;
|
|
89
|
+
get isExtendedReal(): boolean | undefined;
|
|
90
|
+
get isComplex(): boolean | undefined;
|
|
91
|
+
get isImaginary(): boolean | undefined;
|
|
92
|
+
get isExtendedComplex(): boolean | undefined;
|
|
93
|
+
get isOne(): boolean | undefined;
|
|
94
|
+
get isNegativeOne(): boolean | undefined;
|
|
95
|
+
get isEven(): boolean | undefined;
|
|
96
|
+
get isOdd(): boolean | undefined;
|
|
97
|
+
get isPrime(): boolean | undefined;
|
|
98
|
+
get isComposite(): boolean | undefined;
|
|
99
|
+
get canonical(): BoxedExpression;
|
|
100
|
+
apply(_fn: (x: BoxedExpression) => SemiBoxedExpression, _head?: string): BoxedExpression;
|
|
101
|
+
evaluate(options?: EvaluateOptions): BoxedExpression;
|
|
102
|
+
simplify(_options?: SimplifyOptions): BoxedExpression;
|
|
103
|
+
N(_options?: NOptions): BoxedExpression;
|
|
104
|
+
replace(_rules: BoxedRuleSet): null | BoxedExpression;
|
|
105
|
+
subs(_sub: Substitution): BoxedExpression;
|
|
106
|
+
solve(_vars: Iterable<string>): null | BoxedExpression[];
|
|
107
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/* 0.5.0 */
|
|
2
|
+
import { Decimal } from 'decimal.js';
|
|
3
|
+
import { IComputeEngine, SemiBoxedExpression, BoxedExpression, Metadata } from '../public';
|
|
4
|
+
import { Expression, MathJsonNumber } from '../../math-json/math-json-format';
|
|
5
|
+
/**
|
|
6
|
+
* Notes about the boxed form:
|
|
7
|
+
*
|
|
8
|
+
* [1] Expression with a head of `Number`, `String`, `Symbol` and `Dictionary`
|
|
9
|
+
* are converted to the corresponding atomic expression.
|
|
10
|
+
*
|
|
11
|
+
* [2] Expressions with a head of `Complex` are converted to a (complex) number
|
|
12
|
+
* or a `Add`/`Multiply` expression.
|
|
13
|
+
*
|
|
14
|
+
* The precedence of `Complex` (for serialization) is sometimes the
|
|
15
|
+
* precedence of `Add` (when re and im != 0), sometimes the precedence of
|
|
16
|
+
* `Multiply` (when im or re === 0). Using a number or an explicit
|
|
17
|
+
* `Add`/`Multiply` expression avoids this ambiguity.
|
|
18
|
+
*
|
|
19
|
+
* [3] An expression with a `Rational` head is converted to a rational number.
|
|
20
|
+
*
|
|
21
|
+
* [4] A `Negate` function applied to a number literal is converted to a number.
|
|
22
|
+
*
|
|
23
|
+
*
|
|
24
|
+
* Note that `Negate` is only distributed over addition. In practice, having
|
|
25
|
+
* `Negate` factored on multiply/divide is more useful to detect patterns.
|
|
26
|
+
*
|
|
27
|
+
* Note that the `box()` function should only be called from `ComputeEngine`
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
export declare function box(ce: IComputeEngine, expr: Decimal | Complex | [num: number, denom: number] | SemiBoxedExpression): BoxedExpression;
|
|
31
|
+
/**
|
|
32
|
+
* Return a boxed number representing `num`.
|
|
33
|
+
*
|
|
34
|
+
* This function tries to avoid creating a boxed number if `num` corresponds
|
|
35
|
+
* to a common value for which we have a shared instance (-1, 0, NaN, etc...)
|
|
36
|
+
*
|
|
37
|
+
*
|
|
38
|
+
* Note that `boxNumber()` should only be called from `ComputeEngine`
|
|
39
|
+
*/
|
|
40
|
+
export declare function boxNumber(ce: IComputeEngine, num: MathJsonNumber | BoxedExpression | number | Complex | Decimal | [numer: number, denom: number], metadata?: Metadata): BoxedExpression | null;
|
|
41
|
+
/**
|
|
42
|
+
* Note that `boxDomain()` should only be called from `ComputeEngine`
|
|
43
|
+
*/
|
|
44
|
+
export declare function boxDomain(ce: IComputeEngine, dom: string | BoxedExpression, metadata?: Metadata): BoxedExpression;
|
|
45
|
+
/**
|
|
46
|
+
* Given a head (either as a string or a lambda expression)
|
|
47
|
+
* and a set of arguments, return a boxed function expression.
|
|
48
|
+
*
|
|
49
|
+
* If available, preserve LaTeX and wikidata metadata in the boxed expression.
|
|
50
|
+
*
|
|
51
|
+
* The result is *not* a canonical expression.
|
|
52
|
+
*
|
|
53
|
+
* Note that `boxFunction()` should only be called from `ComputeEngine` or
|
|
54
|
+
* `box()`
|
|
55
|
+
*/
|
|
56
|
+
export declare function boxFunction(ce: IComputeEngine, head: string, ops: Expression[], metadata?: Metadata): BoxedExpression;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* 0.5.0 */
|
|
2
|
+
import { BoxedExpression, IComputeEngine, EvaluateOptions, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, ReplaceOptions, Substitution, Metadata, PatternMatchOption } from '../public';
|
|
3
|
+
import { AbstractBoxedExpression } from './abstract-boxed-expression';
|
|
4
|
+
/**
|
|
5
|
+
* BoxedDictionary
|
|
6
|
+
*/
|
|
7
|
+
export declare class BoxedDictionary extends AbstractBoxedExpression {
|
|
8
|
+
private _value;
|
|
9
|
+
private _isCanonical;
|
|
10
|
+
constructor(ce: IComputeEngine, dict: {
|
|
11
|
+
[key: string]: SemiBoxedExpression;
|
|
12
|
+
}, metadata?: Metadata);
|
|
13
|
+
_purge(): undefined;
|
|
14
|
+
get hash(): number;
|
|
15
|
+
get complexity(): number;
|
|
16
|
+
get head(): 'Dictionary';
|
|
17
|
+
get isPure(): boolean;
|
|
18
|
+
getKey(key: string): BoxedExpression | undefined;
|
|
19
|
+
hasKey(key: string): boolean;
|
|
20
|
+
get keys(): IterableIterator<string>;
|
|
21
|
+
get keysCount(): number;
|
|
22
|
+
has(x: string | string[]): boolean;
|
|
23
|
+
get domain(): BoxedExpression;
|
|
24
|
+
get json(): Expression;
|
|
25
|
+
/** Structural equality */
|
|
26
|
+
isSame(rhs: BoxedExpression): boolean;
|
|
27
|
+
match(rhs: BoxedExpression, _options?: PatternMatchOption): Substitution | null;
|
|
28
|
+
/** Mathematical equality */
|
|
29
|
+
isEqual(rhs: BoxedExpression): boolean;
|
|
30
|
+
apply(fn: (x: BoxedExpression) => SemiBoxedExpression, head?: string): BoxedExpression;
|
|
31
|
+
evaluate(options?: EvaluateOptions): BoxedExpression;
|
|
32
|
+
get isCanonical(): boolean;
|
|
33
|
+
set isCanonical(val: boolean);
|
|
34
|
+
get canonical(): BoxedExpression;
|
|
35
|
+
simplify(options?: SimplifyOptions): BoxedExpression;
|
|
36
|
+
N(options?: NOptions): BoxedExpression;
|
|
37
|
+
replace(rules: BoxedRuleSet, options?: ReplaceOptions): null | BoxedExpression;
|
|
38
|
+
subs(sub: Substitution): BoxedExpression;
|
|
39
|
+
}
|