Solve for x Calculator | Instant Answers (2024)

Related Content
  • Synthetic Division
  • Relative Extrema Calculator
  • Riemann Sum Calculator
  • Inflection Point Calculator
  • Euler’s Method Calculator
  • Implicit Differentiation Calculator
  • Tangent Plane Calculator

Thank you!


On behalf of our dedicated team, we thank you for your continued support. It's fulfilling to see so many people using Voovers to find solutions to their problems. Thanks again and we look forward to continue helping you along your journey!



Nikkolas and Alex
Founders and Owners of Voovers

"+n(t)+"\n";return(i||s)&&(r+=n(t)+"

    \n"+i+s+n(t)+"

\n"),r+=""},this.tree=function(t){for(var e=[],n=0;n

i.numVal)&&(e.pop(),e.push(r))}}function Rt(e,n){if(e.equals(1))return new Dt(0);var r;if(e.fname===w&&e.multiplier.equals(1))return r=t.divide(Rt(e.args[0]),new Dt(2)),e.power.sign()<0&&r.negate(),r;if(e.equals(0))throw new wt(a.LOG+"(0) is undefined!");if(e.isImaginary())return E.evaluate(e,a.LOG);if(e.isConstant()&&void 0!==n&&n.isConstant())r=new Dt(Math.log(e)/Math.log(n));else if(e.group===f&&e.power.multiplier.lessThan(0)||"-1"===e.power.toString())e.power.negate(),r=Rt(e).negate();else if("e"===e.value&&e.multiplier.equals(1)){var i=e.power;r=U(i)?i:new Dt(i)}else if(e.group===p&&"exp"===e.fname){var s=e.args[0];r=e.multiplier.equals(1)?t.multiply(s,new Dt(e.power)):t.symfunction(a.LOG,[e])}else if(a.PARSE2NUMBER&&Z(e)){var o;e.multiplier.lessThan(0)&&(e.negate(),o=t.multiply(new Dt(Math.PI),new Dt("i"))),r=new Dt(Math.log(e.multiplier.toDecimal())),o&&(r=t.add(r,o))}else{e.power.equals(1)||e.contains("e")||(s=e.group===f?e.power:new Dt(e.power),e.toLinear()),r=arguments.length>1&&q(arguments)?new Dt(1):t.symfunction(a.LOG,arguments),s&&(r=t.multiply(s,r))}return r}function qt(e,n){var r,i,s,o,a=n&&n.isConstant()||void 0===n;return e.isConstant()&&a?(r=e,n&&n.lessThan(0)&&(n=z(n),r=(i=Number(e).toExponential().toString().split("e"))[0],s=i[1]),o=new Dt(et(r,Number(n||0))),t.multiply(o,t.pow(new Dt(10),new Dt(s||0)))):t.symfunction("round",arguments)}function Ct(t){var e=t%2;return e<0&&(e=2+e),e>=0&&e<=.5?1:e>.5&&e<=1?2:e>1&&e<=1.5?3:4}function Lt(t){if(!isFinite(t)){var e=Math.sign(t),n=new Dt(String(Math.abs(t)));return n.multiplier=n.multiplier.multiply(new Ut(e)),n}if(U(t))return t;if("number"==typeof t)try{t=Ut.simple(t)}catch(e){t=new Ut(t)}var r=new Dt(0);return r.multiplier=t,r}function _t(e){if(e.group===p&&""===e.fname)return t.expand(e.args[0]);if(!e.symbols)return e;var n=e.clone();try{if(!e.symbols)return e;for(var r in e.symbols){var i=e.symbols[r];e.symbols[r]=_t(i)}var s=(e=t.parse(e)).power,o=e.multiplier.clone(),a=Number(s);if(X(a)&&a>0&&e.isComposite()){var u=new Dt(0);for(var i in e.symbols){var l=e.symbols[i];l.power.greaterThan(1)&&(l=t.expand(l)),u=t.add(u,l)}for(var c=a-1,h=u.clone(),v=0;v1&&(T(n)&&(-1===s.indexOf(n)&&s.push(n),r.push(n)),e=o),n++}return r.sort(function(t,e){return t-e})}(e)[0];if(!n)return C("Unable to compute prime factors. This should not happen. Please review and report."),t;var r=new Ut(Math.log(e)/Math.log(n)).multiply(t.power);if(r.den>t.power.den)return t;t=X(r)?Dt(Math.pow(n,r)):new Dt(n).setPower(r)}return t}this.toTeX=function(e,n){n=n||{};var r="string"==typeof e?this.toObject(e):e,i=[],s=void 0===n.cdot?"\\cdot":n.cdot;if(V(r)){for(var o,u,l=[],c=0;c0?"\\frac{d}{d "+S[0]+"}":"\\frac{d}{d x}"}else N=2===g.length?"\\frac{d}{d "+g[1]+"}":"\\frac{d^{"+g[2]+"}}{d "+this.toTeX(g[1])+"^{"+g[2]+"}}";m=N+"\\left("+E+"\\right)"}else if("sum"===v||"product"===v){var A=[[],[],[],[]],x=0;for(c=0;cM&&M>0)return this.add(n,e);if(d===m&&y===h&&e.value===n.value){var E=e;e=n,n=E,d=e.group,y=n.group,b=e.power.toString(),M=n.power.toString()}var N,S,A,O=b===M,R=e.value,q=n.value,C=e.isComposite(),I=n.isComposite();if(C&&(N=Tt(e,"hash")),I&&(S=Tt(n,"hash")),d===v&&y===v&&n.isLinear()&&!e.isLinear()&&N!==S)return this.add(n,e);d===h&&y===h&&(R=N,q=S);var P=d===l&&y===u,T=e.value===n.multiplier.toString(),L=R===q||N===S&&void 0!==N||P&&T;if(L&&O&&d===y)if(P&&(n=n.convert(l)),d!==h||y!==c&&y!==l)if(A=e,e.multiplier.isOne()&&n.multiplier.isOne()&&d===v&&e.isLinear()&&n.isLinear())for(var _ in n.symbols){var D=n.symbols[_];A.attach(D)}else A.multiplier=A.multiplier.add(n.multiplier);else e.distributeMultiplier(),A=e.attach(n);else if(L&&d!==h)d===v&&y===h?(n.insert(e),A=n):(A=Dt.shell(h).attach([e,n])).value=d===h?N:R;else if(C&&e.isLinear()){var k=d===y,F=d===h&&y===h;if(F&&(k=e.value===n.value),e.distributeMultiplier(),n.isComposite()&&n.isLinear()&&k){for(var _ in n.distributeMultiplier(),n.symbols){D=n.symbols[_];e.attach(D)}A=e}else F&&e.value!==S||d===h&&!L?(A=Dt.shell(v).attach([e,n])).updateHash():A=e.attach(n)}else{if(d===p&&e.fname===w&&y!==f&&n.power.equals(.5)){var j=n.multiplier.clone();(n=nt(n.toUnitMultiplier().toLinear())).multiplier=j}2===e.length&&2===n.length&&rt(e.power)&&rt(n.power)?A=t.add(_t(e),_t(n)):(A=Dt.shell(v).attach([e,n])).updateHash()}if(A.multiplier.equals(0)&&(A=new Dt(0)),1===A.length){j=A.multiplier;(A=J(A.symbols)).multiplier=A.multiplier.multiply(j)}return A}if(i&&!r){E=e;e=n,n=E,E=i,i=r,r=E}var Z=G(n);if(r&&Z){var V=new jt;n.eachElement(function(n,r,i){V.set(r,i,t.add(e.clone(),n))}),n=V}else if(G(e)&&Z)n=e.add(n);else if(r&&B(n))n.each(function(r,i){i--,n.elements[i]=t.add(e.clone(),n.elements[i])});else if(B(e)&&B(n))n.each(function(r,i){i--,n.elements[i]=t.add(e.elements[i],n.elements[i])});else{if(B(e)&&G(n))return t.add(n,e);if(G(e)&&B(n)){if(n.elements.length===e.rows()){V=new jt;var X=e.cols();return n.each(function(n,r){for(var i=[],s=0;se.group&&n.group!==v)return this.multiply(n,e);if(e.group===m&&n.group===h&&e.value===n.value){var M=e;e=n,n=M}var E=e.group,N=n.group,S=n.multiplier.num,A=n.multiplier.den;if(E!==p||e.fname!==w||n.isConstant()||e.args[0].value!==n.value||e.args[0].multiplier.lessThan(0))E===p&&e.fname===w&&e.multiplier.equals(1)&&e.power.equals(-1)&&n.isConstant()&&e.args[0].equals(n)&&(e=t.symfunction(w,[n.clone()]),n=new Dt(1));else{var O=e.power,R=t.parse(e.multiplier);(e=t.multiply(R,e.args[0].clone())).setPower(new Ut(.5).multiply(O)),E=e.group}var q=e.value,C=n.value,I=(d=new Ut(e.sign()),E===l&&N===u&&n.multiplier.equals(e.value)),P=I?new Ut(1).multiply(e.multiplier).abs():e.multiplier.multiply(n.multiplier).abs();g=e.clone().toUnitMultiplier();if(n=n.clone().toUnitMultiplier(!0),E===p&&N===p){var T=e.args[0].clone(),L=n.args[0].clone();if(e.fname===w&&n.fname===w&&e.isLinear()&&n.isLinear()){var _=t.divide(T,L).invert();_.gt(1)&&X(_)&&(g=t.multiply(e.args[0].clone(),nt(_.clone())),n=new Dt(1))}else if(e.fname===b&&n.fname===b&&!T.isConstant()&&!L.isConstant()&&n.power<0){var D=t.subtract(T.clone(),L.clone());if(D.isConstant())if(M=new Dt(1),D<0){for(var k=0,F=Math.abs(D);k<=F;k++){var j=t.add(T.clone(),new Dt(k));M=t.multiply(M,j)}g=t.multiply(t.pow(T,new Dt(e.power)),t.pow(M,new Dt(n.power))),n=new Dt(1)}else{for(k=0,F=Math.abs(D);k<=F;k++){j=t.add(L.clone(),new Dt(k));M=t.multiply(M,j)}g=t.multiply(t.pow(M,new Dt(e.power)),t.pow(L,new Dt(n.power))),n=new Dt(1)}}}if(q===C&&E===h&&E===N&&(q=e.text("hash"),C=n.text("hash")),N===f&&n.previousGroup===h&&E===h&&(q=Tt(e,"hash",f)),q!==C&&!I||E===h&&(N===c||N===l||N===p)||E===h&&N===m)if(E===m&&e.isLinear())if(N===m&&n.distributeExponent(),N===m&&n.isLinear()){for(var j in n.symbols){var Z=n.symbols[j];g=g.combine(Z)}g.multiplier=g.multiplier.multiply(n.multiplier)}else g.combine(n);else if(E!==u){if(E===m)g.distributeExponent(),g.combine(n);else if(!n.isOne()){var V=n.multiplier.clone();n.toUnitMultiplier(),(g=Dt.shell(m).combine([g,n])).multiplier=g.multiplier.multiply(V)}}else g=n.clone().toUnitMultiplier();else{var z=e.power,H=n.power,$=U(z),W=U(H),Y=$||W;if(E===h&&N!==h&&n.previousGroup!==h&&z.equals(1))g=new Dt(0),e.each(function(e){g=t.add(g,t.multiply(e,n.clone()))},!0);else{if(g.power=Y?t.add(U(z)?z:new Dt(z),U(H)?H:new Dt(H)):E===u?z:z.add(H),g.power.equals(0)&&(g=g.convert(u)),Y&&g.convert(f),e.imaginary&&n.imaginary)rt(g.power%2)&&(g=new Dt(1),P.negate());g.group!==f&&g.previousGroup&&(g.previousGroup=void 0),g.multiplier=g.multiplier.multiply(n.multiplier)}}if(g.group===l){var Q=Math.log(g.value),K=Math.log(S)/Q,tt=Math.log(A)/Q,et=P.num/S,it=P.den/A;0!==K&&X(K)&&X(et)&&(g.power=g.power.add(new Ut(K)),P.num/=S),0!==tt&&X(tt)&&X(it)&&(g.power=g.power.subtract(new Ut(tt)),P.den/=A)}if(1===g.length){M=g.multiplier;(g=J(g.symbols)).multiplier=g.multiplier.multiply(M)}var st=g.power.toString();if(rt(st)&&g.fname===w){d*=g.sign();var ot=g.power;g=g.args[0],g=t.multiply(new Dt(P),t.pow(g,new Dt(ot.divide(new Ut(2))))),d<0&&g.negate()}else g.multiplier=g.multiplier.multiply(P).multiply(d),g.group===v&&g.isImaginary()&&g.distributeMultiplier();return g.group===l&&X(g.power.toDecimal())&&(g=g.convert(u)),g}s&&!i&&(M=e,e=n,n=M,M=s,s=i,i=M);var at=G(n),ut=G(e);if(i&&at){var lt=new jt;n.eachElement(function(n,r,i){lt.set(r,i,t.multiply(e.clone(),n))}),n=lt}else if(ut&&at)n=e.multiply(n);else if(i&&B(n))n.each(function(r,i){i--,n.elements[i]=t.multiply(e.clone(),n.elements[i])});else if(B(e)&&B(n))n.each(function(r,i){i--,n.elements[i]=t.multiply(e.elements[i],n.elements[i])});else{if(B(e)&&G(n))return this.multiply(n,e);if(G(e)&&B(n)){if(n.elements.length===e.rows()){lt=new jt;var ct=e.cols();return n.each(function(n,r){for(var i=[],s=0;s0&&3===Q)&&N.negate()}else{var $=n.multiplier.multiply(Ut.quick(1,2)),W=Math.pow(-1,$.num);N=rt($.den)?new Dt(-1).setPower($,!0):new Dt(W)}if(A<0&&!j&&N.negate(),g&&e.group!==f){var Y=rt(n.multiplier.den),J=rt(e.power),Q=N.power.toDecimal(),K=rt(Q);if(Y&&J&&!K){if(1===Q)N=t.symfunction(y,[N]);else if(X(Q))N=t.multiply(t.symfunction(y,[N.clone().toLinear()]),N.clone().setPower(new Ut(Q-1)));else{x=N.power;N=t.symfunction(y,[N.toLinear()]).setPower(x)}a.POSITIVE_MULTIPLIERS&&N.fname===y&&(N=N.args[0])}}if(n.equals(2)&&N.group===m){var tt=new Dt(1);N.each(function(e){tt=t.multiply(tt,t.pow(e,n))}),N=tt}}}if(N=kt(N),Z&&V&&(N=t.multiply(N,Ft(t.multiply(Z,V)))),N.fname===w){var et=N.group===f,nt=et?N.power.multiplier.toString():N.power.toString();if(rt(nt)){var st=et?t.divide(N.power,new Dt(2)):new Dt(N.power.divide(new Ut(2)));E=N.multiplier;(N=t.pow(N.args[0],st)).multiplier=N.multiplier.multiply(E)}}else if(!a.IGNORE_E&&N.isE()&&N.group===f&&N.power.contains("pi")&&N.power.contains(a.IMAGINARY)){var ot=n.stripVar(a.IMAGINARY);N=t.add(S.cos(ot),t.multiply(Dt.imaginary(),S.sin(ot)))}return N}if(B(e)&&i)e=e.map(function(e){return t.pow(e,n.clone())});else if(G(e)&&i){var at=new jt;e.eachElement(function(e,r,i){at.set(r,i,t.pow(e,n.clone()))}),e=at}else if(r&&G(n)){at=new jt;n.eachElement(function(n,r,i){at.set(r,i,t.pow(e.clone(),n))}),e=at}return e},this.comma=function(t,e){return t instanceof o||(t=o.create(t)),t.append(e),t},this.mod=function(t,e){return Y(t,e)},this.slice=function(t,e){return new i(t,e)},this.equals=function(t,e){return t.group===c||t.isLinear()||x("Cannot set equality for "+t.toString()),N[t.value]=e.clone(),e},this.percent=function(e){return t.divide(e,new Dt(100))},this.assign=function(e,n){if(e instanceof o&&n instanceof o)return e.elements.map(function(e,r){return t.assign(e,n.elements[r])}),Gt.fromArray(n.elements);if(e.parent){var r=e.parent;return r.elements[r.getter]=n,delete r.getter,r}if(e.group!==c)throw new Ot("Cannot complete operation. Incorrect LH value for "+e);return N[e.value]=n,n},this.function_assign=function(t,e){var n=t.elements.pop();return Q(n,t.elements,e)};var Vt=function(t){return new Dt(!0===t?1:0)};this.eq=function(t,e){return Vt(t.equals(e))},this.gt=function(t,e){return Vt(t.gt(e))},this.gte=function(t,e){return Vt(t.gte(e))},this.lt=function(t,e){return Vt(t.lt(e))},this.lte=function(t,e){return Vt(t.lte(e))},this.factorial=function(t){return this.symfunction(b,[t])},this.dfactorial=function(t){return this.symfunction(M,[t])}}a.FUNCTION_MODULES.push(Pt),at(Pt),Math.sign=Math.sign||function(t){return 0===(t=+t)||isNaN(t)?t:t>0?1:-1},Math.cosh=Math.cosh||function(t){var e=Math.exp(t);return(e+1/e)/2},Math.sech=Math.sech||function(t){return 1/Math.cosh(t)},Math.csch=Math.csch||function(t){return 1/Math.sinh(t)},Math.coth=Math.coth||function(t){return 1/Math.tanh(t)},Math.sinh=Math.sinh||function(t){var e=Math.exp(t);return(e-1/e)/2},Math.tanh=Math.tanh||function(t){if(t===1/0)return 1;if(t===-1/0)return-1;var e=Math.exp(2*t);return(e-1)/(e+1)},Math.asinh=Math.asinh||function(t){return t===-1/0?t:Math.log(t+Math.sqrt(t*t+1))},Math.acosh=Math.acosh||function(t){return Math.log(t+Math.sqrt(t*t-1))},Math.atanh=Math.atanh||function(t){return Math.log((1+t)/(1-t))/2},Math.log10=Math.log10||function(t){return Math.log(t)*Math.LOG10E},Math.trunc=Math.trunc||function(t){return isNaN(t)?NaN:t>0?Math.floor(t):Math.ceil(t)},Lt.getExpression=function(t,e){"last"!==t&&t||(t=E.length),"first"===t&&(t=1);var n=E[t-1];return n?new Lt(n):n},Lt.prototype={text:function(t,e){return e=e||19,t=t||"decimals",this.symbol.text_?this.symbol.text_(t):Tt(this.symbol,t,void 0,e)},latex:function(t){return this.symbol.latex?this.symbol.latex(t):Bt.latex(this.symbol,t)},valueOf:function(){return this.symbol.valueOf()},evaluate:function(){var t,n=arguments[0],r=1;"string"==typeof n?t="%"===n.charAt(0)?Lt.getExpression(n.substr(1)).text():n:n instanceof Lt||U(n)?t=n.text():(t=this.symbol.text(),r--);var i=arguments[r]||{};return new Lt(lt("PARSE2NUMBER",function(){return e.parse(t,i)},!0))},buildFunction:function(t){return Vt.build(this.symbol,t)},isNumber:function(){return Z(this.symbol)},isInfinity:function(){return Math.abs(this.symbol.multiplier)===1/0},variables:function(){return k(this.symbol)},toString:function(){try{return V(this.symbol)?"["+this.symbol.toString()+"]":this.symbol.toString()}catch(t){return""}},toDecimal:function(t){a.precision=t;var e=Tt(this.symbol,"decimals");return a.precision=void 0,e},isFraction:function(){return _(this.symbol)},isPolynomial:function(){return this.symbol.isPoly()},sub:function(t,n){return new Lt(this.symbol.sub(e.parse(t),e.parse(n)))},operation:function(t,n){return D(n)?n=n.symbol:U(n)||(n=e.parse(n)),new Lt(e[t](this.symbol.clone(),n.clone()))},add:function(t){return this.operation("add",t)},subtract:function(t){return this.operation("subtract",t)},multiply:function(t){return this.operation("multiply",t)},divide:function(t){return this.operation("divide",t)},pow:function(t){return this.operation("pow",t)},expand:function(){return new Lt(e.expand(this.symbol))},each:function(t,e){if(this.symbol.each)this.symbol.each(t,e);else if(V(this.symbol))for(e=0;e4&&i++,e.coeff=n+i}return e},copy:function(){var t=new _t(0);return t.coeff=this.coeff,t.exponent=this.exponent,t.sign=this.sign,t},toString:function(t){var e,n=void 0===t?this.coeff:_t.round(this.coeff,t);return e=0===this.exponent&&a.SCIENTIFIC_IGNORE_INTS?this.coeff:n+"e"+this.exponent,(-1===this.sign?"-":"")+e}},_t.isScientific=function(t){return/\d+\.?\d*e[\+\-]*\d+/i.test(t)},_t.leadingZeroes=function(t){var e=t.match(/^(0*).*$/);return e?e[1]:""},_t.removeLeadingZeroes=function(t){var e=t.match(/^0*(.*)$/);return e?e[1]:""},_t.removeTrailingZeroes=function(t){var e=t.match(/0*$/);return e?t.substring(0,t.length-e[0].length):""},_t.round=function(t,e){var n=et(t,e),r=e-String(n).split(".").pop().length;return r>0&&(n+=new Array(r+1).join(0)),n},_t.prototype={fromScientific:function(t){var e=String(t).toLowerCase().split("e");return this.coeff=e[0],this.exponent=e[1],this},convert:function(t){var e=t.split("."),n=e[0]||"",r=e[1]||"";n=_t.removeLeadingZeroes(n),r=_t.removeTrailingZeroes(r);var i=n.length,s=n+r,o=_t.leadingZeroes(s).length;this.exponent=i-(o+1);var a=_t.removeLeadingZeroes(s);this.coeff=a.charAt(0)+"."+(a.substr(1,a.length)||"0");var u=this.coeff.split(".")[1]||"";return this.decp="0"===u?0:u.length,this.dec=r,this.wholes=n,this},round:function(t){var e=this.copy();if(0===(t=Number(t)))e.coeff=e.coeff.charAt(0);else{var n=this.coeff.substring(0,t+1),r=this.coeff.substring(t+1,t+3),i=r.charAt(0);r.charAt(1)>4&&i++,e.coeff=n+i}return e},copy:function(){var t=new _t(0);return t.coeff=this.coeff,t.exponent=this.exponent,t.sign=this.sign,t},toString:function(t){var e;if(a.SCIENTIFIC_IGNORE_ZERO_EXPONENTS&&0===this.exponent&&this.decp1)return!1;for(var s in this.symbols)if(!this.symbols[s].isPoly(t))return!1;return!0}return!1},stripVar:function(t,n){var r;return this.group!==h&&this.group!==c||this.value!==t?this.group===m&&this.isLinear()?(r=new Dt(1),this.each(function(n){n.contains(t,!0)||(r=e.multiply(r,n.clone()))}),r.multiplier=r.multiplier.multiply(this.multiplier)):this.group!==v||this.isLinear()?this.group===v&&this.isLinear()?(r=new Dt(0),this.each(function(n){if(!n.contains(t)){var i=n.clone();i.multiplier=i.multiplier.multiply(this.multiplier),r=e.add(r,i)}}),r.equals(0)&&(r=new Dt(this.multiplier))):r=this.group===f&&this.power.contains(t,!0)?new Dt(this.multiplier):this.group===p&&this.contains(t)?new Dt(this.multiplier):this.clone():r=new Dt(this.multiplier):r=new Dt(n?0:this.multiplier),r},toArray:function(t,n){n=n||{arr:[],add:function(t,n){var r=this.arr[n];this.arr[n]=r?e.add(r,t):t}};var r=this.group;if(r===c&&this.contains(t))n.add(new Dt(this.multiplier),this.power);else if(r===m){var i=this.stripVar(t),s=e.divide(this.clone(),i.clone()),o=s.isConstant()?0:s.power;n.add(i,o)}else if(r===h&&this.value===t)this.each(function(e,r){n.add(e.stripVar(t),r)});else if(r===v)this.each(function(e){e.toArray(t,n)});else{if(this.contains(t))throw new bt("Cannot convert to array! Exiting");n.add(this.clone(),0)}n=n.arr;for(var a=0;ap){var n=this.clone();this.symbols={},t===m?n.toUnitMultiplier():this.toUnitMultiplier(),this.group===p&&(n.args=this.args,delete this.args,delete this.fname),this.isImgSymbol&&delete this.isImgSymbol,this.toLinear(),this.symbols[n.keyForGroup(t)]=n,this.group=t,this.length=1}else if(t===f)this.group===u&&this.multiplier.equals(1)||(this.group!==f&&(this.previousGroup=this.group),this.group===u?(this.value=this.multiplier.num.toString(),this.toUnitMultiplier()):this.value=Tt(this,"hash"),this.group=f);else if(t===u){var r=this.multiplier.toDecimal();this.symbols&&(this.symbols=void 0),new Dt(this.group===l?r*Math.pow(this.value,this.power):r).clone(this)}else t===l&&this.group===u&&(this.value=e?this.multiplier.num.toString():Math.abs(this.multiplier.num.toString()),this.toUnitMultiplier(!e),this.group=l);return this},insert:function(t,n){if(U(t)||x("Object "+t+" is not of type Symbol!"),this.symbols){var r=this.group;if(r>p){var i=t.keyForGroup(r),s=i in this.symbols&&this.symbols[i];if("add"===n){var o=i;s?(this.symbols[o]=e.add(s,t),this.symbols[o].multiplier.equals(0)&&(delete this.symbols[o],this.length--,0===this.length&&(this.convert(u),this.multiplier=new Ut(0)))):(this.symbols[i]=t,this.length++)}else t.group===l&&X(t.power)&&t.convert(u),t.group!==f?(this.multiplier=this.multiplier.multiply(t.multiplier),t.toUnitMultiplier()):(t.parens=t.multiplier.lessThan(0),this.multiplier=this.multiplier.multiply(t.multiplier.clone().abs()),t.toUnitMultiplier(!0)),s&&((t=e.multiply(ut(this.symbols,i),t)).isConstant()&&(this.multiplier=this.multiplier.multiply(t.multiplier),t=new Dt(1)),this.length--),t.isOne(!0)?t.multiplier.lessThan(0)&&this.negate():(this.symbols[i]=t,this.length++);0===this.length&&this.convert(u),this.group!==v&&this.group!==m||this.updateHash()}}return this},attach:function(t){if(V(t)){for(var e=0;e0||n.group===f&&n.power.multiplier>0)&&(t=e.multiply(t,n.clone()))})):t=e.parse(n.multiplier.num),t},toString:function(){return this.text()}};var Ft={convert:function(t,e){var n;if(0===t)n=[0,1];else if(t<1e-6||t>1e20){var r=this.quickConversion(Number(t));if(r[1]<=1e20){var i=Math.abs(t),s=t/i;(n=this.fullConversion(i.toFixed((r[1]+"").length-1)))[0]=n[0]*s}else n=r}else n=this.fullConversion(t);return n},quickConversion:function(t){var e=(t.toExponential()+"").split("e"),n=e[0].split(".")[1],r=(n?n.length:0)-parseInt(e[1]);return[Math.round(Math.pow(10,r)*e[0]),Math.pow(10,Math.abs(e[1])+r)]},fullConversion:function(t){for(var e=!1,n=0,r=1,i=1,s=0,o=0,a=t;!e;){++o>1e4&&(e=!0);var u=Math.floor(a),l=n+u*i,c=r+u*s,f=a-u;f<1e-16&&(e=!0),a=1/f,n=i,r=s,i=l,s=c,(Math.abs(l/c-t)<1e-16||o>30)&&(e=!0)}return[l,c]}},Bt={parser:function(){var t=["classes","setOperator","getOperators","getBrackets","tokenize","toRPN","tree","units"],e=new kt;for(var n in e)-1===t.indexOf(n)&&delete e[n];return e.setOperator({precedence:8,operator:"\\",action:"slash",prefix:!0,postfix:!1,leftAssoc:!0,operation:function(t){return t}}),e.setOperator({precedence:8,operator:"\\,",action:"slash_comma",prefix:!0,postfix:!1,leftAssoc:!0,operation:function(t){return t}}),e.getBrackets()["{"].maps_to=void 0,e}(),space:"~",dot:" \\cdot ",latex:function(t,n){if(t.clone&&(t=t.clone()),t instanceof e.classes.Collection&&(t=t.elements),V(t)){for(var r=[],i=0;i1)o[h]="\\mathrm"+this.braces(a.LOG)+"_"+this.braces(N[1])+this.brackets(N[0]);else if(S===a.LOG10)o[h]="\\mathrm"+this.braces(a.LOG)+"_"+this.braces(10)+this.brackets(N[0]);else if("sum"===S){var R=N[0],q=N[1],C=N[2],I=N[3];o[h]="\\sum\\limits_{"+this.braces(q)+"="+this.braces(C)+"}^"+this.braces(I)+" "+this.braces(R)}else if("product"===S){R=N[0],q=N[1],C=N[2],I=N[3];o[h]="\\prod\\limits_{"+this.braces(q)+"="+this.braces(C)+"}^"+this.braces(I)+" "+this.braces(R)}else if("nthroot"===S)o[h]="\\sqrt["+N[1]+"]"+this.braces(N[0]);else if("mod"===S)o[h]=N[0]+" \\bmod "+N[1];else if("realpart"===S)o[h]="\\operatorname{Re}"+this.brackets(N[0]);else if("imagpart"===S)o[h]="\\operatorname{Im}"+this.brackets(N[0]);else{var P=""!==S?"\\mathrm"+this.braces(S.replace(/_/g,"\\_")):"";t.isConversion?o[h]=P+this.brackets(N.join(""),"parens"):o[h]=P+this.brackets(N.join(","),"parens")}}else if(t.isComposite()){var T=t.collectSymbols().sort(i===v||s===v?function(t,e){return e.group-t.group}:function(t,e){var n=U(t.power)?-1:t.power;return(U(e.power)?-1:e.power)-n}),L=[],_=T.length;for(A=0;A<_;A++)L.push(Bt.latex(T[A],n));var D=L.join("+");o[h]=t.isLinear()&&t.multiplier.equals(1)&&!r?D:this.brackets(D,"parens")}else if(i===m||s===f||s===m){i===m&&t.distributeExponent();var k=[],F=[],B=[],G=[],j=0,Z=0,V=function(t,e,n){if(n>1&&e.length>0)for(var r=e.length,i=0;ithis.elements.length?null:this.elements[t-1]},set:function(t,e){U(e)||(e=new Dt(e)),this.elements[t]=e},dimensions:function(){return this.elements.length},modulus:function(){return lt("SAFE",function(){return e.pow(this.dot(this.clone()),new Dt(.5))},void 0,this)},eql:function(t){var n=this.elements.length,r=t.elements||t;if(n!==r.length)return!1;do{if(Math.abs(e.subtract(this.elements[n-1],r[n-1]).valueOf())>PRECISION)return!1}while(--n);return!0},clone:function(){for(var t=new Gt,e=this.elements.length,n=0;n1&&(a=1),new Dt(Math.acos(a))},void 0,this)},isParallelTo:function(t){var e=this.angleFrom(t).valueOf();return null===e?null:e<=PRECISION},isAntiparallelTo:function(t){var e=this.angleFrom(t).valueOf();return null===e?null:Math.abs(e-Math.PI)<=PRECISION},isPerpendicularTo:function(t){var e=this.dot(t);return null===e?null:Math.abs(e)<=PRECISION},add:function(t){return lt("SAFE",function(){var n=t.elements||t;return this.elements.length!==n.length?null:this.map(function(t,r){return e.add(t,n[r-1])})},void 0,this)},subtract:function(t){return lt("SAFE",function(){var n=t.elements||t;return this.elements.length!==n.length?null:this.map(function(t,r){return e.subtract(t,n[r-1])})},void 0,this)},multiply:function(t){return this.map(function(e){return e.clone()*t.clone()})},x:function(t){return this.multiply(t)},dot:function(t){return lt("SAFE",function(){var n=t.elements||t,r=new Dt(0),i=this.elements.length;if(i!==n.length)return null;do{r=e.add(r,e.multiply(this.elements[i-1],n[i-1]))}while(--i);return r},void 0,this)},cross:function(t){var n=t.elements||t;if(3!==this.elements.length||3!==n.length)return null;var r=this.elements;return lt("SAFE",function(){return new Gt([e.subtract(e.multiply(r[1],n[2]),e.multiply(r[2],n[1])),e.subtract(e.multiply(r[2],n[0]),e.multiply(r[0],n[2])),e.subtract(e.multiply(r[0],n[1]),e.multiply(r[1],n[0]))])},void 0,this)},max:function(){var t,e=0,n=this.elements.length,r=n;do{t=r-n,Math.abs(this.elements[t].valueOf())>Math.abs(e.valueOf())&&(e=this.elements[t])}while(--n);return e},magnitude:function(){var t=new Dt(0);return this.each(function(n){t=e.add(t,e.pow(n,new Dt(2)))}),e.sqrt(t)},indexOf:function(t){var e,n=null,r=this.elements.length,i=r;do{e=i-r,null===n&&this.elements[e].valueOf()===t.valueOf()&&(n=e+1)}while(--r);return n},text:function(t){return Tt(this)},toString:function(){return this.text()},latex:function(t){for(var e=[],n=0;nthis.cols()?[]:this.elements[t-1]},col:function(t){var e=this.rows(),n=[];if(t>this.cols()||!t)return n;for(var r=0;r=l&&h[t].push(a)}while(--r);for(f.elements[t]=s,n=0;n0},is_subset:function(t){for(var e=t.elements,n=0,r=e.length;n1?o[1]:o[0])+"="+n[s]+";",i[s]=o.pop()}return[i,r]},getArgsDeps:function(t,e){for(var n=t.args,r=0;r\n
    \n
  • \n'+this.tree(t).toHTML(3,e)+"\n
  • \n
\n

"},Ht.addPeeker=function(t,n){e.peekers[t]&&e.peekers[t].push(n)},Ht.removePeeker=function(t,n){ut(e.peekers[t],n)},Ht.parse=function(t){return String(t).split(";").map(function(t){return e.parse(t)})},Ht.api(),Ht}({bigInt:function(){var t=function(e){"use strict";var n=1e7,r=7,i=9007199254740992,s=f(i),o=Math.log(i);function a(t,e){return void 0===t?a[0]:void 0!==e?10==+e?$(t):j(t,e):$(t)}function u(t,e){this.value=t,this.sign=e,this.isSmall=!1}function l(t){this.value=t,this.sign=t<0,this.isSmall=!0}function c(t){return-i

0?Math.floor(t):Math.ceil(t)}function g(t,e){var r,i,s=t.length,o=e.length,a=new Array(s),u=0,l=n;for(i=0;i=l?1:0,a[i]=r-u*l;for(;i0&&a.push(u),a}function d(t,e){return t.length>=e.length?g(t,e):g(e,t)}function w(t,e){var r,i,s=t.length,o=new Array(s),a=n;for(i=0;i0;)o[i++]=e%a,e=Math.floor(e/a);return o}function y(t,e){var r,i,s=t.length,o=e.length,a=new Array(s),u=0,l=n;for(r=0;r0;)o[i++]=u%a,u=Math.floor(u/a);return o}function N(t,e){for(var n=[];e-- >0;)n.push(0);return n.concat(t)}function S(t,e,r){return new u(t=0;--r)s=(o=s*l+t[r])-(i=v(o/e))*e,u[r]=0|i;return[u,0|s]}function O(t,e){var r,i,s=$(e),o=t.value,c=s.value;if(0===c)throw new Error("Cannot divide by zero");if(t.isSmall)return s.isSmall?[new l(v(o/c)),new l(o%c)]:[a[0],t];if(s.isSmall){if(1===c)return[t,a[0]];if(-1==c)return[t.negate(),a[0]];var g=Math.abs(c);if(g=0;i--){for(r=h-1,w[i+f]!==g&&(r=Math.floor((w[i+f]*h+w[i+f-1])/g)),s=0,o=0,u=y.length,a=0;al&&(s=(s+1)*m),r=Math.ceil(s/o);do{if(R(a=E(e,r),f)<=0)break;r--}while(r);c.push(r),f=y(f,a)}return c.reverse(),[p(c),p(f)]}(o,c))[0];var b=t.sign!==s.sign,M=r[1],N=t.sign;return"number"==typeof i?(b&&(i=-i),i=new l(i)):i=new u(i,b),"number"==typeof M?(N&&(M=-M),M=new l(M)):M=new u(M,N),[i,M]}function R(t,e){if(t.length!==e.length)return t.length>e.length?1:-1;for(var n=t.length-1;n>=0;n--)if(t[n]!==e[n])return t[n]>e[n]?1:-1;return 0}function q(t){var e=t.abs();return!e.isUnit()&&(!!(e.equals(2)||e.equals(3)||e.equals(5))||!(e.isEven()||e.isDivisibleBy(3)||e.isDivisibleBy(5))&&(!!e.lesser(49)||void 0))}function C(e,n){for(var r,i,s,o=e.prev(),u=o,l=0;u.isEven();)u=u.divide(2),l++;t:for(i=0;i=0?r=y(t,e):(r=y(e,t),n=!n),"number"==typeof(r=p(r))?(n&&(r=-r),new l(r)):new u(r,n)}(n,r,this.sign)},u.prototype.minus=u.prototype.subtract,l.prototype.subtract=function(t){var e=$(t),n=this.value;if(n<0!==e.sign)return this.add(e.negate());var r=e.value;return e.isSmall?new l(n-r):b(r,Math.abs(n),n>=0)},l.prototype.minus=l.prototype.subtract,u.prototype.negate=function(){return new u(this.value,!this.sign)},l.prototype.negate=function(){var t=this.sign,e=new l(-this.value);return e.sign=!t,e},u.prototype.abs=function(){return new u(this.value,!1)},l.prototype.abs=function(){return new l(Math.abs(this.value))},u.prototype.multiply=function(t){var e,r,i,s=$(t),o=this.value,l=s.value,c=this.sign!==s.sign;if(s.isSmall){if(0===l)return a[0];if(1===l)return this;if(-1===l)return this.negate();if((e=Math.abs(l))0?function t(e,n){var r=Math.max(e.length,n.length);if(r<=30)return M(e,n);r=Math.ceil(r/2);var i=e.slice(r),s=e.slice(0,r),o=n.slice(r),a=n.slice(0,r),u=t(s,a),l=t(i,o),c=d(d(u,N(y(y(t(d(s,i),d(a,o)),u),l),r)),N(l,2*r));return h(c),c}(o,l):M(o,l),c)},u.prototype.times=u.prototype.multiply,l.prototype._multiplyBySmall=function(t){return c(t.value*this.value)?new l(t.value*this.value):S(Math.abs(t.value),f(Math.abs(this.value)),this.sign!==t.sign)},u.prototype._multiplyBySmall=function(t){return 0===t.value?a[0]:1===t.value?this:-1===t.value?this.negate():S(Math.abs(t.value),this.value,this.sign!==t.sign)},l.prototype.multiply=function(t){return $(t)._multiplyBySmall(this)},l.prototype.times=l.prototype.multiply,u.prototype.square=function(){return new u(A(this.value),!1)},l.prototype.square=function(){var t=this.value*this.value;return c(t)?new l(t):new u(A(f(Math.abs(this.value))),!1)},u.prototype.divmod=function(t){var e=O(this,t);return{quotient:e[0],remainder:e[1]}},l.prototype.divmod=u.prototype.divmod,u.prototype.divide=function(t){return O(this,t)[0]},l.prototype.over=l.prototype.divide=u.prototype.over=u.prototype.divide,u.prototype.mod=function(t){return O(this,t)[1]},l.prototype.remainder=l.prototype.mod=u.prototype.remainder=u.prototype.mod,u.prototype.pow=function(t){var e,n,r,i=$(t),s=this.value,o=i.value;if(0===o)return a[1];if(0===s)return a[0];if(1===s)return a[1];if(-1===s)return i.isEven()?a[1]:a[-1];if(i.sign)return a[0];if(!i.isSmall)throw new Error("The exponent "+i.toString()+" is too large.");if(this.isSmall&&c(e=Math.pow(s,o)))return new l(v(e));for(n=this,r=a[1];!0&o&&(r=r.times(n),--o),0!==o;)o/=2,n=n.square();return r},l.prototype.pow=u.prototype.pow,u.prototype.modPow=function(t,e){if(t=$(t),(e=$(e)).isZero())throw new Error("Cannot take modPow with modulus 0");for(var n=a[1],r=this.mod(e);t.isPositive();){if(r.isZero())return a[0];t.isOdd()&&(n=n.multiply(r).mod(e)),t=t.divide(2),r=r.square().mod(e)}return n},l.prototype.modPow=u.prototype.modPow,u.prototype.compareAbs=function(t){var e=$(t),n=this.value,r=e.value;return e.isSmall?1:R(n,r)},l.prototype.compareAbs=function(t){var e=$(t),n=Math.abs(this.value),r=e.value;return e.isSmall?n===(r=Math.abs(r))?0:n>r?1:-1:-1},u.prototype.compare=function(t){if(t===1/0)return-1;if(t===-1/0)return 1;var e=$(t),n=this.value,r=e.value;return this.sign!==e.sign?e.sign?1:-1:e.isSmall?this.sign?-1:1:R(n,r)*(this.sign?-1:1)},u.prototype.compareTo=u.prototype.compare,l.prototype.compare=function(t){if(t===1/0)return-1;if(t===-1/0)return 1;var e=$(t),n=this.value,r=e.value;return e.isSmall?n==r?0:n>r?1:-1:n<0!==e.sign?n<0?-1:1:n<0?1:-1},l.prototype.compareTo=l.prototype.compare,u.prototype.equals=function(t){return 0===this.compare(t)},l.prototype.eq=l.prototype.equals=u.prototype.eq=u.prototype.equals,u.prototype.notEquals=function(t){return 0!==this.compare(t)},l.prototype.neq=l.prototype.notEquals=u.prototype.neq=u.prototype.notEquals,u.prototype.greater=function(t){return this.compare(t)>0},l.prototype.gt=l.prototype.greater=u.prototype.gt=u.prototype.greater,u.prototype.lesser=function(t){return this.compare(t)<0},l.prototype.lt=l.prototype.lesser=u.prototype.lt=u.prototype.lesser,u.prototype.greaterOrEquals=function(t){return this.compare(t)>=0},l.prototype.geq=l.prototype.greaterOrEquals=u.prototype.geq=u.prototype.greaterOrEquals,u.prototype.lesserOrEquals=function(t){return this.compare(t)<=0},l.prototype.leq=l.prototype.lesserOrEquals=u.prototype.leq=u.prototype.lesserOrEquals,u.prototype.isEven=function(){return 0==(1&this.value[0])},l.prototype.isEven=function(){return 0==(1&this.value)},u.prototype.isOdd=function(){return 1==(1&this.value[0])},l.prototype.isOdd=function(){return 1==(1&this.value)},u.prototype.isPositive=function(){return!this.sign},l.prototype.isPositive=function(){return this.value>0},u.prototype.isNegative=function(){return this.sign},l.prototype.isNegative=function(){return this.value<0},u.prototype.isUnit=function(){return!1},l.prototype.isUnit=function(){return 1===Math.abs(this.value)},u.prototype.isZero=function(){return!1},l.prototype.isZero=function(){return 0===this.value},u.prototype.isDivisibleBy=function(t){var e=$(t),n=e.value;return 0!==n&&(1===n||(2===n?this.isEven():this.mod(e).equals(a[0])))},l.prototype.isDivisibleBy=u.prototype.isDivisibleBy,u.prototype.isPrime=function(e){var n=q(this);if(void 0!==n)return n;var r=this.abs(),i=r.bitLength();if(i<=64)return C(r,[2,325,9375,28178,450775,9780504,1795265022]);for(var s=Math.log(2)*i,o=Math.ceil(!0===e?2*Math.pow(s,2):s),a=[],u=0;u-i?new l(t-1):new u(s,!0)};for(var I=[1];2*I[I.length-1]<=n;)I.push(2*I[I.length-1]);var P=I.length,T=I[P-1];function L(t){return("number"==typeof t||"string"==typeof t)&&+Math.abs(t)<=n||t instanceof u&&t.value.length<=1}function _(e,n,r){n=$(n);for(var i=e.isNegative(),s=n.isNegative(),o=i?e.not():e,a=s?n.not():n,u=0,l=0,c=null,f=null,p=[];!o.isZero()||!a.isZero();)u=(c=O(o,T))[1].toJSNumber(),i&&(u=T-1-u),l=(f=O(a,T))[1].toJSNumber(),s&&(l=T-1-l),o=c[0],a=f[0],p.push(r(u,l));for(var h=0!==r(i?1:0,s?1:0)?t(-1):t(0),m=p.length-1;m>=0;m-=1)h=h.multiply(T).add(t(p[m]));return h}u.prototype.shiftLeft=function(t){if(!L(t))throw new Error(String(t)+" is too large for shifting.");if((t=+t)<0)return this.shiftRight(-t);var e=this;if(e.isZero())return e;for(;t>=P;)e=e.multiply(T),t-=P-1;return e.multiply(I[t])},l.prototype.shiftLeft=u.prototype.shiftLeft,u.prototype.shiftRight=function(t){var e;if(!L(t))throw new Error(String(t)+" is too large for shifting.");if((t=+t)<0)return this.shiftLeft(-t);for(var n=this;t>=P;){if(n.isZero()||n.isNegative()&&n.isUnit())return n;n=(e=O(n,T))[1].isNegative()?e[0].prev():e[0],t-=P-1}return(e=O(n,I[t]))[1].isNegative()?e[0].prev():e[0]},l.prototype.shiftRight=u.prototype.shiftRight,u.prototype.not=function(){return this.negate().prev()},l.prototype.not=u.prototype.not,u.prototype.and=function(t){return _(this,t,function(t,e){return t&e})},l.prototype.and=u.prototype.and,u.prototype.or=function(t){return _(this,t,function(t,e){return t|e})},l.prototype.or=u.prototype.or,u.prototype.xor=function(t){return _(this,t,function(t,e){return t^e})},l.prototype.xor=u.prototype.xor;var U=1<<30,D=(n&-n)*(n&-n)|U;function k(t){var e=t.value,r="number"==typeof e?e|U:e[0]+e[1]*n|D;return r&-r}function F(t,e){return t=$(t),e=$(e),t.greater(e)?t:e}function B(t,e){return t=$(t),e=$(e),t.lesser(e)?t:e}function G(t,e){if(t=$(t).abs(),e=$(e).abs(),t.equals(e))return t;if(t.isZero())return e;if(e.isZero())return t;for(var n,r,i=a[1];t.isEven()&&e.isEven();)n=Math.min(k(t),k(e)),t=t.divide(n),e=e.divide(n),i=i.multiply(n);for(;t.isEven();)t=t.divide(k(t));do{for(;e.isEven();)e=e.divide(k(e));t.greater(e)&&(r=e,e=t,t=r),e=e.subtract(t)}while(!e.isZero());return i.isUnit()?t:t.multiply(i)}u.prototype.bitLength=function(){var e=this;return e.compareTo(t(0))<0&&(e=e.negate().subtract(t(1))),0===e.compareTo(t(0))?t(0):t(function e(n,r){if(r.compareTo(n)<=0){var i=e(n,r.square(r)),s=i.p,o=i.e,a=s.multiply(r);return a.compareTo(n)<=0?{p:a,e:2*o+1}:{p:s,e:2*o}}return{p:t(1),e:0}}(e,t(2)).e).add(t(1))},l.prototype.bitLength=u.prototype.bitLength;var j=function(t,e){for(var n=t.length,r=Math.abs(e),i=0;i=r){if("1"===c&&1===r)continue;throw new Error(c+" is not a valid digit in base "+e+".")}if(c.charCodeAt(0)-87>=r)throw new Error(c+" is not a valid digit in base "+e+".")}}if(2<=e&&e<=36&&n<=o/Math.log(e)){var s=parseInt(t,e);if(isNaN(s))throw new Error(c+" is not a valid digit in base "+e+".");return new l(parseInt(t,e))}e=$(e);var a=[],u="-"===t[0];for(i=u?1:0;i"!==t[i]);a.push($(t.slice(p+1,i)))}}return Z(a,e,u)};function Z(t,e,n){var r,i=a[0],s=a[1];for(r=t.length-1;r>=0;r--)i=i.add(t[r].times(s)),s=s.times(e);return n?i.negate():i}function V(t){return t<=35?"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t):"<"+t+">"}function X(e,n){if((n=t(n)).isZero()){if(e.isZero())return{value:[0],isNegative:!1};throw new Error("Cannot convert nonzero numbers to base 0.")}if(n.equals(-1)){if(e.isZero())return{value:[0],isNegative:!1};if(e.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-e)).map(Array.prototype.valueOf,[1,0])),isNegative:!1};var r=Array.apply(null,Array(+e-1)).map(Array.prototype.valueOf,[0,1]);return r.unshift([1]),{value:[].concat.apply([],r),isNegative:!1}}var i=!1;if(e.isNegative()&&n.isPositive()&&(i=!0,e=e.abs()),n.equals(1))return e.isZero()?{value:[0],isNegative:!1}:{value:Array.apply(null,Array(+e)).map(Number.prototype.valueOf,1),isNegative:i};for(var s,o=[],a=e;a.isNegative()||a.compareAbs(n)>=0;){a=(s=a.divmod(n)).quotient;var u=s.remainder;u.isNegative()&&(u=n.minus(u).abs(),a=a.next()),o.push(u.toJSNumber())}return o.push(a.toJSNumber()),{value:o.reverse(),isNegative:i}}function z(t,e){var n=X(t,e);return(n.isNegative?"-":"")+n.value.map(V).join("")}function H(t){if(c(+t)){var e=+t;if(e===v(e))return new l(e);throw new Error("Invalid integer: "+t)}var n="-"===t[0];n&&(t=t.slice(1));var i=t.split(/e/i);if(i.length>2)throw new Error("Invalid integer: "+i.join("e"));if(2===i.length){var s=i[1];if("+"===s[0]&&(s=s.slice(1)),(s=+s)!==v(s)||!c(s))throw new Error("Invalid integer: "+s+" is not a valid exponent.");var o=i[0],a=o.indexOf(".");if(a>=0&&(s-=o.length-a-1,o=o.slice(0,a)+o.slice(a+1)),s<0)throw new Error("Cannot include negative exponent part for integers");t=o+=new Array(s+1).join("0")}if(!/^([0-9][0-9]*)$/.test(t))throw new Error("Invalid integer: "+t);for(var f=[],p=t.length,m=r,g=p-m;p>0;)f.push(+t.slice(g,p)),(g-=m)<0&&(g=0),p-=m;return h(f),new u(f,n)}function $(t){return"number"==typeof t?function(t){if(c(t)){if(t!==v(t))throw new Error(t+" is not an integer.");return new l(t)}return H(t.toString())}(t):"string"==typeof t?H(t):t}u.prototype.toArray=function(t){return X(this,t)},l.prototype.toArray=function(t){return X(this,t)},u.prototype.toString=function(t){if(void 0===t&&(t=10),10!==t)return z(this,t);for(var e,n=this.value,r=n.length,i=String(n[--r]);--r>=0;)e=String(n[r]),i+="0000000".slice(e.length)+e;return(this.sign?"-":"")+i},l.prototype.toString=function(t){return void 0===t&&(t=10),10!=t?z(this,t):String(this.value)},u.prototype.toJSON=l.prototype.toJSON=function(){return this.toString()},u.prototype.valueOf=function(){return parseInt(this.toString(),10)},u.prototype.toJSNumber=u.prototype.valueOf,l.prototype.valueOf=function(){return this.value},l.prototype.toJSNumber=l.prototype.valueOf;for(var W=0;W<1e3;W++)a[W]=new l(W),W>0&&(a[-W]=new l(-W));return a.one=a[1],a.zero=a[0],a.minusOne=a[-1],a.max=F,a.min=B,a.gcd=G,a.lcm=function(t,e){return t=$(t).abs(),e=$(e).abs(),t.divide(G(t,e)).multiply(e)},a.isInstance=function(t){return t instanceof u||t instanceof l},a.randBetween=function(t,e){var r=B(t=$(t),e=$(e)),i=F(t,e).subtract(r).add(1);if(i.isSmall)return r.add(Math.floor(Math.random()*i));for(var s=[],o=!0,a=i.value.length-1;a>=0;a--){var c=o?i.value[a]:n,f=v(Math.random()*c);s.unshift(f),f0){for(s+=o,e=1;en)throw Error(p+t)}function R(t,e,n,r){var i,s,o,a;for(s=t[0];s>=10;s/=10)--e;return--e<0?(e+=E,i=0):(i=Math.ceil((e+1)/E),e%=E),s=g(10,E-e),a=t[i]%s|0,null==r?e<3?(0==e?a=a/100|0:1==e&&(a=a/10|0),o=n<4&&99999==a||n>3&&49999==a||5e4==a||0==a):o=(n<4&&a+1==s||n>3&&a+1==s/2)&&(t[i+1]/s/100|0)==g(10,e-2)-1||(a==s/2||0==a)&&0==(t[i+1]/s/100|0):e<4?(0==e?a=a/1e3|0:1==e?a=a/100|0:2==e&&(a=a/10|0),o=(r||n<4)&&9999==a||!r&&n>3&&4999==a):o=((r||n<4)&&a+1==s||!r&&n>3&&a+1==s/2)&&(t[i+1]/s/1e3|0)==g(10,e-3)-1,o}function q(t,e,n){for(var r,i,s=[0],a=0,u=t.length;an-1&&(void 0===s[r+1]&&(s[r+1]=0),s[r+1]+=s[r]/n|0,s[r]%=n)}return s.reverse()}A.absoluteValue=A.abs=function(){var t=new this.constructor(this);return t.s<0&&(t.s=1),I(t)},A.ceil=function(){return I(new this.constructor(this),this.e+1,2)},A.comparedTo=A.cmp=function(t){var e,n,r,i,s=this,o=s.d,a=(t=new s.constructor(t)).d,u=s.s,l=t.s;if(!o||!a)return u&&l?u!==l?u:o===a?0:!o^u<0?1:-1:NaN;if(!o[0]||!a[0])return o[0]?u:a[0]?-l:0;if(u!==l)return u;if(s.e!==t.e)return s.e>t.e^u<0?1:-1;for(e=0,n=(r=o.length)<(i=a.length)?r:i;ea[e]^u<0?1:-1;return r===i?0:r>i^u<0?1:-1},A.cosine=A.cos=function(){var t,e,n=this,i=n.constructor;return n.d?n.d[0]?(t=i.precision,e=i.rounding,i.precision=t+Math.max(n.e,n.sd())+E,i.rounding=1,n=function(t,e){var n,r,i=e.d.length;i<32?(n=Math.ceil(i/3),r=Math.pow(4,-n).toString()):(n=16,r="2.3283064365386962890625e-10"),t.precision+=n,e=z(t,1,e.times(r),new t(1));for(var s=n;s--;){var o=e.times(e);e=o.times(o).minus(o).times(8).plus(1)}return t.precision-=n,e}(i,H(i,n)),i.precision=t,i.rounding=e,I(2==r||3==r?n.neg():n,t,e,!0)):new i(1):new i(NaN)},A.cubeRoot=A.cbrt=function(){var t,e,n,r,i,s,o,a,u,l,f=this,p=f.constructor;if(!f.isFinite()||f.isZero())return new p(f);for(c=!1,(s=f.s*Math.pow(f.s*f,1/3))&&Math.abs(s)!=1/0?r=new p(s.toString()):(n=x(f.d),(s=((t=f.e)-n.length+1)%3)&&(n+=1==s||-2==s?"0":"00"),s=Math.pow(n,1/3),t=v((t+1)/3)-(t%3==(t<0?-1:2)),(r=new p(n=s==1/0?"5e"+t:(n=s.toExponential()).slice(0,n.indexOf("e")+1)+t)).s=f.s),o=(t=p.precision)+3;;)if(l=(u=(a=r).times(a).times(a)).plus(f),r=C(l.plus(f).times(a),l.plus(u),o+2,1),x(a.d).slice(0,o)===(n=x(r.d)).slice(0,o)){if("9999"!=(n=n.slice(o-3,o+1))&&(i||"4999"!=n)){+n&&(+n.slice(1)||"5"!=n.charAt(0))||(I(r,t+1,1),e=!r.times(r).times(r).eq(f));break}if(!i&&(I(a,t+1,0),a.times(a).times(a).eq(f))){r=a;break}o+=4,i=1}return c=!0,I(r,t,p.rounding,e)},A.decimalPlaces=A.dp=function(){var t,e=this.d,n=NaN;if(e){if(n=((t=e.length-1)-v(this.e/E))*E,t=e[t])for(;t%10==0;t/=10)n--;n<0&&(n=0)}return n},A.dividedBy=A.div=function(t){return C(this,new this.constructor(t))},A.dividedToIntegerBy=A.divToInt=function(t){var e=this.constructor;return I(C(this,new e(t),0,1,1),e.precision,e.rounding)},A.equals=A.eq=function(t){return 0===this.cmp(t)},A.floor=function(){return I(new this.constructor(this),this.e+1,3)},A.greaterThan=A.gt=function(t){return this.cmp(t)>0},A.greaterThanOrEqualTo=A.gte=function(t){var e=this.cmp(t);return 1==e||0===e},A.hyperbolicCosine=A.cosh=function(){var t,e,n,r,i,s=this,o=s.constructor,a=new o(1);if(!s.isFinite())return new o(s.s?1/0:NaN);if(s.isZero())return a;n=o.precision,r=o.rounding,o.precision=n+Math.max(s.e,s.sd())+4,o.rounding=1,(i=s.d.length)<32?(t=Math.ceil(i/3),e=Math.pow(4,-t).toString()):(t=16,e="2.3283064365386962890625e-10"),s=z(o,1,s.times(e),new o(1),!0);for(var u,l=t,c=new o(8);l--;)u=s.times(s),s=a.minus(u.times(c.minus(u.times(c))));return I(s,o.precision=n,o.rounding=r,!0)},A.hyperbolicSine=A.sinh=function(){var t,e,n,r,i=this,s=i.constructor;if(!i.isFinite()||i.isZero())return new s(i);if(e=s.precision,n=s.rounding,s.precision=e+Math.max(i.e,i.sd())+4,s.rounding=1,(r=i.d.length)<3)i=z(s,2,i,i,!0);else{t=(t=1.4*Math.sqrt(r))>16?16:0|t,i=z(s,2,i=i.times(Math.pow(5,-t)),i,!0);for(var o,a=new s(5),u=new s(16),l=new s(20);t--;)o=i.times(i),i=i.times(a.plus(o.times(u.times(o).plus(l))))}return s.precision=e,s.rounding=n,I(i,e,n,!0)},A.hyperbolicTangent=A.tanh=function(){var t,e,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(t=r.precision,e=r.rounding,r.precision=t+7,r.rounding=1,C(n.sinh(),n.cosh(),r.precision=t,r.rounding=e)):new r(n.s)},A.inverseCosine=A.acos=function(){var t,e=this,n=e.constructor,r=e.abs().cmp(1),i=n.precision,s=n.rounding;return-1!==r?0===r?e.isNeg()?_(n,i,s):new n(0):new n(NaN):e.isZero()?_(n,i+4,s).times(.5):(n.precision=i+6,n.rounding=1,e=e.asin(),t=_(n,i+4,s).times(.5),n.precision=i,n.rounding=s,t.minus(e))},A.inverseHyperbolicCosine=A.acosh=function(){var t,e,n=this,r=n.constructor;return n.lte(1)?new r(n.eq(1)?0:NaN):n.isFinite()?(t=r.precision,e=r.rounding,r.precision=t+Math.max(Math.abs(n.e),n.sd())+4,r.rounding=1,c=!1,n=n.times(n).minus(1).sqrt().plus(n),c=!0,r.precision=t,r.rounding=e,n.ln()):new r(n)},A.inverseHyperbolicSine=A.asinh=function(){var t,e,n=this,r=n.constructor;return!n.isFinite()||n.isZero()?new r(n):(t=r.precision,e=r.rounding,r.precision=t+2*Math.max(Math.abs(n.e),n.sd())+6,r.rounding=1,c=!1,n=n.times(n).plus(1).sqrt().plus(n),c=!0,r.precision=t,r.rounding=e,n.ln())},A.inverseHyperbolicTangent=A.atanh=function(){var t,e,n,r,i=this,s=i.constructor;return i.isFinite()?i.e>=0?new s(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(t=s.precision,e=s.rounding,r=i.sd(),Math.max(r,t)<2*-i.e-1?I(new s(i),t,e,!0):(s.precision=n=r-i.e,i=C(i.plus(1),new s(1).minus(i),n+t,1),s.precision=t+4,s.rounding=1,i=i.ln(),s.precision=t,s.rounding=e,i.times(.5))):new s(NaN)},A.inverseSine=A.asin=function(){var t,e,n,r,i=this,s=i.constructor;return i.isZero()?new s(i):(e=i.abs().cmp(1),n=s.precision,r=s.rounding,-1!==e?0===e?((t=_(s,n+4,r).times(.5)).s=i.s,t):new s(NaN):(s.precision=n+6,s.rounding=1,i=i.div(new s(1).minus(i.times(i)).sqrt().plus(1)).atan(),s.precision=n,s.rounding=r,i.times(2)))},A.inverseTangent=A.atan=function(){var t,e,n,r,i,s,o,a,u,l=this,f=l.constructor,p=f.precision,h=f.rounding;if(l.isFinite()){if(l.isZero())return new f(l);if(l.abs().eq(1)&&p+4<=S)return(o=_(f,p+4,h).times(.25)).s=l.s,o}else{if(!l.s)return new f(NaN);if(p+4<=S)return(o=_(f,p+4,h).times(.5)).s=l.s,o}for(f.precision=a=p+10,f.rounding=1,t=n=Math.min(28,a/E+2|0);t;--t)l=l.div(l.times(l).plus(1).sqrt().plus(1));for(c=!1,e=Math.ceil(a/E),r=1,u=l.times(l),o=new f(l),i=l;-1!==t;)if(i=i.times(u),s=o.minus(i.div(r+=2)),i=i.times(u),void 0!==(o=s.plus(i.div(r+=2))).d[e])for(t=e;o.d[t]===s.d[t]&&t--;);return n&&(o=o.times(2<this.d.length-2},A.isNaN=function(){return!this.s},A.isNegative=A.isNeg=function(){return this.s<0},A.isPositive=A.isPos=function(){return this.s>0},A.isZero=function(){return!!this.d&&0===this.d[0]},A.lessThan=A.lt=function(t){return this.cmp(t)<0},A.lessThanOrEqualTo=A.lte=function(t){return this.cmp(t)<1},A.logarithm=A.log=function(t){var e,n,r,i,s,o,a,u,l=this.constructor,f=l.precision,p=l.rounding;if(null==t)t=new l(10),e=!0;else{if(n=(t=new l(t)).d,t.s<0||!n||!n[0]||t.eq(1))return new l(NaN);e=t.eq(10)}if(n=this.d,this.s<0||!n||!n[0]||this.eq(1))return new l(n&&!n[0]?-1/0:1!=this.s?NaN:n?0:1/0);if(e)if(n.length>1)s=!0;else{for(i=n[0];i%10==0;)i/=10;s=1!==i}if(c=!1,o=j(this,a=f+5),r=e?L(l,a+10):j(t,a),R((u=C(o,r,a,1)).d,i=f,p))do{if(o=j(this,a+=10),r=e?L(l,a+10):j(t,a),u=C(o,r,a,1),!s){+x(u.d).slice(i+1,i+15)+1==1e14&&(u=I(u,f+1,0));break}}while(R(u.d,i+=10,p));return c=!0,I(u,f,p)},A.minus=A.sub=function(t){var e,n,r,i,s,o,a,u,l,f,p,h,m=this,g=m.constructor;if(t=new g(t),!m.d||!t.d)return m.s&&t.s?m.d?t.s=-t.s:t=new g(t.d||m.s!==t.s?m:NaN):t=new g(NaN),t;if(m.s!=t.s)return t.s=-t.s,m.plus(t);if(l=m.d,h=t.d,a=g.precision,u=g.rounding,!l[0]||!h[0]){if(h[0])t.s=-t.s;else{if(!l[0])return new g(3===u?-0:0);t=new g(m)}return c?I(t,a,u):t}if(n=v(t.e/E),f=v(m.e/E),l=l.slice(),s=f-n){for((p=s<0)?(e=l,s=-s,o=h.length):(e=h,n=f,o=l.length),s>(r=Math.max(Math.ceil(a/E),o)+2)&&(s=r,e.length=1),e.reverse(),r=s;r--;)e.push(0);e.reverse()}else{for((p=(r=l.length)<(o=h.length))&&(o=r),r=0;r0;--r)l[o++]=0;for(r=h.length;r>s;){if(l[--r](o=(s=Math.ceil(a/E))>o?s+1:o+1)&&(i=o,n.length=1),n.reverse();i--;)n.push(0);n.reverse()}for((o=l.length)-(i=f.length)<0&&(i=o,n=f,f=l,l=n),e=0;i;)e=(l[--i]=l[i]+f[i]+e)/M|0,l[i]%=M;for(e&&(l.unshift(e),++r),o=l.length;0==l[--o];)l.pop();return t.d=l,t.e=T(l,r),c?I(t,a,u):t},A.precision=A.sd=function(t){var e,n=this;if(void 0!==t&&t!==!!t&&1!==t&&0!==t)throw Error(p+t);return n.d?(e=U(n.d),t&&n.e+1>e&&(e=n.e+1)):e=NaN,e},A.round=function(){var t=this,e=t.constructor;return I(new e(t),t.e+1,e.rounding)},A.sine=A.sin=function(){var t,e,n=this,i=n.constructor;return n.isFinite()?n.isZero()?new i(n):(t=i.precision,e=i.rounding,i.precision=t+Math.max(n.e,n.sd())+E,i.rounding=1,n=function(t,e){var n,r=e.d.length;if(r<3)return z(t,2,e,e);n=(n=1.4*Math.sqrt(r))>16?16:0|n,e=z(t,2,e=e.times(Math.pow(5,-n)),e);for(var i,s=new t(5),o=new t(16),a=new t(20);n--;)i=e.times(e),e=e.times(s.plus(i.times(o.times(i).minus(a))));return e}(i,H(i,n)),i.precision=t,i.rounding=e,I(r>2?n.neg():n,t,e,!0)):new i(NaN)},A.squareRoot=A.sqrt=function(){var t,e,n,r,i,s,o=this,a=o.d,u=o.e,l=o.s,f=o.constructor;if(1!==l||!a||!a[0])return new f(!l||l<0&&(!a||a[0])?NaN:a?o:1/0);for(c=!1,0==(l=Math.sqrt(+o))||l==1/0?(((e=x(a)).length+u)%2==0&&(e+="0"),l=Math.sqrt(e),u=v((u+1)/2)-(u<0||u%2),r=new f(e=l==1/0?"1e"+u:(e=l.toExponential()).slice(0,e.indexOf("e")+1)+u)):r=new f(l.toString()),n=(u=f.precision)+3;;)if(r=(s=r).plus(C(o,s,n+2,1)).times(.5),x(s.d).slice(0,n)===(e=x(r.d)).slice(0,n)){if("9999"!=(e=e.slice(n-3,n+1))&&(i||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(I(r,u+1,1),t=!r.times(r).eq(o));break}if(!i&&(I(s,u+1,0),s.times(s).eq(o))){r=s;break}n+=4,i=1}return c=!0,I(r,u,f.rounding,t)},A.tangent=A.tan=function(){var t,e,n=this,i=n.constructor;return n.isFinite()?n.isZero()?new i(n):(t=i.precision,e=i.rounding,i.precision=t+10,i.rounding=1,(n=n.sin()).s=1,n=C(n,new i(1).minus(n.times(n)).sqrt(),t+10,0),i.precision=t,i.rounding=e,I(2==r||4==r?n.neg():n,t,e,!0)):new i(NaN)},A.times=A.mul=function(t){var e,n,r,i,s,o,a,u,l,f=this,p=f.constructor,h=f.d,m=(t=new p(t)).d;if(t.s*=f.s,!(h&&h[0]&&m&&m[0]))return new p(!t.s||h&&!h[0]&&!m||m&&!m[0]&&!h?NaN:h&&m?0*t.s:t.s/0);for(n=v(f.e/E)+v(t.e/E),(u=h.length)<(l=m.length)&&(s=h,h=m,m=s,o=u,u=l,l=o),s=[],r=o=u+l;r--;)s.push(0);for(r=l;--r>=0;){for(e=0,i=u+r;i>r;)a=s[i]+m[r]*h[i-r-1]+e,s[i--]=a%M|0,e=a/M|0;s[i]=(s[i]+e)%M|0}for(;!s[--o];)s.pop();return e?++n:s.shift(),t.d=s,t.e=T(s,n),c?I(t,p.precision,p.rounding):t},A.toBinary=function(t,e){return $(this,2,t,e)},A.toDecimalPlaces=A.toDP=function(t,e){var n=this,r=n.constructor;return n=new r(n),void 0===t?n:(O(t,0,s),void 0===e?e=r.rounding:O(e,0,8),I(n,t+n.e+1,e))},A.toExponential=function(t,e){var n,r=this,i=r.constructor;return void 0===t?n=P(r,!0):(O(t,0,s),void 0===e?e=i.rounding:O(e,0,8),n=P(r=I(new i(r),t+1,e),!0,t+1)),r.isNeg()&&!r.isZero()?"-"+n:n},A.toFixed=function(t,e){var n,r,i=this,o=i.constructor;return void 0===t?n=P(i):(O(t,0,s),void 0===e?e=o.rounding:O(e,0,8),n=P(r=I(new o(i),t+i.e+1,e),!1,t+r.e+1)),i.isNeg()&&!i.isZero()?"-"+n:n},A.toFraction=function(t){var e,n,r,i,s,o,a,u,l,f,h,m,v=this,d=v.d,w=v.constructor;if(!d)return new w(v);if(l=n=new w(1),o=(s=(e=new w(r=u=new w(0))).e=U(d)-v.e-1)%E,e.d[0]=g(10,o<0?E+o:o),null==t)t=s>0?e:l;else{if(!(a=new w(t)).isInt()||a.lt(l))throw Error(p+a);t=a.gt(e)?s>0?e:l:a}for(c=!1,a=new w(x(d)),f=w.precision,w.precision=s=d.length*E*2;h=C(a,e,0,1,1),1!=(i=n.plus(h.times(r))).cmp(t);)n=r,r=i,i=l,l=u.plus(h.times(i)),u=i,i=e,e=a.minus(h.times(i)),a=i;return i=C(t.minus(n),r,0,1,1),u=u.plus(i.times(l)),n=n.plus(i.times(r)),u.s=l.s=v.s,m=C(l,r,s,1).minus(v).abs().cmp(C(u,n,s,1).minus(v).abs())<1?[l,r]:[u,n],w.precision=f,c=!0,m},A.toHexadecimal=A.toHex=function(t,e){return $(this,16,t,e)},A.toNearest=function(t,e){var n=this,r=n.constructor;if(n=new r(n),null==t){if(!n.d)return n;t=new r(1),e=r.rounding}else{if(t=new r(t),void 0===e?e=r.rounding:O(e,0,8),!n.d)return t.s?n:t;if(!t.d)return t.s&&(t.s=n.s),t}return t.d[0]?(c=!1,n=C(n,t,0,e,1).times(t),c=!0,I(n)):(t.s=n.s,n=t),n},A.toNumber=function(){return+this},A.toOctal=function(t,e){return $(this,8,t,e)},A.toPower=A.pow=function(t){var e,n,r,i,s,o,a=this,u=a.constructor,l=+(t=new u(t));if(!(a.d&&t.d&&a.d[0]&&t.d[0]))return new u(g(+a,l));if((a=new u(a)).eq(1))return a;if(r=u.precision,s=u.rounding,t.eq(1))return I(a,r,s);if((e=v(t.e/E))>=t.d.length-1&&(n=l<0?-l:l)<=9007199254740991)return i=k(u,a,n,r),t.s<0?new u(1).div(i):I(i,r,s);if((o=a.s)<0){if(eu.maxE+1||e0?o/0:0):(c=!1,u.rounding=a.s=1,n=Math.min(12,(e+"").length),(i=G(t.times(j(a,r+n)),r)).d&&R((i=I(i,r+5,1)).d,r,s)&&(e=r+10,+x((i=I(G(t.times(j(a,e+n)),e),e+5,1)).d).slice(r+1,r+15)+1==1e14&&(i=I(i,r+1,0))),i.s=o,c=!0,u.rounding=s,I(i,r,s))},A.toPrecision=function(t,e){var n,r=this,i=r.constructor;return void 0===t?n=P(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):(O(t,1,s),void 0===e?e=i.rounding:O(e,0,8),n=P(r=I(new i(r),t,e),t<=r.e||r.e<=i.toExpNeg,t)),r.isNeg()&&!r.isZero()?"-"+n:n},A.toSignificantDigits=A.toSD=function(t,e){var n=this.constructor;return void 0===t?(t=n.precision,e=n.rounding):(O(t,1,s),void 0===e?e=n.rounding:O(e,0,8)),I(new n(this),t,e)},A.toString=function(){var t=this,e=t.constructor,n=P(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()&&!t.isZero()?"-"+n:n},A.truncated=A.trunc=function(){return I(new this.constructor(this),this.e+1,1)},A.valueOf=A.toJSON=function(){var t=this,e=t.constructor,n=P(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()?"-"+n:n};var C=function(){function t(t,e,n){var r,i=0,s=t.length;for(t=t.slice();s--;)r=t[s]*e+i,t[s]=r%n|0,i=r/n|0;return i&&t.unshift(i),t}function e(t,e,n,r){var i,s;if(n!=r)s=n>r?1:-1;else for(i=s=0;ie[i]?1:-1;break}return s}function r(t,e,n,r){for(var i=0;n--;)t[n]-=i,i=t[n]1;)t.shift()}return function(i,s,o,a,u,l){var c,f,p,h,m,g,d,w,y,b,N,S,A,x,O,R,q,C,P,T,L=i.constructor,_=i.s==s.s?1:-1,U=i.d,D=s.d;if(!(U&&U[0]&&D&&D[0]))return new L(i.s&&s.s&&(U?!D||U[0]!=D[0]:D)?U&&0==U[0]||!D?0*_:_/0:NaN);for(l?(m=1,f=i.e-s.e):(l=M,m=E,f=v(i.e/m)-v(s.e/m)),P=D.length,q=U.length,b=(y=new L(_)).d=[],p=0;D[p]==(U[p]||0);p++);if(D[p]>(U[p]||0)&&f--,null==o?(x=o=L.precision,a=L.rounding):x=u?o+(i.e-s.e)+1:o,x<0)b.push(1),g=!0;else{if(x=x/m+2|0,p=0,1==P){for(h=0,D=D[0],x++;(p1&&(D=t(D,h,l),U=t(U,h,l),P=D.length,q=U.length),R=P,S=(N=U.slice(0,P)).length;S

=l/2&&++C;do{h=0,(c=e(D,N,P,S))<0?(A=N[0],P!=S&&(A=A*l+(N[1]||0)),(h=A/C|0)>1?(h>=l&&(h=l-1),1==(c=e(d=t(D,h,l),N,w=d.length,S=N.length))&&(h--,r(d,P=10;h/=10)p++;y.e=p+f*m-1,I(y,u?o+y.e+1:o,a,g)}return y}}();function I(t,e,n,r){var i,s,o,a,u,l,f,p,h,m=t.constructor;t:if(null!=e){if(!(p=t.d))return t;for(i=1,a=p[0];a>=10;a/=10)i++;if((s=e-i)<0)s+=E,o=e,u=(f=p[h=0])/g(10,i-o-1)%10|0;else if((h=Math.ceil((s+1)/E))>=(a=p.length)){if(!r)break t;for(;a++<=h;)p.push(0);f=u=0,i=1,o=(s%=E)-E+1}else{for(f=a=p[h],i=1;a>=10;a/=10)i++;u=(o=(s%=E)-E+i)<0?0:f/g(10,i-o-1)%10|0}if(r=r||e<0||void 0!==p[h+1]||(o<0?f:f%g(10,i-o-1)),l=n<4?(u||r)&&(0==n||n==(t.s<0?3:2)):u>5||5==u&&(4==n||r||6==n&&(s>0?o>0?f/g(10,i-o):0:p[h-1])%10&1||n==(t.s<0?8:7)),e<1||!p[0])return p.length=0,l?(e-=t.e+1,p[0]=g(10,(E-e%E)%E),t.e=-e||0):p[0]=t.e=0,t;if(0==s?(p.length=h,a=1,h--):(p.length=h+1,a=g(10,E-s),p[h]=o>0?(f/g(10,i-o)%g(10,o)|0)*a:0),l)for(;;){if(0==h){for(s=1,o=p[0];o>=10;o/=10)s++;for(o=p[0]+=a,a=1;o>=10;o/=10)a++;s!=a&&(t.e++,p[0]==M&&(p[0]=1));break}if(p[h]+=a,p[h]!=M)break;p[h--]=0,a=1}for(s=p.length;0===p[--s];)p.pop()}return c&&(t.e>m.maxE?(t.d=null,t.e=NaN):t.e0?s=s.charAt(0)+"."+s.slice(1)+D(r):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(t.e<0?"e":"e+")+t.e):i<0?(s="0."+D(-i-1)+s,n&&(r=n-o)>0&&(s+=D(r))):i>=o?(s+=D(i+1-o),n&&(r=n-i-1)>0&&(s=s+"."+D(r))):((r=i+1)0&&(i+1===o&&(s+="."),s+=D(r))),s}function T(t,e){var n=t[0];for(e*=E;n>=10;n/=10)e++;return e}function L(t,e,n){if(e>N)throw c=!0,n&&(t.precision=n),Error(h);return I(new t(a),e,1,!0)}function _(t,e,n){if(e>S)throw Error(h);return I(new t(u),e,n,!0)}function U(t){var e=t.length-1,n=e*E+1;if(e=t[e]){for(;e%10==0;e/=10)n--;for(e=t[0];e>=10;e/=10)n++}return n}function D(t){for(var e="";t--;)e+="0";return e}function k(t,e,n,r){var i,s=new t(1),o=Math.ceil(r/E+4);for(c=!1;;){if(n%2&&W((s=s.times(e)).d,o)&&(i=!0),0===(n=v(n/2))){n=s.d.length-1,i&&0===s.d[n]&&++s.d[n];break}W((e=e.times(e)).d,o)}return c=!0,s}function F(t){return 1&t.d[t.d.length-1]}function B(t,e,n){for(var r,i=new t(e[0]),s=0;++s17)return new h(t.d?t.d[0]?t.s<0?0:1/0:1:t.s?t.s<0?0:t:NaN);for(null==e?(c=!1,u=v):u=e,a=new h(.03125);t.e>-2;)t=t.times(a),p+=5;for(u+=r=Math.log(g(2,p))/Math.LN10*2+5|0,n=s=o=new h(1),h.precision=u;;){if(s=I(s.times(t),u,1),n=n.times(++f),x((a=o.plus(C(s,n,u,1))).d).slice(0,u)===x(o.d).slice(0,u)){for(i=p;i--;)o=I(o.times(o),u,1);if(null!=e)return h.precision=v,o;if(!(l<3&&R(o.d,u-r,m,l)))return I(o,h.precision=v,m,c=!0);h.precision=u+=10,n=s=a=new h(1),f=0,l++}o=a}}function j(t,e){var n,r,i,s,o,a,u,l,f,p,h,m=1,v=t,g=v.d,d=v.constructor,w=d.rounding,y=d.precision;if(v.s<0||!g||!g[0]||!v.e&&1==g[0]&&1==g.length)return new d(g&&!g[0]?-1/0:1!=v.s?NaN:g?0:v);if(null==e?(c=!1,f=y):f=e,d.precision=f+=10,r=(n=x(g)).charAt(0),!(Math.abs(s=v.e)<15e14))return l=L(d,f+2,y).times(s+""),v=j(new d(r+"."+n.slice(1)),f-10).plus(l),d.precision=y,null==e?I(v,y,w,c=!0):v;for(;r<7&&1!=r||1==r&&n.charAt(1)>3;)r=(n=x((v=v.times(t)).d)).charAt(0),m++;for(s=v.e,r>1?(v=new d("0."+n),s++):v=new d(r+"."+n.slice(1)),p=v,u=o=v=C(v.minus(1),v.plus(1),f,1),h=I(v.times(v),f,1),i=3;;){if(o=I(o.times(h),f,1),x((l=u.plus(C(o,new d(i),f,1))).d).slice(0,f)===x(u.d).slice(0,f)){if(u=u.times(2),0!==s&&(u=u.plus(L(d,f+2,y).times(s+""))),u=C(u,new d(m),f,1),null!=e)return d.precision=y,u;if(!R(u.d,f-10,w,a))return I(u,d.precision=y,w,c=!0);d.precision=f+=10,l=o=v=C(p.minus(1),p.plus(1),f,1),h=I(v.times(v),f,1),i=a=1}u=l,i+=2}}function Z(t){return String(t.s*t.s/0)}function V(t,e){var n,r,i;for((n=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(n<0&&(n=r),n+=+e.slice(r+1),e=e.substring(0,r)):n<0&&(n=e.length),r=0;48===e.charCodeAt(r);r++);for(i=e.length;48===e.charCodeAt(i-1);--i);if(e=e.slice(r,i)){if(i-=r,t.e=n=n-r-1,t.d=[],r=(n+1)%E,n<0&&(r+=E),rt.constructor.maxE?(t.d=null,t.e=NaN):t.e0?(l=+n.slice(o+1),n=n.substring(2,o)):n=n.slice(2),a=(o=n.indexOf("."))>=0,i=t.constructor,a&&(o=(u=(n=n.replace(".","")).length)-o,s=k(i,new i(r),o,2*o)),o=h=(f=q(n,r,M)).length-1;0===f[o];--o)f.pop();return o<0?new i(0*t.s):(t.e=T(f,h),t.d=f,c=!1,a&&(t=C(t,s,4*u)),l&&(t=t.times(Math.abs(l)<54?Math.pow(2,l):e.pow(2,l))),c=!0,t)}function z(t,e,n,r,i){var s,o,a,u,l=t.precision,f=Math.ceil(l/E);for(c=!1,u=n.times(n),a=new t(r);;){if(o=C(a.times(u),new t(e++*e++),l,1),a=i?r.plus(o):r.minus(o),r=C(o.times(u),new t(e++*e++),l,1),void 0!==(o=a.plus(r)).d[f]){for(s=f;o.d[s]===a.d[s]&&s--;);if(-1==s)break}s=a,a=r,r=o,o=s}return c=!0,o.d.length=f+1,o}function H(t,e){var n,i=e.s<0,s=_(t,t.precision,1),o=s.times(.5);if((e=e.abs()).lte(o))return r=i?4:1,e;if((n=e.divToInt(s)).isZero())r=i?3:2;else{if((e=e.minus(n.times(s))).lte(o))return r=F(n)?i?2:3:i?4:1,e;r=F(n)?i?1:4:i?3:2}return e.minus(s).abs()}function $(t,e,r,i){var a,u,l,c,f,p,h,m,v,g=t.constructor,d=void 0!==r;if(d?(O(r,1,s),void 0===i?i=g.rounding:O(i,0,8)):(r=g.precision,i=g.rounding),t.isFinite()){for(d?(a=2,16==e?r=4*r-3:8==e&&(r=3*r-2)):a=e,(l=(h=P(t)).indexOf("."))>=0&&(h=h.replace(".",""),(v=new g(1)).e=h.length-l,v.d=q(P(v),10,a),v.e=v.d.length),u=f=(m=q(h,10,a)).length;0==m[--f];)m.pop();if(m[0]){if(l<0?u--:((t=new g(t)).d=m,t.e=u,m=(t=C(t,v,r,i,0,a)).d,u=t.e,p=n),l=m[r],c=a/2,p=p||void 0!==m[r+1],p=i<4?(void 0!==l||p)&&(0===i||i===(t.s<0?3:2)):l>c||l===c&&(4===i||p||6===i&&1&m[r-1]||i===(t.s<0?8:7)),m.length=r,p)for(;++m[--r]>a-1;)m[r]=0,r||(++u,m.unshift(1));for(f=m.length;!m[f-1];--f);for(l=0,h="";l1)if(16==e||8==e){for(l=16==e?4:3,--f;f%l;f++)h+="0";for(f=(m=q(h,a,e)).length;!m[f-1];--f);for(l=1,h="1.";lf)for(u-=f;u--;)h+="0";else ue)return t.length=e,!0}function Y(t){return new this(t).abs()}function J(t){return new this(t).acos()}function Q(t){return new this(t).acosh()}function K(t,e){return new this(t).plus(e)}function tt(t){return new this(t).asin()}function et(t){return new this(t).asinh()}function nt(t){return new this(t).atan()}function rt(t){return new this(t).atanh()}function it(t,e){t=new this(t),e=new this(e);var n,r=this.precision,i=this.rounding,s=r+4;return t.s&&e.s?t.d||e.d?!e.d||t.isZero()?(n=e.s<0?_(this,r,i):new this(0)).s=t.s:!t.d||e.isZero()?(n=_(this,s,1).times(.5)).s=t.s:e.s<0?(this.precision=s,this.rounding=1,n=this.atan(C(t,e,s,1)),e=_(this,s,1),this.precision=r,this.rounding=i,n=t.s<0?n.minus(e):n.plus(e)):n=this.atan(C(t,e,s,1)):(n=_(this,s,1).times(e.s>0?.25:.75)).s=t.s:n=new this(NaN),n}function st(t){return new this(t).cbrt()}function ot(t){return I(t=new this(t),t.e+1,2)}function at(t){if(!t||"object"!=typeof t)throw Error(f+"Object expected");var e,n,r,o=!0===t.defaults,a=["precision",1,s,"rounding",0,8,"toExpNeg",-i,0,"toExpPos",0,i,"maxE",0,i,"minE",-i,0,"modulo",0,9];for(e=0;e=a[e+1]&&r<=a[e+2]))throw Error(p+n+": "+r);this[n]=r}if(n="crypto",o&&(this[n]=l[n]),void 0!==(r=t[n])){if(!0!==r&&!1!==r&&0!==r&&1!==r)throw Error(p+n+": "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(m);this[n]=!0}else this[n]=!1}return this}function ut(t){return new this(t).cos()}function lt(t){return new this(t).cosh()}function ct(t,e){return new this(t).div(e)}function ft(t){return new this(t).exp()}function pt(t){return I(t=new this(t),t.e+1,3)}function ht(){var t,e,n=new this(0);for(c=!1,t=0;t=429e7?e[o]=crypto.getRandomValues(new Uint32Array(1))[0]:u[o++]=i%1e7;else{if(!crypto.randomBytes)throw Error(m);for(e=crypto.randomBytes(r*=4);o=214e7?crypto.randomBytes(4).copy(e,o):(u.push(i%1e7),o+=4);o=r/4}else for(;o=10;i/=10)r++;rs.maxE?(i.e=NaN,i.d=null):t.e=10;n/=10)e++;return void(c?e>s.maxE?(i.e=NaN,i.d=null):e

Solve for x Calculator | Instant Answers (2)

Solve for x Calculator | Instant Answers (3)

\text{Solve for x}

Help

?

Solve for x Calculator | Instant Answers (4)

Lesson on Solving for Variables

Lesson Contents

How to Solve for a Variable

In algebra, we solve for a variable within an equation by isolating the variable. However, sometimes we cannot isolate the variable because it has multiple unlike terms of the same variable (such as x2 + 2x). These cases require special techniques to solve. Also, there will sometimes be no real solution for the variable.

To isolate a variable, use the reverse order of operations to move every term that does not contain the variable to the other side of the equation. Continue performing algebraic manipulation until only the variable itself is present on its side of the equation.

When the Variable can't be Isolated

If there are multiple unlike terms containing the applicable variable, we may not be able to algebraically manipulate the equation enough for full variable isolation. An example is trying to solve for x in the polynomial equation 0 = 2x3 + x2 – 6x + 5.

We may employ special techniques in these cases. Commonly used techniques for solving polynomials include factoring and the quadratic formula. Factoring can be used on a polynomial of any degree, while the quadratic formula can only be used on 2nd-degree (quadratic) polynomials.

Sometimes we come across an equation that cannot be solved by hand. This can be due to it not having any real, whole number, fractional, or rational solutions. In fact, statistically, these equations are more likely to occur in the real-world than equations that can be solved by hand.

These cases are where numerical methods must be employed. Numerical methods are leveraged by computers to perform many iterations of an explicit technique to converge on a very accurate approximate solution. The calculator on this page employs numerical methods when there is no exact algebraic solution.

How the Calculator Works

The calculator on this page is written in the programming language JavaScript (JS) and powered by a JS native computer algebra system (CAS). Your device’s internet browser runs the calculator entirely in its built-in JS engine, providing near-instant answers at the click of the calculate button.

When you click the calculate button, your inputted equation or expression is filtered into the CAS which then solves for x. The CAS first attempts to solve symbolically. It treats each letter and number as a symbol and isolates the variable being solved for. When it cannot attain a solution symbolically, it then attempts to solve using numerical methods.

Once finished solving, the result is converted to LaTeX (a math rendering language) and displayed on the calculator as the answer. Sometimes the inputted expression or equation has no solution or causes an error during calculations. When this happens, an error notice is displayed in the answer area.

Solve for x Calculator | Instant Answers (2024)

References

Top Articles
Latest Posts
Article information

Author: Annamae Dooley

Last Updated:

Views: 6116

Rating: 4.4 / 5 (65 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Annamae Dooley

Birthday: 2001-07-26

Address: 9687 Tambra Meadow, Bradleyhaven, TN 53219

Phone: +9316045904039

Job: Future Coordinator

Hobby: Archery, Couponing, Poi, Kite flying, Knitting, Rappelling, Baseball

Introduction: My name is Annamae Dooley, I am a witty, quaint, lovely, clever, rich, sparkling, powerful person who loves writing and wants to share my knowledge and understanding with you.