UNPKG

guacyra

Version:

A small and self-contained Computer Algebra System.

22 lines 48.4 kB
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}("undefined"!=typeof self?self:this,(function(){return(()=>{"use strict";var e={150:(e,t,r)=>{const n=r(882),o=r(884),{$:a,$$:l,Form:i,ownValueSet:s,equal:u,kind:c,apply:_,match:f,Eval:p,copy:g,addRule:b,Integer:h,Plus:m,Times:d,Power:y,Sequence:I,List:L,Less:x,True:T,False:S,toString:R,mkReservedSymbol:P}=n,{gcd:w,factorization:$,binomial:v}=o,D=i("Rational"),A=i("Divide"),k=i("Complex"),C=P("I");s(C,k(0,1));const E=i("Conjugate"),q=i("Abs"),M=i("Expand"),N=i("Sqrt"),B=i("NumeratorDenominator"),O=i("Numerator"),F=i("Denominator"),X=i("Together"),H=e=>"Integer"===c(e)||"Rational"===c(e),j=e=>{if(isAtom(e))return H(e);if("Symbol"!==c(e[0]))return!1;for(let t=1;t<e.length;++t)if(!j(e[t]))return!1;return!0};b(l`Rational(a_Integer, b_Integer)`,(({a:e,b:t})=>{let r=e[1],n=t[1];const o=w(r,n);return 1==o&&n>0&&1!=n?null:(r/=o,n/=o,n<0&&(r=-r,n=-n),1==n?h(r):D(r,n))})),a`Rational : Numeric(Rational(a_Integer, b_Integer)) := True`,a`Rational : Less(a_Integer, Rational(p_Integer, q_Integer)) := a*q < p`,a`Rational : Less(Rational(p_Integer, q_Integer), a_Integer) := p < a*q`,a`Rational : Less( Rational(a_Integer, b_Integer), Rational(c_Integer, d_Integer) ) := a*d < b*c`,a`Rational : Less(a_Rational, b_) := True`,a`Rational : Less(a_, b_Rational) := False`,a`Divide(a_Integer, b_Integer) := Rational(a, b)`,a`Divide(a_, b_) := Times(a, Power(b, -1))`,a`Plus(a_Integer, Rational(b_Integer, c_Integer), d___) := Plus(Rational(a*c+b, c), d)`,a`Plus(Rational(b_Integer, c_Integer), a_Integer, d___) := Plus(Rational(a*c+b, c), d)`,a`Plus( Rational(a_Integer, b_Integer), Rational(c_Integer, d_Integer), e___) := Plus(Rational(a*d+b*c, b*d), e)`,a`Times(a_Integer, Rational(b_Integer, c_Integer), d___) := Times(Rational(a*b,c), d)`,a`Times(Rational(b_Integer, c_Integer), a_Integer, d___) := Times(Rational(a*b,c), d)`,a`Times( Rational(a_Integer, b_Integer), Rational(c_Integer, d_Integer), e___) := Times(Rational(a*c, b*d), e)`,a`Complex : Numeric(Complex(a_)) := True`,a`Complex : Less(Complex(a_, b_), Complex(c_, d_)) := If(a=c, b<d, a<c)`,a`Complex : Less(a_Complex, b_) := If(Numeric(b), False, True)`,a`Complex : Less(a_, b_Complex) := If(Numeric(a), True, False)`,a`Complex(a_, 0) := a`,a`Conjugate(Complex(a_, b_)) := Complex(a, -b)`,a`Abs(a_Integer) := If(a<0, -a, a); Abs(Rational(a_Integer, b_Integer)) := Rational(Abs(a), b)`,a`Abs(Complex(a_, b_)) := Sqrt(a^2+b^2)`,a`Plus(n_Integer, Complex(a_, b_), c___) := Plus(Complex(a+n, b), c)`,a`Plus(p_Rational, Complex(a_, b_), c___) := Plus(Complex(a+p, b), c)`,a`Plus(Complex(a_, b_), Complex(c_, d_), e___) := Plus(Complex(a+c, b+d), e)`,a`Times(n_Integer, Complex(a_, b_), c___) := Times(Complex(n*a, n*b), c)`,a`Times(p_Rational, Complex(a_, b_), c___) := Times(Complex(Times(p, a), Times(p, b)), c)`,a`Times(Complex(a_, b_), Complex(c_, d_), e___) := Times(Complex(a*c-b*d, a*d+b*c), e)`,a`Times(-1, Plus(a__)) := Map(x => Times(-1, x), Plus(a))`;const G=(e,t,r)=>{const n=R(t);return e[n]?(e[n][1].push(r),!0):(e[n]=[t,I(r)],!1)};b(l`Plus(c__)`,(({c:e})=>{const t=m();let r=!1;const n={};for(let t=1;t<e.length;++t){const o={};r=f(e[t],l`Times(a_Integer, b_)`,o)||f(e[t],l`Times(a_Integer, b__)`,o)||f(e[t],l`Times(a_Rational, b_)`,o)||f(e[t],l`Times(a_Rational, b__)`,o)||f(e[t],l`Times(a_Complex, b_)`,o)||f(e[t],l`Times(a_Complex, b__)`,o)?G(n,o.b,o.a)||r:f(e[t],l`Times(b__)`,o)?G(n,o.b,h(1))||r:G(n,e[t],h(1))||r}if(r){for(let e in n){const r=n[e];_("Plus",r[1]),t.push(d(r[1],r[0]))}return t}return null})),b(l`Times(c__)`,(({c:e})=>{const t=d();let r=!1;const n={};for(let t=1;t<e.length;++t){const o={};r=f(e[t],l`Power(a_Integer, b_Rational)`,o)?G(n,y(o.a,o.b),h(1))||r:f(e[t],l`Power(a_, b_)`,o)?G(n,o.a,o.b)||r:G(n,e[t],h(1))||r}if(r){for(let e in n){const r=n[e];_("Plus",r[1]),t.push(y(r[0],r[1]))}return t}return null})),b(l`Times(c__)`,(({c:e})=>{const t=d();let r=!1;const n={};for(let t=1;t<e.length;++t){const o={};f(e[t],l`Power(a_Integer, b_)`,o)?r=G(n,o.b,o.a)||r:G(n,h(1),e[t])}if(r){for(let e in n){const r=n[e];_("Times",r[1]),t.push(y(r[1],r[0]))}return t}return null})),a`Power(a_Integer, b_Integer) := Rational(1, a^(-b))`,a`Power(Rational(a_Integer, b_Integer), c_Integer) := If(c<0, Rational(b^(-c), a^(-c)), Rational(a^c, b^c))`;const U=(e,t,r)=>{let[n,o]=[1,1];for(let a=0;a<e.length;++a){const l=e[a][1]*t,i=e[a][0],s=Math.floor(l/r),u=l-s*r;n*=Math.pow(i,s),o*=Math.pow(i,u)}return[n,o]};b(l`Power(a_Integer, b_Rational)`,(({a:e,b:t})=>{if(e[1]<0)return null;const r=$(e[1]);if(t[1][1]>0){const[e,n]=U(r,t[1][1],t[2][1]);return 1==e&&1==t[1][1]?null:d(e,y(n,D(1,t[2][1])))}{const n=-t[1][1],o=Math.floor(n/t[2][1]),a=n-o*t[2][1],[l,i]=U(r,t[2][1]-a,t[2][1]);return d(D(l,Math.pow(e[1],o+1)),y(i,D(1,t[2][1])))}})),a`Power(Rational(a_Integer, b_Integer), c_Rational) := a^(c)*b^(-c)`,a`Power(Power(a_, b_), c_Integer) := Power(a, Times(b, c))`,a`Power(Times(a__), b_Integer) := Map( x => x^b, Times(a))`,a`Sqrt(a_) := Power(a, Rational(1, 2))`,b(l`Power(z_Complex, n_Integer)`,(({z:e,n:t})=>{let r=k(1,0);const n=Math.abs(t[1]);for(let t=0;t<n;++t)r=p(d(r,e));return t[1]<0?d(E(r),A(1,y(q(r),2))):r})),b(l`Numerator(a_Integer)`,l`a`),b(l`Numerator(Rational(a_Integer, b_Integer))`,l`a`),b(l`Numerator(a_)`,(({a:e})=>p(B(e))[1])),b(l`Denominator(a_Integer)`,l`1`),b(l`Denominator(a_Rational)`,(({a:e})=>h(e[2][1]))),b(l`Denominator(a_)`,(({a:e})=>p(B(e))[2])),b(l`NumeratorDenominator(a_Integer)`,(({a:e})=>L(e,h(1)))),b(l`NumeratorDenominator(a_Rational)`,(({a:e})=>L(h(e[1][1]),h(e[2][1])))),b(l`NumeratorDenominator(Power(a_, n_Integer))`,(({a:e,n:t})=>t[1]<0?L(1,y(e,-t[1])):L(y(e,t),1))),b(l`NumeratorDenominator(Power(a_, n_Rational))`,(({a:e,n:t})=>t[1][1]<0?L(1,y(e,D(-t[1][1],t[2][1]))):L(y(e,t),1))),b(l`NumeratorDenominator(Times(a__))`,(({a:e})=>{const t=d(),r=d();for(let n=1;n<e.length;++n){const o=p(B(e[n]));t.push(o[1]),r.push(o[2])}return L(t,r)})),b(l`NumeratorDenominator(Plus(a__))`,(({a:e})=>{const t=m(),r=d(),n={},o=L();for(let t=1;t<e.length;++t){const a=p(B(e[t]));o.push(a);const l=a[2],i=R(l);n[i]||(n[i]=!0,r.push(l))}for(let n=1;n<e.length;++n){const e=p(d(g(r),A(o[n][1],o[n][2])));t.push(e)}return L(t,r)})),b(l`NumeratorDenominator(a_)`,(({a:e})=>L(e,1))),b(l`Together(a_)`,(({a:e})=>{const t=p(B(e));return"Integer"===c(t[2])?A(t[1],t[2]):A(X(t[1]),X(t[2]))})),b(l`Expand(Times(a__))`,(({a:e})=>{for(let t=1;t<e.length;++t){let r={};if(f(e[t],l`Plus(b__)`,r)){let n=m();for(let o=1;o<r.b.length;++o){let a=e.slice();_("Times",a),a[t]=r.b[o],n.push(M(a))}return n}if(f(e[t],l`Power(Plus(b__), n_Integer)`,r)&&r.n[1]>0){let n=e.slice();return _("Times",n),n[t]=M(y(m(r.b),r.n[1])),M(n)}}return d(e)})),b(l`Expand(Power(Plus(a_, b__), n_Integer))`,(({a:e,b:t,n:r})=>{let n=m();for(let o=0;o<=r[1];++o)n.push(M(d(v(r[1],o),y(e,r[1]-o),M(y(m(t),o)))));return n})),b(l`Expand(Plus(a_, b__))`,(({a:e,b:t})=>m(M(e),M(m(t))))),b(l`Expand(List(a__))`,l`Map(Expand,List(a))`),b(l`Expand(a_)`,(({a:e})=>e));const z={};z.Rational=D,z.Divide=A,z.Complex=k,z.I=C,z.Conjugate=E,z.Abs=q,z.Expand=M,z.Sqrt=N,z.NumeratorDenominator=B,z.Numerator=O,z.Denominator=F,z.Together=X,z.isNumeric=H,z.isNumericEx=j,e.exports=z},613:(e,t,r)=>{const n=r(882),{$$:o,Form:a,mkReservedSymbol:l,Cons:i,has:s,subst:u,Eval:c,addRule:_,Integer:f,Str:p,Plus:g,Times:b,Power:h,Sqrt:m,Divide:d,Subtract:y,toString:I}=n,L=r(762),{equal:x}=r(882),{latex:T}=L,S=a("Diff"),R=a("Derivative"),P=a("Log"),w=a("Exp"),$=a("Sin"),v=a("Cos"),D=l("Pi");_(o`Log(1)`,o`0`),_(o`Exp(0)`,o`1`),_(o`Sin(Pi)`,o`0`),_(o`Sin(0)`,o`0`),_(o`Sin(Times(n_Integer, Pi))`,o`0`),_(o`Sin(Times(Rational(a_Integer, b_Integer), Pi))`,(({a:e,b:t})=>e[1]<0?o`-Sin(${-e[1]}/${t[1]}*Pi)`:e[1]/t[1]>2?o`Sin(${e[1]%(2*t[1])}/${t[1]}*Pi)`:e[1]/t[1]>1?o`-Sin(${e[1]-t[1]}/${t[1]}*Pi)`:e[1]/t[1]>.5?o`Sin(${t[1]-e[1]}/${t[1]}*Pi)`:1==e[1]&&2==t[1]?f(1):1==e[1]&&3==t[1]?d(m(3),2):1==e[1]&&4==t[1]?d(m(2),2):1==e[1]&&6==t[1]?d(1,2):null)),_(o`Cos(Pi)`,o`-1`),_(o`Cos(0)`,o`1`),_(o`Cos(Times(n_Integer, Pi))`,(({n:e})=>f(e[1]%2==0?1:-1))),_(o`Cos(Times(Rational(a_Integer, b_Integer), Pi))`,(({a:e,b:t})=>e[1]<0?o`Cos(${-e[1]}/${t[1]}*Pi)`:e[1]/t[1]>2?o`Cos(${e[1]%(2*t[1])}/${t[1]}*Pi)`:e[1]/t[1]>1?o`-Cos(${e[1]-t[1]}/${t[1]}*Pi)`:e[1]/t[1]>.5?o`-Cos(${t[1]-e[1]}/${t[1]}*Pi)`:1==e[1]&&2==t[1]?f(0):1==e[1]&&3==t[1]?d(1,2):1==e[1]&&4==t[1]?d(m(2),2):1==e[1]&&6==t[1]?d(m(3),2):null)),_(o`Diff(k_, x_Literal)`,(({k:e,x:t})=>s(e,t)?null:f(0))),_(o`Diff(x_Literal, x_Literal)`,o`1`),_(o`Diff(Power(x_Literal, n_Integer), x_Literal)`,o`n*x^(n-1)`),_(o`Derivative(Log)(1)(x_)`,o`1/x`),_(o`Derivative(Exp)(1)(x_)`,o`Exp(x)`),_(o`Derivative(Sin)(1)(x_)`,o`Cos(x)`),_(o`Derivative(Cos)(1)(x_)`,o`-Sin(x)`),_(o`Diff(Times(k_, a__), x_Literal)`,(({k:e,x:t,a:r})=>s(e,t)?g(b(S(e,t),r),b(e,S(b(r),t))):b(e,S(b(r),t)))),_(o`Diff(Plus(a__), x_Literal)`,o`Map( t => Diff(t,x), Plus(a) )`),_(o`Diff(Power(f_, n_Integer), x_Literal)`,(({f:e,n:t,x:r})=>b(t,h(e,y(t,1)),S(e,r)))),_(o`Diff(Power(f_, n_Rational), x_Literal)`,(({f:e,n:t,x:r})=>b(t,h(e,y(t,1)),S(e,r)))),_(o`Diff(f_(y_), x_Literal)`,o`Times(Derivative(f)(1)(y), Diff(y, x))`),_(o`LaTeX(Pi)`,p("\\pi"),"Pi"),_(o`LaTeX(Exp(a_))`,(({a:e})=>p("e^{"+T(e)+"}")),"Exp"),_(o`LaTeX(Log(a_))`,(({a:e})=>p("\\log{"+T(e)+"}")),"Log"),_(o`LaTeX(Sin(a_))`,(({a:e})=>p("\\sin{"+T(e)+"}")),"Sin"),_(o`LaTeX(Cos(a_))`,(({a:e})=>p("\\cos{"+T(e)+"}")),"Cos"),_(o`LaTeX(Derivative(f_)(1)(x_))`,(({f:e,x:t})=>p(T(e)+"{'}("+T(t)+")")),"Derivative");const A={Diff:S,Derivative:R,Sin:$,Cos:v,Pi:D,Log:P,Exp:w};e.exports=A},762:(e,t,r)=>{const n=r(882),o=r(150),a=r(986),{$$:l,Form:i,equal:s,kind:u,Eval:c,addRule:_,Integer:f,Str:p,Plus:g,Times:b,Power:h,isAtom:m,toString:d}=n,{isNumeric:y,NumeratorDenominator:I}=o,{size:L,reducedRowEchelonSteps:x,rowEchelonSteps:T,buildTensor:S,forEachEntry:R}=a,P=i("LaTeX"),w=i("Output"),v=e=>"Integer"===u(e)?e[1]:e[1][1]/e[2][1],D=e=>c(P(e))[1],A=e=>c(w(e))[1],k=(i("Display"),i("RowReduceSteps"),i("GaussianEliminationSteps"),e=>"Symbol"===e||"Literal"===e),C=(e,t)=>{const r=u(e),n=u(t);if(y(e)&&y(t))return v(e)<v(t);if(k(r)&&k(n))return e[1]<t[1];if("Plus"===r&&"Plus"===n||"Times"===r&&"Times"===n){let r=e.length-1,n=t.length-1;for(;r>=1&&n>=1;){if(!s(e[r],t[n]))return C(e[r],t[n]);r-=1,n-=1}return r<n}if("Power"===r&&"Power"===n)return s(e[2],t[2])?C(e[1],t[1]):C(t[2],e[2]);if(r===n){let r=e.length,n=t.length,o=1;for(;o<r&&o<n;){if(!s(e[o],t[o]))return C(e[o],t[o]);o+=1}return r<n}return"Times"===r?C(e,b(t)):"Times"===n?C(b(e),t):"Power"===r?C(e,h(t,1)):"Power"===t?C(h(e,1),t):"Plus"===r?C(e,g(t)):"Plus"===n?C(g(e),t):!(y(e)&&!y(t))&&(!(y(e)||!y(t))||void 0)};_(l`LaTeX()`,p("")),_(l`LaTeX(a_Integer)`,l`ToString(a)`),_(l`LaTeX(a_Symbol)`,l`ToString(a)`),_(l`LaTeX(a_Literal)`,l`ToString(a)`),_(l`LaTeX(a_Str)`,l`a`),_(l`LaTeX(Times(p_Rational, a_))`,(({p:e,a:t})=>{if(!k(u(t)))return null;if(e[1][1]<0){const r=c(P(b(-e[1][1],t)))[1];return p(`-\\frac{${r}}{${e[2][1]}}`)}{const r=c(P(b(e[1][1],t)))[1];return p(`\\frac{${r}}{${e[2][1]}}`)}})),_(l`LaTeX(a_Rational)`,(({a:e})=>e[1][1]<0?p(`-\\frac{${-e[1][1]}}{${e[2][1]}}`):p(`\\frac{${e[1][1]}}{${e[2][1]}}`))),_(l`LaTeX(Complex(a_,b_))`,(({a:e,b:t})=>{let r=c(P(e))[1];s(e,f(0))&&(r="");const n=c(P(b(t,p("\\mathrm{i}"))))[1];return n.startsWith("-")||""===r||(r+="+"),p(`${r}${n}`)})),_(l`LaTeX(Plus(c__))`,(({c:e})=>{let t="",r=e.slice(1);r.sort(((e,t)=>C(e,t)?-1:1));for(let e=0;e<r.length;++e){const n=c(P(r[e]))[1];n.startsWith("-")||0==e||(t+="+"),t+=n}return p(t)}));const E=e=>{const t=c(I(b(e)));return"Integer"===u(t[2])?(e=>{let t="";for(let r=1;r<e.length;++r){let n=c(P(e[r]))[1];"Plus"===u(e[r])?n="("+n+")":"Complex"!==u(e[r])||s(e[r][1],f(0))||(n="("+n+")"),t+=n}return t})(e):`\\frac{${c(P(t[1]))[1]}}{${c(P(t[2]))[1]}}`};_(l`LaTeX(Times(a_Integer, c__))`,(({a:e,c:t})=>{if(e[1]<0){const r="-"+c(P(c(b(-e[1],t))))[1];return p(r)}{const r=E(c(b(e[1],t)));return p(r)}})),_(l`LaTeX(Times(a_Rational, Power(b_Integer, c_Rational), d___))`,(({a:e,b:t,c:r,d:n})=>{if(1==r[1][1]&&2==r[2][1]){let o=c(P(h(t,r)))[1],a=E(n);return-1==e[1][1]?o=`-\\frac{${o}}{${e[2][1]}}`:(1!=e[1][1]&&(o=`${e[1][1]}`+o),o=`\\frac{${o}}{${e[2][1]}}`),p(o+a)}return null})),_(l`LaTeX(Times(c__))`,(({c:e})=>p(E(e)))),_(l`LaTeX(Power(a_, b_Rational))`,(({a:e,b:t})=>{if(1==t[1][1]&&2==t[2][1]){let t=c(P(e))[1];return p(`\\sqrt{${t}}`)}if(-1==t[1][1]&&2==t[2][1]){let t=c(P(e))[1];return p(`\\frac{1}{\\sqrt{${t}}}`)}return null})),_(l`LaTeX(Power(a_, b_Integer))`,(({a:e,b:t})=>{if(t[1]<0){let r=c(P(c(h(e,-t[1]))))[1];return p(`\\frac{1}{${r}}`)}return null})),_(l`LaTeX(Power(a_, b_))`,(({a:e,b:t})=>{let r="",n=c(P(e))[1];return m(e)||(n="("+n+")"),r=r+n+"^{"+c(P(t))[1]+"}",p(r)}));const q=(e,t=["[","]"])=>{const[r,n]=L(e),o="r".repeat(n);let a="";a+=`\\left${t[0]}\\begin{array}{${o}}`;for(let t=1;t<=r;++t){for(let r=1;r<=n;++r)a+=D(e[t][r]),r!=n&&(a+="&");t!=r&&(a+="\\\\")}return a+=`\\end{array}\\right${t[1]}`,a};_(l`LaTeX(A_List)`,(({A:e})=>{try{return p(q(e))}catch(t){return p(A(e))}})),_(l`LaTeX(a_)`,(({a:e})=>p(d(e)))),_(l`Output()`,p("")),_(l`Output(a_Integer)`,l`ToString(a)`),_(l`Output(a_Symbol)`,l`ToString(a)`),_(l`Output(a_Literal)`,l`ToString(a)`),_(l`Output(a_Str)`,l`a`),_(l`Output(Times(p_Rational, a_))`,(({p:e,a:t})=>{if(!k(u(t)))return null;if(e[1]<0){const r=c(w(b(-e[1][1],t)))[1];return p(`-${r}/${e[2][1]}`)}{const r=c(w(b(e[1][1],t)))[1];return p(`${r}/${e[2][1]}`)}})),_(l`Output(a_Rational)`,(({a:e})=>e[1][1]<0?p(`-${-e[1][1]}/${e[2][1]}`):p(`${e[1][1]}/${e[2][1]}`))),_(l`Output(Complex(a_,b_))`,(({a:e,b:t})=>{let r=c(w(e))[1];s(e,f(0))&&(r="");const n=c(w(b(t,p("I"))))[1];return n.startsWith("-")||""===r||(r+="+"),p(`${r}${n}`)})),_(l`Output(Plus(c__))`,(({c:e})=>{let t="",r=e.slice(1);r.sort(((e,t)=>C(e,t)?-1:1));for(let e=0;e<r.length;++e){const n=c(w(r[e]))[1];n.startsWith("-")||0==e||(t+="+"),t+=n}return p(t)})),_(l`Output(List(c__))`,(({c:e})=>{let t="[";for(let r=1;r<e.length;++r){let n=c(w(e[r]))[1];1!=r&&(n=", "+n),t+=n}return t+="]",p(t)}));const M=e=>{const t=c(I(b(e)));return"Integer"===u(t[2])?(e=>{let t="";for(let r=1;r<e.length;++r){let n=c(w(e[r]))[1];"Plus"===u(e[r])?n="("+n+")":"Complex"!==u(e[r])||s(e[r][1],f(0))||(n="("+n+")"),1!=r&&(n="*"+n),t+=n}return t})(e):`(${c(w(t[1]))[1]})/(${c(w(t[2]))[1]})`};_(l`Output(Times(a_Integer, c__))`,(({a:e,c:t})=>{if(e[1]<0){const r="-"+c(w(c(b(-e[1],t))))[1];return p(r)}{const r=M(c(b(e[1],t)));return p(r)}})),_(l`Output(Times(a_Rational, Power(b_Integer, c_Rational), d___))`,(({a:e,b:t,c:r,d:n})=>{if(1==r[1][1]&&2==r[2][1]){let o=c(w(h(t,r)))[1],a=M(n);return-1==e[1][1]?o=`-${o}/${e[2][1]}`:(1!=e[1][1]&&(o=`${e[1][1]}*`+o),o=`${o}/${e[2][1]}`),p(o+a)}return null})),_(l`Output(Times(c__))`,(({c:e})=>p(M(e)))),_(l`Output(Power(a_, b_Rational))`,(({a:e,b:t})=>{if(1==t[1][1]&&2==t[2][1]){let t=c(w(e))[1];return p(`Sqrt(${t})`)}if(-1==t[1][1]&&2==t[2][1]){let t=c(w(e))[1];return p(`1/Sqrt(${t})`)}return null})),_(l`Output(Power(a_, b_Integer))`,(({a:e,b:t})=>{if(t[1]<0){let r=c(w(c(h(e,-t[1]))))[1];return p(`1/${r}`)}return null})),_(l`Output(Power(a_, b_))`,(({a:e,b:t})=>{let r="",n=c(w(e))[1];return m(e)||(n="("+n+")"),r=r+n+"^"+c(w(t))[1],p(r)})),_(l`Output(a_)`,(({a:e})=>p(d(e)))),_(l`Display(a_)`,(({a:e})=>p("$$"+D(e))));const N=(e,t={})=>{let r,{method:n=x,format:o=(e=>q(e))}=t,a=String.raw`\begin{array}{c}`;for(let t of n(e)){if("pivot"===t.op)continue;let e;if("init"===t.op){r=o(t.A);continue}if("rswap"===t.op)e=`L_{${t.i}} \\leftrightarrow L_{${t.ip}}`;else if("rscale"===t.op){const r=D($`${t.k}*LLLLL`).replace("LLLLL",`L_{${t.i}}`);e=`L_{${t.i}} \\rightarrow ${r}`}else if("radd"===t.op){const r=D($`AAAAA+${t.k}*BBBBB`).replace("AAAAA",`L_{${t.i}}`).replace("BBBBB",`L_{${t.ip}}`);e=`L_{${t.i}} \\rightarrow ${r}`}const n=o(t.A);a+=String.raw` ${r} \;\underrightarrow{${e}}\;${n} \\ \\ `,r=n}return a+String.raw`\end{array}`};_(l`RowReduceSteps(A_)`,(({A:e})=>{const[t,r]=L(e);let n=S([t,r]);return R(e,((t,r)=>{n[t][r]=e[t][r]})),p("$$"+N(n))})),_(l`GaussianEliminationSteps(A_)`,(({A:e})=>{const[t,r]=L(e);let n=S([t,r]);return R(e,((t,r)=>{n[t][r]=e[t][r]})),p("$$"+N(n,{method:T}))}));const B={};B.LaTeX=P,B.latex=D,B.Output=w,B.output=A,B.formatMatrix=q,e.exports=B},579:(e,t,r)=>{const n=r(884),o=r(882),a=r(150),l=r(762),i=r(613),s=r(986),u=r(237);e.exports={NumberAlgo:n,Kernel:o,Algebra:a,Formatting:l,Calculus:i,LinearAlgebra:s,Random:u}},882:e=>{const t={},r={},n={},o=[r,n];let a=0;const l=()=>a++;class i{constructor(){this.attr={},this.up=[],this.down=[],this.sub=[],this.own=null,this.gen=l()}}const s=e=>{e[2].gen=l()};t.newDef=s;const u=[];u[0]=u,u[1]="Symbol",u[2]=new i,r.Symbol=u;const c=e=>[u,e,new i],_=e=>{for(let t=o.length-1;t>=0;--t){const r=o[t][e];if(r)return r}},f=e=>r[e]=c(e),p=e=>o[o.length-1][e]=c(e),g=e=>e[2].attr,b=e=>e[2].up,h=e=>e[2].own,m=(e,t)=>(s(e),e[2].own=t,t),d=f("Integer"),y=e=>[d,e],I=f("Str"),L=e=>[I,e],x=f("Literal"),T=e=>[x,e],S=e=>(...t)=>[e,...t],R=e=>{switch(typeof e){case"string":return L(e);case"number":return y(e);default:return e}},P=(e,r={})=>{const n=f(e),o=(...e)=>(e=e.map((e=>R(e))),S(n)(...e));return t[e]=o,Object.assign(g(n),r),o},w=P("List"),$=P("Sequence"),v=f("True"),D=f("False"),A=f("Null"),k=f("$Skip");t.True=v,t.False=D,t.Null=A,t.$Skip=k,P("If",{HoldAll:!0}),P("Cond",{HoldAll:!0}),P("And",{HoldAll:!0}),P("Or",{HoldAll:!0});const C=P("Not"),E=(P("While",{HoldAll:!0}),P("Repeat",{HoldAll:!0}),P("Block",{HoldAll:!0})),q=(P("Table",{HoldAll:!0}),P("ClearAll",{Impure:!0}),P("Clear",{HoldAll:!0,Impure:!0}),P("Print",{Impure:!0}),P("Cat"),P("ToString"),P("ToLisp"),P("Apply"),P("Postfix"),P("Append"),P("Map"),P("Reduce"),P("Lambda",{HoldAll:!0}),P("Do",{Flat:!0,HoldAll:!0}),P("Def",{HoldAll:!0,Impure:!0})),M=(P("Tag",{HoldAll:!0}),P("At",{HoldAll:!0}),P("Len"),P("Match"),P("Subst"),P("Equal"),P("Less")),N=(P("LessEqual"),P("Great"),P("GreatEqual"),P("Kind"),P("Blank",{HoldAll:!0})),B=P("BlankSequence",{HoldAll:!0}),O=P("BlankNullSequence",{HoldAll:!0}),F=(P("Hold",{HoldAll:!0}),P("Set",{Orderless:!0})),X=(P("In"),P("Union"),P("Intersection"),P("Plus",{Flat:!0,Orderless:!0})),H=P("Times",{Flat:!0,Orderless:!0}),j=(P("Subtract"),P("Quotient"),P("Mod"),P("UnaryMinus"),P("Power"),P("Numeric"),e=>e[0]===u||e[0]===I||e[0]===x||e[0]===d),G=e=>e[0]===u,U=e=>e[0]===x,z=e=>e[0]===d,W=e=>{const t=(e,r)=>{if(G(e))return Math.max(e[2].gen,r);if(U(e)){const t=_(e[1]);if(t)return Math.max(t[2].gen,r)}return j(e)?-1:e.reduce(((e,r)=>Math.max(t(r,e),e)),r)};return t(e,-1)};t.defNum=W;const K=e=>{if(G(e))return g(e).Impure;if(U(e)){const t=_(e[1]);if(t)return g(t).Impure}if(j(e))return!1;for(let t=0;t<e.length;++t)if(K(e[t]))return!0;return!1};t.isImpure=K;const V=e=>j(e)||j(e[0])?e[0][1]:"compound",Q=e=>{if(G(e[0]))return e[0];if(U(e[0])){let t=_(e[0][1]);return t||(t=p(e[0][1])),t}return Q(e[0])};t.ruleSymbol=Q;const J=e=>G(e[0])?e[0]:J(e[0]),Y=e=>!!ee(e,v)||!!z(e)&&0!=e[1],Z=e=>j(e)?e:e.map((e=>Z(e))),ee=(e,t)=>{if(e.length!=t.length)return!1;if(j(e)&&j(t)){for(let r=0;r<e.length;++r)if(e[r]!==t[r])return!1;return!0}if(!j(e)&&!j(t)){for(let r=0;r<e.length;++r)if(!ee(e[r],t[r]))return!1;return!0}return!1},te=(e,t)=>{if(j(e))return ee(e,t);if(ee(e,t))return!0;for(let r=0;r<e.length;++r)if(te(e[r],t))return!0;return!1},re=(e,t)=>j(e)?U(e)&&t[e[1]]?Z(t[e[1]]):e:e.map((e=>re(e,t))),ne=(e,t,r)=>{const n=(e,t,r)=>{if(U(t)&&G(e)||U(e)&&G(t))return e[1]==t[1];if(j(t))return ee(e,t);if("Blank"===V(t)){const n=t[1][1],o=t[2][1];if(o&&V(e)!==o)return!1;if(!n)return!0;const a=r[n];return a?ee(e,a):(r[n]=e,!0)}if(!n(e[0],t[0],r))return!1;for(let o=1;o<t.length;++o){const a=V(t[o]);if(("BlankNullSequence"===a||"BlankSequence"===a)&&o!=t.length-1)throw"BlankSequence not at last";if("BlankNullSequence"===a||"BlankSequence"===a&&o<e.length){const n=t[o][1][1],a=t[o][2][1],l=$();for(let t=o;t<e.length;++t)if(l.push(e[t]),a&&V(e[t])!==a)return!1;if(!n)return!0;const i=r[n];return i?ee(l,i):(r[n]=l,!0)}if(o==e.length)return!1;if(!n(e[o],t[o],r))return!1}return!(t.length<e.length)},o={},a=n(e,t,o);return a&&Object.assign(r,o),a},oe=e=>{if(j(e))return e;for(let t=0;t<e.length;++t)e[t]=oe(e[t]);const t=V(e);if("compound"===t)return e;if(G(e[0])&&g(e[0]).Flat){let r=1;for(;r<e.length;){let n=e[r];V(n)===t?(e.splice(r,1,...n.slice(1)),r=r+n.length-1):r+=1}}return e},ae=new class{constructor(e){this.lex=e.map((({tok:e,rex:t,type:r})=>[new RegExp("^"+t.source+"(.*)"),e])),this.tokens={},this.ops={},e.forEach((({tok:e,rex:t,type:r})=>{const n={};if(n.isTerminal=!!r.isTerminal,void 0!==r.binary){n.isBinary=!0;let t=r.binary.op;t||(t=e),n.binary=t,this.ops[t]=r.binary}else n.isBinary=!1;if(void 0!==r.unary){n.isUnary=!0;let t=r.unary.op;t||(t=e),n.unary=t,this.ops[t]=r.unary}else n.isUnary=!1;this.tokens[e]=n}))}isTerminal(e){return this.tokens[e].isTerminal}isBinary(e){return this.tokens[e].isBinary}binary(e){return this.tokens[e].binary}isUnary(e){return this.tokens[e].isUnary}unary(e){return this.tokens[e].unary}prec(e){return this.ops[e].precedence}associativity(e){return this.ops[e].associativity}tokenize(e){let t=e.replace(/\r?\n|\r/gm,"");const r=[];for(;t;)for(let e=0;e<this.lex.length;++e){let n=t.match(this.lex[e][0]);if(n){const o=this.lex[e][1];"Space"!==o&&r.push([o,n[1]]),t=n[2];break}}return r.push(["End",""]),r}}([{tok:"Space",rex:/(\s+)/,type:{}},{tok:"Integer",rex:/(\d+)/,type:{isTerminal:!0}},{tok:"String",rex:/'(.*?)'/,type:{isTerminal:!0}},{tok:"Symbol",rex:/([$\w]+)/,type:{isTerminal:!0}},{tok:"Do",rex:/(;)/,type:{binary:{precedence:0,associativity:"Left"}}},{tok:"Def",rex:/(:=)/,type:{binary:{precedence:5,associativity:"Right"}}},{tok:"Tag",rex:/(:)/,type:{binary:{precedence:3,associativity:"Right"}}},{tok:"Lambda",rex:/(=>)/,type:{binary:{precedence:5,associativity:"Right"}}},{tok:"LessEqual",rex:/(<=)/,type:{binary:{precedence:5,associativity:"Left"}}},{tok:"GreatEqual",rex:/(>=)/,type:{binary:{precedence:5,associativity:"Left"}}},{tok:"Less",rex:/(<)/,type:{binary:{precedence:5,associativity:"Left"}}},{tok:"Great",rex:/(>)/,type:{binary:{precedence:5,associativity:"Left"}}},{tok:"Equal",rex:/(=)/,type:{binary:{precedence:5,associativity:"Left"}}},{tok:"Plus",rex:/(\+)/,type:{binary:{precedence:10,associativity:"Left"}}},{tok:"Minus",rex:/(\-)/,type:{binary:{op:"Subtract",precedence:10,associativity:"Left"},unary:{op:"UnaryMinus",precedence:20}}},{tok:"At",rex:/(@)/,type:{unary:{precedence:50}}},{tok:"Len",rex:/(#)/,type:{unary:{precedence:50}}},{tok:"Postfix",rex:/(\/\/)/,type:{binary:{precedence:3,associativity:"Left"}}},{tok:"Times",rex:/(\*)/,type:{binary:{precedence:30,associativity:"Left"}}},{tok:"Dot",rex:/(\.)/,type:{binary:{precedence:30,associativity:"Left"}}},{tok:"Divide",rex:/(\/)/,type:{binary:{precedence:30,associativity:"Left"}}},{tok:"Power",rex:/(\^)/,type:{binary:{precedence:40,associativity:"Right"}}},{tok:"Left",rex:/(\()/,type:{}},{tok:"Right",rex:/(\))/,type:{}},{tok:"LeftBra",rex:/(\[)/,type:{}},{tok:"RightBra",rex:/(\])/,type:{}},{tok:"Comma",rex:/(,)/,type:{}},{tok:"End",rex:/end/,type:{}}]),le=e=>{const t=ae.tokenize(e);let n=0;const o=()=>t[n][0],a=()=>t[n+1][0],l=()=>t[n][1],i=()=>n+=1,s=e=>{if(o()!==e)throw`next = ${o()}, ${e} expected.`;i()};let u,c,_;return u=()=>{const e=c(0);return s("End"),e},c=e=>{let t=_();for(;"Left"===o();){let e=[];if("Right"===a())i();else do{i(),e.push(c(0))}while("Comma"===o());s("Right"),t=S(t)(...e)}for(;ae.isBinary(o())&&ae.prec(ae.binary(o()))>=e;){const e=ae.binary(o());i();const n=ae.prec(e)+("Right"===ae.associativity(e)?0:1),a=c(n);t=S(r[e])(t,a)}return t},_=()=>{if(ae.isUnary(o())){const e=ae.unary(o());i();const t=ae.prec(e),n=c(t);return"UnaryMinus"===e&&"Integer"===V(n)?y(-n[1]):S(r[e])(n)}if("Left"===o()){i();const e=c(0);return s("Right"),e}if("LeftBra"===o()){let e=[];if("RightBra"===a())i();else do{i(),e.push(c(0))}while("Comma"===o());return s("RightBra"),w(...e)}if(!ae.isTerminal(o()))throw"Syntax error";if("String"==o()){const e=L(l());return i(),e}if("Integer"==o()){const e=y(Number(l()));return i(),e}if("Symbol"==o()){let e=l();return i(),e.includes("_")?(e=>{const t=e.split("_");switch(t.length){case 2:return N(T(t[0]),T(t[1]));case 3:return B(T(t[0]),T(t[2]));case 4:return O(T(t[0]),T(t[3]))}throw"Ill formed Blank"})(e):r[e]||T(e)}},oe(u())};function ie(e,...t){if(0==t.length){let e=String.raw.apply(String,arguments);return le(e)}{const r=t.map(((e,t)=>`xXxLaBeL${t}`)),n={};r.forEach(((e,r)=>n[e]=R(t[r])));let o=String.raw.apply(String,[e,...r]);return re(le(o),n)}}function se(){return be(ie.apply(String,arguments))}const ue=e=>{const t=V(e);if("Integer"===t)return e[1].toString();if("Str"===t)return"'"+e[1]+"'";if("Symbol"===t)return e[1];if("Literal"===t)return e[1];let r=ue(e[0])+"(";for(let t=1;t<e.length;++t)1!=t&&(r+=","),r+=ue(e[t]);return r+")"},ce=e=>{const t=V(e);if("Integer"===t)return e[1].toString();if("Str"===t)return"'"+e[1]+"'";if("Symbol"===t)return e[1];if("Literal"===t)return"#"+e[1];let r="(";r+=ce(e[0]);for(let t=1;t<e.length;++t)r+=" "+ce(e[t]);return r+=")",r},_e=(e,t)=>{const r=V(e),n=V(t);if("Integer"===r&&"Integer"!==n)return!0;if("Integer"!==r&&"Integer"===n)return!1;if(j(e)&&j(t))return e[1]<t[1];if(j(e))return!0;if(j(t))return!1;if(r===n){const r=Math.min(e.length,t.length);for(let n=0;n<r;++n)if(!ee(e[n],t[n]))return _e(e[n],t[n]);return e.length<t.length}return"compound"===n||"compound"!==r&&r<n},fe=e=>null!==e&&e!==k,pe=e=>{const t=V(e),r=be(e[0]);if(!ee(r,e[0])){const t=Z(e);return t[0]=r,be(t)}if("compound"===t){const t=Z(e);for(let e=1;e<t.length;++e)t[e]=be(t[e]);let r;for(let e=1;e<t.length;++e){let n=t[e];const o=b(J(n));for(let e=0;e<o.length;++e)if(r=o[e](t),fe(r))return be(r)}const n=J(t)[2].sub;for(let e=0;e<n.length;++e)if(r=n[e](t),fe(r))return be(r);return t}if(G(r)){const n=g(r);let o,a=[];if(n.HoldAll||n.HoldRest)for(let t=1;t<e.length;++t)1==t&&n.HoldRest?a.push(be(e[t])):a.push(e[t]);else for(let t=1;t<e.length;++t)1==t&&n.HoldFirst?a.push(e[t]):a.push(be(e[t]));if(!n.SequenceHold){let e=0;for(;e<a.length;){let t=a[e];"Sequence"===V(t)?(a.splice(e,1,...t.slice(1)),e=e+t.length-1):e+=1}}if(n.Flat){let e=0;for(;e<a.length;){let r=a[e];V(r)===t?(a.splice(e,1,...r.slice(1)),e=e+r.length-1):e+=1}}n.Orderless&&a.sort(((e,t)=>Y(be(M(e,t)))?-1:1)),a.splice(0,0,r);for(let e=1;e<a.length;++e){let t=a[e];const r=b(J(t));for(let e=0;e<r.length;++e)if(o=r[e](a),fe(o))return be(o)}const l=r[2].down;for(let e=0;e<l.length;++e)if(o=l[e](a),fe(o))return be(o);return a}{const t=Z(e);for(let e=1;e<t.length;++e)t[e]=be(t[e]);return t}},ge={},be=e=>{const t=V(e);if(j(e)){if("Symbol"===t){return h(e)||e}if("Literal"===t){const t=_(e[1]);if(t)return be(t)}return e}if("List"==t)return pe(e);if(K(e))return pe(e);const r=ce(e),n=W(e);let o=ge[r];if(o){if(n!=o.def){const t=pe(e);return ge[r]={value:t,def:n},t}return o.value}{const t=pe(e);return ge[r]={value:t,def:n},t}};t.dumpMemo=()=>{let e=0;for(let t in ge)console.log(t,ue(ge[t].value)),e++;console.log(`Memo itens: ${e}`)};const he=(e,t,n)=>{let o=n?_(n):Q(e);const a=t=>{n?((e,t)=>{s(e),e[2].up.push(t)})(o,t):"compound"!==V(e)?((e,t)=>{s(e),e[2].down.push(t)})(o,t):((e,t)=>{s(e),e[2].sub.push(t)})(o,t)};"function"==typeof t?a((r=>{let n={};return ne(r,e,n)?t(n):null})):(K(t)&&(g(o).Impure=!0),te(t,r.Def)||te(t,r.Block)?a((r=>{let n={};if(ne(r,e,n)){const e=be(E((e=>{const t=w();for(const[r,n]of Object.entries(e))t.push(q(T(r),n));return t})(n),t));return"Return"===V(e)?e[1]:e}return null})):a((r=>{let n={};return ne(r,e,n)?be(re(t,n)):null})))};he(ie`Lambda(a_Literal, b_)(c_)`,(({a:e,b:t,c:r})=>{const n={};return n[e[1]]=r,be(re(t,n))})),he(ie`Lambda(List(a__Literal), b_)(c__)`,(({a:e,b:t,c:r})=>{const n={};for(let t=1;t<e.length;++t)n[e[t][1]]=r[t];return be(re(t,n))})),he(ie`Do(a__)`,(({a:e})=>{let t=A;for(let r=1;r<e.length&&(t=be(e[r]),"Return"!==V(t));++r);return t})),he(ie`Def(a_Literal, b_)`,(({a:e,b:t})=>{const r=be(t);let n=_(e[1]);return n||(n=p(e[1])),m(n,r),r})),he(ie`Def(List(a__Literal), b_)`,(({a:e,b:t})=>{const r=be(t);for(let n=1;n<e.length;++n){let o=_(e[n][1]);o||(o=p(e[n][1])),n>=t.length?m(o,A):m(o,r[n])}return r})),he(ie`Def(At(a_Literal(b_)), c_)`,(({a:e,b:t,c:r})=>{let n=_(e[1]);n||(n=p(e[1]));const o=h(n),a=be(t);if("Integer"!==V(a))throw"Index must be a integer";if(a[1]>=o.length||a[1]<0)throw"Out of bounds";return o[a[1]]=be(r),m(n,o),r})),he(ie`Def(At(a_Literal(b__)), c_)`,(({a:e,b:t,c:r})=>{let n=_(e[1]);n||(n=p(e[1]));let o=h(n),a=o;for(let e=1;e<t.length-1;++e)a=a[be(t[e])[1]];const l=be(t[t.length-1]),i=be(r);return a[l[1]]=i,m(n,o),i})),he(ie`Def(a_, b_)`,(({a:e,b:t})=>(he(e,t),A))),he(ie`Tag(t_Literal, Def(a_, b_))`,(({t:e,a:t,b:r})=>(he(t,r,e[1]),A))),he(ie`Tag(t_Symbol, Def(a_, b_))`,(({t:e,a:t,b:r})=>(he(t,r,e[1]),A))),he(ie`At(a_Literal(b_))`,(({a:e,b:t})=>{const r=_(e[1]);if(!r)throw console.log(e[1]),"Not a variable";const n=h(r);if(!n)throw"Not defined";const o=be(t);if(!z(o))throw"Index must be a integer";if("Str"===V(n)){if(o[1]>n[1].length||o[1]<=0)throw"Out of bounds";return L(n[1][o[1]-1])}if(o[1]>=n.length||o[1]<0)throw"Out of bounds";return n[o[1]]})),he(ie`At(a_Literal(b__))`,(({a:e,b:t})=>{const r=_(e[1]);if(!r)throw"Not a variable";let n=h(r);if(!n)throw"Not defined";for(let e=1;e<t.length;++e)n=n[be(t[e])[1]];return n})),he(ie`At(a_(b_))`,(({a:e,b:t})=>{const r=be(t);if(!z(r))throw"Index must be a integer";if(r[1]>=e.length||r[1]<0)throw"Out of bounds";return e[r[1]]})),he(ie`Len(a_)`,(({a:e})=>"Str"===V(e)?y(e[1].length):y(e.length-1))),he(ie`Postfix(a_, b_)`,(({a:e,b:t})=>S(t)(e))),he(ie`Map(f_, a_)`,(({f:e,a:t})=>{let r=Z(t);for(let n=1;n<t.length;++n)r[n]=be(S(e)(t[n]));return r})),he(ie`Reduce(f_, a_)`,(({f:e,a:t})=>{let r=t[1];for(let n=2;n<t.length;++n)r=be(S(e)(r,t[n]));return r})),he(ie`Reduce(f_, a_, s_)`,(({f:e,a:t,s:r})=>{let n=r;for(let r=1;r<t.length;++r)n=be(S(e)(n,t[r]));return n})),he(ie`Apply(f_, a_)`,(({f:e,a:t})=>(t[0]=e,t))),he(ie`Append(a_, b_)`,(({a:e,b:t})=>{const r=Z(e);return r.push(t),r})),he(ie`Cat(l___)`,(({l:e})=>{let t="";for(let r=1;r<e.length;++r)t+=e[r][1];return L(t)})),he(ie`If(c_, t_, f_)`,(({c:e,t,f:r})=>Y(be(e))?be(t):be(r))),he(ie`Cond(s__List)`,(({s:e})=>{for(let t=1;t<e.length;++t){const r=e[t];if(Y(be(r[1])))return be(r[2])}return A})),he(ie`While(c_, e_)`,(({c:e,e:t})=>{let r=A;for(;Y(be(e));)r=be(t);return r})),he(ie`Repeat(e_, c_)`,(({e,c:t})=>{let r=be(e);for(;Y(be(C(t)));)r=be(e);return r})),he(ie`Match(p_, e_)`,(({p:e,e:t})=>{let r={};if(ne(t,e,r)){for(const[e,t]of Object.entries(r))m(_(e),t);return v}return D})),he(ie`Subst(e_, List(s__Tag))`,(({e,s:t})=>{const r={};for(let e=1;e<t.length;++e)r[t[e][1][1]]=t[e][2];return re(e,r)}));let me=0;he(ie`Block(List(vars__), e_)`,(({vars:e,e:t})=>{const r={};for(let t=1;t<e.length;++t)if("Literal"===V(e[t])&&(r[e[t][1]]=T(e[t][1]+me)),"Def"===V(e[t])){const n=e[t][1][1];r[n]=T(n+me)}me++,e=re(e,r),t=re(t,r),o.push({});for(let t=1;t<e.length;++t)if("Literal"===V(e[t])&&p(e[t][1]),"Def"===V(e[t])){const r=e[t][1][1],n=p(r);m(n,e[t][2])}let n=be(t);return o.pop(),"Return"===V(n)?n[1]:n})),he(ie`Table(e_, List(v_Literal, a_, b_))`,(({e,v:t,a:r,b:n})=>{const o=w();for(let a=be(r)[1];a<=be(n)[1];++a){const r={};r[t[1]]=y(a),o.push(be(re(e,r)))}return o})),he(ie`Table(e_, List(v_Literal, a_, b_), List(w_Literal, c_, d_))`,(({e,v:t,a:r,b:n,w:o,c:a,d:l})=>{const i=w();for(let s=be(r)[1];s<=be(n)[1];++s){const r=w();for(let n=be(a)[1];n<=be(l)[1];++n){const a={};a[t[1]]=y(s),a[o[1]]=y(n),r.push(be(re(e,a)))}i.push(r)}return i})),he(ie`ClearAll()`,(({})=>{for(let e in n)delete n[e];return A})),he(ie`Clear(v__Literal)`,(({v:e})=>{for(let t=1;t<e.length;++t)delete n[e[t][1]];return A})),he(ie`Print(e__)`,(({e})=>{for(let t=1;t<e.length;++t)console.log(ue(e[t]));return A})),he(ie`ToString(e_)`,(({e})=>L(ue(e)))),he(ie`ToLisp(e_)`,(({e})=>L(ce(e)))),he(ie`Set(c__)`,(({c:e})=>{const t=[e[1]];let r=!1;for(let n=2;n<e.length;++n)ee(e[n],e[n-1])?r=!0:t.push(e[n]);return r?F(...t):null})),he(ie`In(a_, b_Set)`,(({a:e,b:t})=>{for(let r=1;r<t.length;++r)if(ee(e,t[r]))return v;return D})),he(ie`Union(a_Set, b_Set)`,(({a:e,b:t})=>{const r=e.slice(1).concat(t.slice(1));return F(...r)})),he(ie`Intersection(a_Set, b_Set)`,(({a:e,b:t})=>{const r=[];let n=1,o=1;for(;n<e.length&&o<t.length;)_e(e[n],t[o])?n++:(_e(t[o],e[n])||(r.push(e[n]),n++),o++);return F(...r)})),he(ie`And(c__)`,(({c:e})=>{for(let t=1;t<e.length;++t)if(!Y(be(e[t])))return D;return v})),he(ie`Or(c__)`,(({c:e})=>{for(let t=1;t<e.length;++t)if(Y(be(e[t])))return v;return D})),he(ie`Not(c_)`,(({c:e})=>Y(e)?D:v)),he(ie`Equal(a_,b_)`,(({a:e,b:t})=>ee(e,t)?v:D)),he(ie`Less(a_,b_)`,(({a:e,b:t})=>_e(e,t)?v:D)),he(ie`LessEqual(a_,b_)`,ie`Or(Less(a, b), Equal(a, b))`),he(ie`Great(a_,b_)`,ie`Less(b, a)`),he(ie`GreatEqual(a_,b_)`,ie`Or(Less(b, a), Equal(a, b))`),he(ie`Kind(a_)`,(({a:e})=>{const t=V(e);return"compound"===t?A:_(t)})),he(ie`Plus()`,ie`0`),he(ie`Plus(a_)`,ie`a`),he(ie`Plus(0, a__)`,ie`Plus(a)`),he(ie`Plus(a_Integer, b_Integer, c___)`,(({a:e,b:t,c:r})=>X(e[1]+t[1],r))),he(ie`UnaryMinus(a_Integer)`,(({a:e})=>y(-e[1]))),he(ie`UnaryMinus(a_)`,ie`Times(-1, a)`),he(ie`Subtract(a_, b_)`,ie`Plus(a, Times(-1, b))`),he(ie`Times()`,ie`1`),he(ie`Times(a_)`,ie`a`),he(ie`Times(1, a__)`,ie`Times(a)`),he(ie`Times(0, a__)`,ie`0`),he(ie`Times(a_Integer, b_Integer, c___)`,(({a:e,b:t,c:r})=>H(e[1]*t[1],r))),he(ie`Power(_, 0)`,ie`1`),he(ie`Power(1, _)`,ie`1`),he(ie`Power(a_, 1)`,ie`a`),he(ie`Power(a_Integer, b_Integer)`,(({a:e,b:t})=>t[1]>0?y(Math.pow(e[1],t[1])):null)),he(ie`Quotient(a_Integer, b_Integer)`,(({a:e,b:t})=>y(Math.floor(e[1]/t[1])))),he(ie`Mod(a_Integer, b_Integer)`,(({a:e,b:t})=>0==e[1]?y(0):e[1]>0==t[1]>0?y(e[1]%t[1]):y(e[1]%t[1]+t[1]))),se`Numeric(a_Integer) := True`,se`Numeric(a_) := False`,t.toString=ue,t.Eval=be,t.Form=P,t.mkReservedSymbol=f,t.lookup=_,t.Cons=S,t.Integer=y,t.Str=L,t.ownValueSet=m,t.kind=V,t.isAtom=j,t.apply=(e,t)=>{t[0]=_(e)},t.equal=ee,t.less=_e,t.copy=Z,t.has=te,t.subst=re,t.match=ne,t.addRule=he,t.parse=le,t.isStr=e=>e[0]===I,t.$=se,t.$$=ie,t.reservedWords=()=>Object.keys(r).sort(),t.globalWords=()=>Object.keys(n).sort(),e.exports=t},986:(e,t,r)=>{const n=r(884),o=r(882),{$:a,$$:l,kind:i,addRule:s,equal:u,copy:c,Form:_,Eval:f,Plus:p,Times:g,Divide:b,Integer:h,List:m,toString:d}=o,{nuples:y,permutations:I,sign:L}=n,x=_("Dot",{Flat:!0}),T=e=>{if("List"===i(e)){let t=m();for(let r=1;r<e.length;++r)if(1==r)t=T(e[r]);else if(!u(T(e[r]),t))throw"Not a tensor";return t.splice(1,0,h(e.length-1)),t}return m()};s(l`Plus(a_List, b_List, c___)`,(({a:e,b:t,c:r})=>{if(e.length===t.length){const n=m();for(let r=1;r<e.length;++r)n.push(f(p(e[r],t[r])));return f(p(n,r))}return null})),s(l`Times(a_, b_List, c___)`,(({a:e,b:t,c:r})=>{const n=m();for(let r=1;r<t.length;++r)n.push(f(g(e,t[r])));return f(g(n,r))}));const S=e=>{const t=m(),r=e[0];if(1==e.length){for(let e=1;e<=r;++e)t.push(h(0));return t}const n=e.slice(1);for(let e=1;e<=r;++e)t.push(S(n));return t},R=_("ConstantArray");s(l`ConstantArray(c_, List(l__Integer))`,(({c:e,l:t})=>{const r=t.slice(1).map((e=>e[1])),n=S(r);for(let t of y(r,1))w(n,t,c(e));return n}));const P=(e,t)=>{let r=e;for(let e=0;e<t.length;++e)r=r[t[e]];return r},w=(e,t,r)=>{let n=e;for(let e=0;e<t.length-1;++e)n=n[t[e]];n[t[t.length-1]]=r};s(l`Dot(a_)`,l`a`),s(l`Dot()`,l`1`),s(l`Dot(a_List, b_List, c___)`,(({a:e,b:t,c:r})=>{const n=T(e),o=T(t);if(2==n.length&&2==o.length&&e.length==t.length){let n=h(0);for(let r=1;r<e.length;++r)n=f(p(n,g(e[r],t[r])));return f(x(n,r))}if(n[n.length-1][1]==o[1][1]){const a=[],l=o[1][1];for(let e=1;e<n.length-1;++e)a.push(n[e][1]);for(let e=2;e<o.length;++e)a.push(o[e][1]);const i=S(a);for(let r of y(a,1)){let o=h(0);const a=r.slice(0,n.length-2);a.push(0);const s=r.slice(n.length-2);s.unshift(0);for(let r=1;r<=l;++r){a[n.length-2]=r,s[0]=r;const l=P(e,a),i=P(t,s);o=f(p(o,g(l,i)))}w(i,r,o)}return f(x(i,r))}return null})),s(l`Dot(a_, b_List, c___)`,(({a:e,b:t,c:r})=>{const n=T(t).slice(1).map((e=>e[1])),o=S(n);for(let r of y(n,1)){const n=P(t,r);w(o,r,f(g(e,n)))}return f(x(o,r))})),s(l`Dot(b_List, a_Integer, c___)`,l`Dot(a, b, c)`),s(l`Dot(b_List, a_Rational, c___)`,l`Dot(a, b, c)`),s(l`Dot(b_List, a_Complex, c___)`,l`Dot(a, b, c)`);const $=e=>{const t=T(e);if(3!=t.length)throw"Not a matrix";return[t[1][1],t[2][1]]},v=(e,t)=>{const[r,n]=$(e);for(let o=1;o<=r;++o)for(let r=1;r<=n;++r)t(o,r,e)},D=e=>{const[t,r]=$(e);let n=m();for(let o=1;o<=t&&o<=r;++o)n.push(e[o][o]);return n};_("Diagonal"),s(l`Diagonal(A_)`,(({A:e})=>D(e))),_("IdentityMatrix"),s(l`IdentityMatrix(n_)`,l`Table(If(i=j,1,0),[i,1,n],[j,1,n])`),_("DiagonalMatrix"),s(l`DiagonalMatrix(l_List)`,l`Table(If(i=j,@l(i),0),[i,1,#l],[j,1,#l])`);const A=(e,t)=>{const[r,n]=$(e),o=D(t);v(t,((e,r)=>{r<e&&(t[e][r]=h(0))}));const a=m(h(0));for(let e=n-1;e>=1;--e)a.push(f(p(o[e+1],a[a.length-1])));for(let e=1;e<=n;++e)t[e][e]=f(g(-1,a[n-e+1]));return((e,t)=>{const[r,n]=$(e),[o,a]=$(t);if(n!=o)throw"Wrong dimensions.";let l=S([r,a]);return v(l,((r,o)=>{let a=p();for(let l=1;l<=n;++l)a.push(f(g(e[r][l],t[l][o])));l[r][o]=f(a)})),l})(t,e)},k=e=>{const[t,r]=$(e);let n=c(e);for(let t=1;t<r;++t)n=A(e,n);return r%2==0?f(g(-1,n[1][1])):n[1][1]},C=_("Det");s(l`Det(A_)`,(({A:e})=>k(e)));const E=_("Tr");s(l`Tr(a_List)`,(({a:e})=>{try{return(e=>{const[t,r]=$(e);if(1==t)return e[1][1];let n=h(0);for(let r=1;r<=t;++r)n=f(p(n,e[r][r]));return n})(e)}catch(e){return console.log(e),null}}));const q=(e,t,r)=>{const n=e[t];e[t]=e[r],e[r]=n},M=(e,t,r,n)=>{const[o,a]=$(e);for(let o=1;o<=a;++o)e[t][o]=f(p(e[t][o],g(n,e[r][o])))},N=(e,t,r)=>{const[n,o]=$(e);for(let n=1;n<=o;++n)e[t][n]=f(g(r,e[t][n]))};function*B(e){const[t,r]=$(e);yield{A:e,op:"init"};let n=1;for(let o=1;o<=r;++o){let r;for(r=n;r<=t&&u(e[r][o],h(0));++r);if(!(r>t)){for(r!=n&&(q(e,r,n),yield{A:e,op:"rswap",i:r,ip:n}),yield{op:"pivot",pivot:[n,o]},r=n+1;r<=t;++r){const t=f(g(-1,b(e[r][o],e[n][o])));u(t,h(0))||(M(e,r,n,t),yield{A:e,op:"radd",i:r,ip:n,k:t})}if(n==t)break;n+=1}}}function*O(e){const[t,r]=$(e);yield{A:e,op:"init"};let n=1;for(let o=1;o<=r;++o){let r;for(r=n;r<=t&&u(e[r][o],h(0));++r);if(!(r>t)){r!=n&&(q(e,r,n),yield{A:e,op:"rswap",i:r,ip:n}),yield{op:"pivot",pivot:[n,o]};{const t=f(b(1,e[n][o]));u(t,h(1))||(N(e,n,t),yield{A:e,op:"rscale",i:n,ip:n,k:t})}for(r=n-1;r>=1;--r){const t=f(g(-1,b(e[r][o],e[n][o])));u(t,h(0))||(M(e,r,n,t),yield{A:e,op:"radd",i:r,ip:n,k:t})}for(r=n+1;r<=t;++r){const t=f(g(-1,b(e[r][o],e[n][o])));u(t,h(0))||(M(e,r,n,t),yield{A:e,op:"radd",i:r,ip:n,k:t})}if(n==t)break;n+=1}}}const F=(e,t,r)=>{const[n,o]=$(e),a=S([n-1,o-1]);return v(a,((n,o)=>{a[n][o]=e[n+(n>=t?1:0)][o+(o>=r?1:0)]})),a},X=e=>{const[t,r]=$(e);let n=S([r,t]);return v(e,((t,r)=>{n[r][t]=e[t][r]})),n},H=_("Transpose");s(l`Transpose(a_List)`,(({a:e})=>{try{return X(e)}catch(e){return console.log(e),null}}));const j=_("Adj");s(l`Adj(a_List)`,(({a:e})=>{try{return(e=>{const[t,r]=$(e),n=S([t,r]);return v(e,((t,r)=>{n[t][r]=f(g(Math.pow(-1,t+r),k(F(e,t,r))))})),X(n)})(e)}catch(e){return console.log(e),null}}));const G=_("Inverse");s(l`Inverse(a_List)`,(({a:e})=>{try{return(e=>{const[t,r]=$(e);if(t!=r)throw"Not a square matrix.";let n=S([r,2*r]);v(e,((t,o)=>{n[t][o]=e[t][o],n[t][o+r]=h(t==o?1:0)}));for(let e of O(n));const o=S([r,r]);return v(o,((e,t)=>{o[e][t]=n[e][t+r]})),o})(e)}catch(e){return console.log(e),null}}));const U=_("RowReduce");s(l`RowReduce(a_)`,(({a:e})=>{try{return(e=>{const[t,r]=$(e);let n=S([t,r]);v(e,((t,r)=>{n[t][r]=e[t][r]}));for(let e of O(n));return n})(e)}catch(e){return console.log(e),null}})),_("GaussianElimination"),s(l`GaussianElimination(A_)`,(({A:e})=>{const[t,r]=$(e);let n=S([t,r]);v(e,((t,r)=>{n[t][r]=e[t][r]}));for(let e of B(n));return n}));const z={Dot:x,dimensions:T,size:$,buildTensor:S,tensorGet:P,tensorSet:w,Det:C,Tr:E,Transpose:H,Adj:j,Inverse:G,forEachEntry:v,RowReduce:U,ConstantArray:R,del:F,reducedRowEchelonSteps:O,rowEchelonSteps:B};e.exports=z},884:(e,t,r)=>{const n=r(882),{$:o,$$:a,Form:l,ownValueSet:i,equal:s,kind:u,apply:c,match:_,Eval:f,addRule:p,Integer:g,Plus:b,Times:h,Power:m,Sequence:d,List:y,Less:I,True:L,False:x,toString:T}=n;function S(e,t){return Math.abs(0==t?e:S(t,e%t))}const R=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021,1031,1033,1039,1049,1051,1061,1063,1069,1087,1091,1093,1097,1103,1109,1117,1123,1129,1151,1153,1163,1171,1181,1187,1193,1201,1213,1217,1223,1229,1231,1237,1249,1259,1277,1279,1283,1289,1291,1297,1301,1303,1307,1319,1321,1327,1361,1367,1373,1381,1399,1409,1423,1427,1429,1433,1439,1447,1451,1453,1459,1471,1481,1483,1487,1489,1493,1499,1511,1523,1531,1543,1549,1553,1559,1567,1571,1579,1583,1597,1601,1607,1609,1613,1619,1621,1627,1637,1657,1663,1667,1669,1693,1697,1699,1709,1721,1723,1733,1741,1747,1753,1759,1777,1783,1787,1789,1801,1811,1823,1831,1847,1861,1867,1871,1873,1877,1879,1889,1901,1907,1913,1931,1933,1949,1951,1973,1979,1987,1993,1997,1999,2003,2011,2017,2027,2029,2039,2053,2063,2069,2081,2083,2087,2089,2099,2111,2113,2129,2131,2137,2141,2143,2153,2161,2179,2203,2207,2213,2221,2237,2239,2243,2251,2267,2269,2273,2281,2287,2293,2297,2309,2311,2333,2339,2341,2347,2351,2357,2371,2377,2381,2383,2389,2393,2399,2411,2417,2423,2437,2441,2447,2459,2467,2473,2477,2503,2521,2531,2539,2543,2549,2551,2557,2579,2591,2593,2609,2617,2621,2633,2647,2657,2659,2663,2671,2677,2683,2687,2689,2693,2699,2707,2711,2713,2719,2729,2731,2741,2749,2753,2767,2777,2789,2791,2797,2801,2803,2819,2833,2837,2843,2851,2857,2861,2879,2887,2897,2903,2909,2917,2927,2939,2953,2957,2963,2969,2971,2999,3001,3011,3019,3023,3037,3041,3049,3061,3067,3079,3083,3089,3109,3119,3121,3137,3163,3167,3169,3181,3187,3191,3203,3209,3217,3221,3229,3251,3253,3257,3259,3271,3299,3301,3307,3313,3319,3323,3329,3331,3343,3347,3359,3361,3371,3373,3389,3391,3407,3413,3433,3449,3457,3461,3463,3467,3469,3491,3499,3511,3517,3527,3529,3533,3539,3541,3547,3557,3559,3571,3581,3583,3593,3607,3613,3617,3623,3631,3637,3643,3659,3671,3673,3677,3691,3697,3701,3709,3719,3727,3733,3739,3761,3767,3769,3779,3793,3797,3803,3821,3823,3833,3847,3851,3853,3863,3877,3881,3889,3907,3911,3917,3919,3923,3929,3931,3943,3947,3967,3989,4001,4003,4007,4013,4019,4021,4027,4049,4051,4057,4073,4079,4091,4093,4099,4111,4127,4129,4133,4139,4153,4157,4159,4177,4201,4211,4217,4219,4229,4231,4241,4243,4253,4259,4261,4271,4273,4283,4289,4297,4327,4337,4339,4349,4357,4363,4373,4391,4397,4409,4421,4423,4441,4447,4451,4457,4463,4481,4483,4493,4507,4513,4517,4519,4523,4547,4549,4561,4567,4583,4591,4597,4603,4621,4637,4639,4643,4649,4651,4657,4663,4673,4679,4691,4703,4721,4723,4729,4733,4751,4759,4783,4787,4789,4793,4799,4801,4813,4817,4831,4861,4871,4877,4889,4903,4909,4919,4931,4933,4937,4943,4951,4957,4967,4969,4973,4987,4993,4999,5003,5009,5011,5021,5023,5039,5051,5059,5077,5081,5087,5099,5101,5107,5113,5119,5147,5153,5167,5171,5179,5189,5197,5209,5227,5231,5233,5237,5261,5273,5279,5281,5297,5303,5309,5323,5333,5347,5351,5381,5387,5393,5399,5407,5413,5417,5419,5431,5437,5441,5443,5449,5471,5477,5479,5483,5501,5503,5507,5519,5521,5527,5531,5557,5563,5569,5573,5581,5591,5623,5639,5641,5647,5651,5653,5657,5659,5669,5683,5689,5693,5701,5711,5717,5737,5741,5743,5749,5779,5783,5791,5801,5807,5813,5821,5827,5839,5843,5849,5851,5857,5861,5867,5869,5879,5881,5897,5903,5923,5927,5939,5953,5981,5987,6007,6011,6029,6037,6043,6047,6053,6067,6073,6079,6089,6091,6101,6113,6121,6131,6133,6143,6151,6163,6173,6197,6199,6203,6211,6217,6221,6229,6247,6257,6263,6269,6271,6277,6287,6299,6301,6311,6317,6323,6329,6337,6343,6353,6359,6361,6367,6373,6379,6389,6397,6421,6427,6449,6451,6469,6473,6481,6491,6521,6529,6547,6551,6553,6563,6569,6571,6577,6581,6599,6607,6619,6637,6653,6659,6661,6673,6679,6689,6691,6701,6703,6709,6719,6733,6737,6761,6763,6779,6781,6791,6793,6803,6823,6827,6829,6833,6841,6857,6863,6869,6871,6883,6899,6907,6911,6917,6947,6949,6959,6961,6967,6971,6977,6983,6991,6997,7001,7013,7019,7027,7039,7043,7057,7069,7079,7103,7109,7121,7127,7129,7151,7159,7177,7187,7193,7207,7211,7213,7219,7229,7237,7243,7247,7253,7283,7297,7307,7309,7321,7331,7333,7349,7351,7369,7393,7411,7417,7433,7451,7457,7459,7477,7481,7487,7489,7499,7507,7517,7523,7529,7537,7541,7547,7549,7559,7561,7573,7577,7583,7589,7591,7603,7607,7621,7639,7643,7649,7669,7673,7681,7687,7691,7699,7703,7717,7723,7727,7741,7753,7757,7759,7789,7793,7817,7823,7829,7841,7853,7867,7873,7877,7879,7883,7901,7907,7919];function P(e){const t=[];for(let r of R){let n=0;for(;e%r==0;)e/=r,n+=1;if(0!=n&&t.push([r,n]),1==e)break}if(1==e)return t;throw"Factorization failed."}function*w(e,t=0){if(1===e.length)for(let r=t;r<=e[0];++r)yield[r];else{let r=e.slice(),n=r.pop();for(let e of w(r,t))for(let r=t;r<=n;++r)yield[...e,r]}}function $(e,t){if(t>e)return;t>e/2&&(t=e-t);let[r,n]=[1,1];for(let o=1;o<=t;++o)r*=e-o+1,n*=o;return r/n}const v=l("GCD"),D=l("FactorInteger"),A=l("Binomial");p(a`GCD(a_Integer, b_Integer)`,(({a:e,b:t})=>g(S(e[1],t[1])))),p(a`Binomial(a_Integer, b_Integer)`,(({a:e,b:t})=>g($(e[1],t[1])))),p(a`FactorInteger(a_Integer)`,(({a:e})=>{const t=y(),r=P(e[1]);for(let e=0;e<r.length;++e)t.push(y(r[e][0],r[e][1]));return t}));const k={GCD:v,Binomial:A,FactorInteger:D,gcd:S,lcm:function(e,t){return Math.abs(e*t)/S(e,t)},primes:R,factorization:P,isSquare:function(e){if(1==e||0==e)return!0;const t=P(e);for(let e=0;e<t.length;++e)if(t[e][1]%2==1)return!1;return!0},nuples:w,divisors:function*(e){if(1==(e=Math.abs(e)))yield 1,yield-1;else{const t=P(e),r=t.map((e=>e[0])),n=t.map((e=>e[1]));for(let e of w(n)){let t=1;for(let o=0;o<n.length;++o)t*=Math.pow(r[o],e[o]);yield t,yield-t}}},binomial:$,permutations:function*e(t){if(1===t.length)yield t;else{let[r,...n]=t;for(let o of e(n))for(let e=0;e<t.length;e++){let t=o.slice(0,e),n=o.slice(e);yield[...t,r,...n]}}},sign:function(e){let t=1;for(let r=0;r<e.length;++r)for(let n=r+1;n<e.length;++n)e[r]>e[n]&&(t=-t);return t},range:function*(e,t,r=1){for(let n=e;n<t;n+=r)yield n}};e.exports=k},237:(e,t,r)=>{const n=r(882),{$$:o,kind:a,addRule:l,equal:i,copy:s,Form:u,Eval:c,lookup:_,newDef:f,Plus:p,Times:g,Divide:b,Cons:h,Integer:m,Null:d,List:y,toString:I}=n;let L;const x=e=>{const t=function(e){for(var t=0,r=1779033703^e.length;t<e.length;t++)r=(r=Math.imul(r^e.charCodeAt(t),3432918353))<<13|r>>>19;return function(){return r=Math.imul(r^r>>>16,2246822507),r=Math.imul(r^r>>>13,3266489909),(r^=r>>>16)>>>0}}(e.toString(2));var r,n,o,a;r=t(),n=t(),o=t(),a=t(),L=function(){var e=(r|=0)-((n|=0)<<27|n>>>5)|0;return r=n^((o|=0)<<17|o>>>15),n=o+(a|=0)|0,o=a+e|0,((a=r+e|0)>>>0)/4294967296}},T=(e=0,t=99)=>Math.floor(e+(t+1-e)*L()),S=(e,t)=>{const r=[];for(let n=e-t+1;n<=e;++n){const e=T(1,n);-1==r.findIndex((t=>t==e))?r.push(e):r.push(n)}return r.sort()};function R(e){for(var t=e.length-1;t>0;t--){var r=T(0,t),n=e[t];e[t]=e[r],e[r]=n}}x("init"),u("RandInteger",{Impure:!0}),l(o`RandInteger(a_Integer, b_Integer)`,(({a:e,b:t})=>m(T(e[1],t[1])))),u("RandCombination",{Impure:!0}),l(o`RandCombination(n_Integer, m_Integer)`,(({n:e,m:t})=>{const r=S(e[1],t[1]).map((e=>m(e)));return y(...r)})),u("RandPermutation",{Impure:!0}),l(o`RandPermutation(n_Integer)`,(({n:e})=>{const t=[];for(let r=1;r<=e[1];++r)t.push(m(r));return R(t),y(...t)})),l(o`RandPermutation(l_List)`,(({l:e})=>{const t=e.slice(1);return R(t),y(...t)})),u("Seed",{Impure:!0}),l(o`Seed(a_)`,(({a:e})=>(x(I(e)),d)));const P={seed:x,rand:()=>L(),randInteger:T,randCombination:S};e.exports=P}},t={};return function r(n){if(t[n])return t[n].exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}(579)})()}));