L'Hopital's Rule Calculator | Best Full Solution Steps (2024)

Learn how to calculate limits with L'Hopital's rule.

L'Hopital's Rule Calculator

$$\lim_{x\to}$$

How to Use This Calculator

L'Hopital's Rule Calculator | Best Full Solution Steps (1)

Solution

Return to calculator

This calculator uses L'Hopital's rule to solve indeterminate limits of the forms 00 and .
Fill in the input fields to calculate the solution.

Want unlimited access to calculators, answers, and solution steps?

Join Now

100% risk free. Cancel anytime.

INTRODUCING

L'Hopital's Rule Calculator | Best Full Solution Steps (2)

L'Hopital's Rule Lesson

What is L'Hopital's Rule?

L'Hopital's rule is a theorem that allows us to evaluate limits that result in indeterminate fractional forms, by taking the derivative of the function on the top of the fraction and taking the derivative of the function on the bottom of the fraction.

Sometimes when evaluating the limit of a function we end up with an indeterminate form. Indeterminate means it does not have a defined value. As an example, let's look at the following limit:

$$\lim_{x \to 2} \frac{x^2+x-6}{x^2-4}$$

Evaluating the limit at x = 2, we get:

$$ \frac{(2)^2+(2)-6}{(2)^2-4} = \frac{4+2-6}{4-4} = \boxed{\frac{0}{0}}$$

Zero divided by zero is indeterminate, so we do not have a defined value for this evaluated limit yet.

But, with L'Hopital's rule, we can take the derivative of the top and bottom functions and then re-evaluate the limit with the possibility of finding a determinate solution.

Why do we Learn About L'Hopital's Rule?

The power of L'Hopital's rule in helping us evaluate certain limits is evident in many real-world examples, so let's hone in on just one of them for now: it can help us plan space missions to learn more about the solar system and beyond.

L'Hopital's Rule Calculator | Best Full Solution Steps (5)

When planning space missions, we must use a variety of orbital mechanics equations to determine the path a spacecraft will take during the mission. Some of these equations tell us how close we will come to celestial objects (such as planets) during a gravity assist (also called a slingshot maneuver).

Sometimes we take limits of these equations to determine closest approaches to bodies or even maximum velocity of a spacecraft. But, some of the equations are fractional form and may have indeterminate results to the limit evaluation.

Fortunately, L'Hopital's rule allows us to take the derivative of the top and bottom of the fraction and re-evaluate the limit in these cases. Therefore, it can help us solve otherwise unsolvable limits to accurately plan a space mission!

How to Evaluate Limits Using L'Hopital's Rule

L'Hopital's rule tells us that when evaluating the limit of a fractional function, we can take the derivative of the top and bottom and still have an equivalent function in regard to the limit evaluation.

For example:

$$ \lim_{x \to c} \frac{f(x)}{g(x)} = \lim_{x \to c} \frac{f'(x)}{g'(x)} = \lim_{x \to c} \frac{f''(x)}{g''(x)} = \; ... $$

Where c is the x value to evaluate the limit at, f(x) is the top function, g(x) is the bottom function, f'(x) is the derivative of the top function, and g'(x) is the derivative of the bottom function.

We may take the derivative of the top and bottom as many times as needed for finding a determinate solution.

The general process of using L'Hopital's rule is as follows:

1) Take the limit of the top function f(x) and the bottom function g(x).

2a) If the entire fraction's resulting limit is determinate, we have our solution.

2b) If the entire fraction's resulting limit is indeterminate, we take the derivative of the top function f(x) and the bottom function g(x) and then repeat steps 1 and 2.

The indeterminate fraction forms we look out for while evaluating limits are:

$$ \frac{0}{0} \text{, } \; \frac{\infty}{\infty} \text{, } \; \frac{-\infty}{-\infty} \text{, } \; \frac{-\infty}{\infty} \text{, } \; \frac{\infty}{-\infty} $$

So, any form of zero over zero is indeterminate, and any form of infinity over infinity is indeterminate.

Example Problem 1

$$ \begin{align} & \hspace{2ex} \text{Let's evaluate the following limit using L'Hopital's rule:} \\ \\ & \hspace{2ex} \lim_{x \to 2} \frac{x^2+x-6}{x^2-4}\\ \\ & \hspace{2ex} \text{To do this, we will:} \\ \\ & \hspace{5ex} \text{Step 1) Take the limit of the top function } f(x) \text{ and the bottom function } g(x) \text{.} \\ \\ & \hspace{5ex} \text{Step 2a) If the entire fraction's resulting limit is determinate, we have our solution.} \\ \\ & \hspace{5ex} \text{Step 2b) If the entire fraction's resulting limit is indeterminate } ( 0/0 \text{ or } \infty / \infty ) \text{,} \\ & \hspace{14ex} \text{we take the derivative of the top function } f(x) \text{ and the} \\ & \hspace{14ex} \text{bottom function } g(x) \text{ and then repeat steps 1 and 2.}\\ \\ \\ & \hspace{2ex} \text{Limit 1, Step 1)} \\ \\ & \hspace{4ex} \text{Let's take the limit of the top function } f(x) \text{ and the bottom function } g(x) \text{.} \\ \\ & \hspace{8ex} \text{Doing so, we get:} \\ \\ & \hspace{8ex} \text{Top function: } \\ & \hspace{8ex} \lim_{x \to c} f(x) \; \Longrightarrow \; \lim_{x \to 2} \left(x^2+x-6\right) = 0\\ \\ & \hspace{8ex} \text{Bottom function: } \\ & \hspace{8ex} \lim_{x \to c} g(x) \; \Longrightarrow \; \lim_{x \to 2} \left(x^2-4\right) = 0\\ \\ & \hspace{2ex} \text{Limit 1, Step 2a)} \\ \\ & \hspace{4ex} \text{Plugging these results into the original fraction, we get:} \\ \\ & \hspace{8ex} \Longrightarrow \; \frac{0}{0} \\ \\ & \hspace{8ex} \text{The entire fraction's resulting limit is } \underline{indeterminate.} \\ \\ & \hspace{10ex} \Longrightarrow \text{Due to being of the indeterminate form } \frac{0}{0} \text{.}\\ \\ & \hspace{2ex} \text{Limit 1, Step 2b)} \\ \\ & \hspace{4ex} \text{Since it is indeterminate, we will take the derivative} \\ & \hspace{4ex} \text{of the top function and of the bottom function.} \\ \\ & \hspace{8ex} \text{Doing so, we get:} \\ \\ & \hspace{8ex} \text{Top function: } \\ & \hspace{8ex} f'(x) = 1 + 2 x\\ \\ & \hspace{8ex} \text{Bottom function: } \\ & \hspace{8ex} g'(x) = 2 x\\ \\ \\ & \hspace{2ex} \text{Limit 2, Step 1)} \\ \\ & \hspace{4ex} \text{Let's take the limit of the new top function } f'(x) \text{ and the new bottom function } g'(x) \text{.} \\ \\ & \hspace{8ex} \text{Doing so, we get:} \\ \\ & \hspace{8ex} \text{Top function: } \\ & \hspace{8ex} \lim_{x \to c} f'(x) \; \Longrightarrow \; \lim_{x \to 2} \left(1 + 2 x\right) = 5\\ \\ & \hspace{8ex} \text{Bottom function: } \\ & \hspace{8ex} \lim_{x \to c} g'(x) \; \Longrightarrow \; \lim_{x \to 2} \left(2 x\right) = 4\\ \\ & \hspace{2ex} \text{Limit 2, Step 2a)} \\ \\ & \hspace{4ex} \text{Plugging these results into the original fraction, we get:} \\ \\ & \hspace{8ex} \Longrightarrow \; \frac{5}{4} \\ \\ & \hspace{8ex} \text{The entire fraction's resulting limit is } \underline{determinate.} \\ \\ & \hspace{8ex} \boxed{ \: \text{Solution: } \hspace{2ex} \lim_{x \to 2} \frac{x^2+x-6}{x^2-4} = \boxed{\frac{5}{4}} \; }\\ & \end{align} $$

Example Problem 2

$$ \begin{align} & \hspace{2ex} \text{Let's evaluate the following limit using L'Hopital's rule:} \\ \\ & \hspace{2ex} \lim_{x \to \infty} \frac{-2x^2}{x+3}\\ \\ & \hspace{2ex} \text{To do this, we will:} \\ \\ & \hspace{5ex} \text{Step 1) Take the limit of the top function } f(x) \text{ and the bottom function } g(x) \text{.} \\ \\ & \hspace{5ex} \text{Step 2a) If the entire fraction's resulting limit is determinate, we have our solution.} \\ \\ & \hspace{5ex} \text{Step 2b) If the entire fraction's resulting limit is indeterminate } ( 0/0 \text{ or } \infty / \infty ) \text{,} \\ & \hspace{14ex} \text{we take the derivative of the top function } f(x) \text{ and the} \\ & \hspace{14ex} \text{bottom function } g(x) \text{ and then repeat steps 1 and 2.}\\ \\ \\ & \hspace{2ex} \text{Limit 1, Step 1)} \\ \\ & \hspace{4ex} \text{Let's take the limit of the top function } f(x) \text{ and the bottom function } g(x) \text{.} \\ \\ & \hspace{8ex} \text{Doing so, we get:} \\ \\ & \hspace{8ex} \text{Top function: } \\ & \hspace{8ex} \lim_{x \to c} f(x) \; \Longrightarrow \; \lim_{x \to \infty} \left(-2x^2\right) = - \infty\\ \\ & \hspace{8ex} \text{Bottom function: } \\ & \hspace{8ex} \lim_{x \to c} g(x) \; \Longrightarrow \; \lim_{x \to \infty} \left(x+3\right) = \infty\\ \\ & \hspace{2ex} \text{Limit 1, Step 2a)} \\ \\ & \hspace{4ex} \text{Plugging these results into the original fraction, we get:} \\ \\ & \hspace{8ex} \Longrightarrow \; \frac{- \infty}{\infty} \\ \\ & \hspace{8ex} \text{The entire fraction's resulting limit is } \underline{indeterminate.} \\ \\ & \hspace{10ex} \Longrightarrow \text{Due to being of the indeterminate form } \frac{- \infty}{\infty} \text{.}\\ \\ & \hspace{2ex} \text{Limit 1, Step 2b)} \\ \\ & \hspace{4ex} \text{Since it is indeterminate, we will take the derivative} \\ & \hspace{4ex} \text{of the top function and of the bottom function.} \\ \\ & \hspace{8ex} \text{Doing so, we get:} \\ \\ & \hspace{8ex} \text{Top function: } \\ & \hspace{8ex} f'(x) = - 4 x\\ \\ & \hspace{8ex} \text{Bottom function: } \\ & \hspace{8ex} g'(x) = 1\\ \\ \\ & \hspace{2ex} \text{Limit 2, Step 1)} \\ \\ & \hspace{4ex} \text{Let's take the limit of the new top function } f'(x) \text{ and the new bottom function } g'(x) \text{.} \\ \\ & \hspace{8ex} \text{Doing so, we get:} \\ \\ & \hspace{8ex} \text{Top function: } \\ & \hspace{8ex} \lim_{x \to c} f'(x) \; \Longrightarrow \; \lim_{x \to \infty} \left(- 4 x\right) = - \infty\\ \\ & \hspace{8ex} \text{Bottom function: } \\ & \hspace{8ex} \lim_{x \to c} g'(x) \; \Longrightarrow \; \lim_{x \to \infty} \left(1\right) = 1\\ \\ & \hspace{2ex} \text{Limit 2, Step 2a)} \\ \\ & \hspace{4ex} \text{Plugging these results into the original fraction, we get:} \\ \\ & \hspace{8ex} \Longrightarrow \; \frac{- \infty}{1} \\ \\ & \hspace{8ex} \text{The entire fraction's resulting limit is } \underline{determinate.} \\ \\ & \hspace{8ex} \boxed{ \: \text{Solution: } \hspace{2ex} \lim_{x \to \infty} \frac{-2x^2}{x+3} = \boxed{ - \infty} \; }\\ & \end{align} $$

How the Calculator Works

The L'Hopital's Rule Calculator is built with code from the languages HTML, CSS, and JS.

The HTML (HyperText Markup Language) creates the infrastructure of the calculator. It defines every element that we see and interact with and can be thought of as the "nouns" of the calculator.

The CSS (Cascading Style Sheets) styles the calculator and defines every color and shape that we see. Without it, the calculator would not look much like a calculator. CSS can be thought of as the "adjectives" of the calculator.

The JS (JavaScript) provides the functionality of the calculator. This includes the clickable buttons, the solution and solution steps printout, and all of the math that happens behind the scenes to solve our problem inputs! JS can be thought of as the "verbs" of the calculator.

Learning math has never been easier.

Get unlimited access to more than 168 personalized lessons and 73 interactive calculators.

Join Voovers+ Today

100% risk free. Cancel anytime.

"; } else { localStorage.setItem(calcName, true); } } function modalOpener() { document.getElementById('steps-cta-button').click(); } } else { document.getElementById('cta-1-section').style.display = 'none'; document.getElementById('cta-2-article').style.display = 'none'; }

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

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

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

r.numVal)&&(e.pop(),e.push(i))}}function Ot(e,n){if(e.equals(1))return new Ft(0);var i;if(e.fname===w&&e.multiplier.equals(1))return i=t.divide(Ot(e.args[0]),new Ft(2)),e.power.sign()<0&&i.negate(),i;if(e.equals(0))throw new yt(a.LOG+"(0) is undefined!");if(e.isImaginary())return g.evaluate(e,a.LOG);if(e.isConstant()&&void 0!==n&&n.isConstant())i=new Ft(Math.log(e)/Math.log(n));else if(e.group===f&&e.power.multiplier.lessThan(0)||"-1"===e.power.toString())e.power.negate(),i=Ot(e).negate();else if("e"===e.value&&e.multiplier.equals(1)){var r=e.power;i=U(r)?r:new Ft(r)}else if(e.group===p&&"exp"===e.fname){var s=e.args[0];i=e.multiplier.equals(1)?t.multiply(s,new Ft(e.power)):t.symfunction(a.LOG,[e])}else if(a.PARSE2NUMBER&&X(e)){var o;(e=t.parse(e)).multiplier.lessThan(0)&&(e.negate(),o=t.multiply(new Ft(Math.PI),new Ft("i"))),i=new Ft(Math.log(e.multiplier.toDecimal())),o&&(i=t.add(i,o))}else{e.power.equals(1)||e.contains("e")||(s=e.group===f?e.power:new Ft(e.power),e.toLinear()),i=arguments.length>1&&R(arguments)?new Ft(1):t.symfunction(a.LOG,arguments),s&&(i=t.multiply(s,i))}return i}function It(e,n){var i,r,s,o,a=n&&n.isConstant()||void 0===n;return e.isConstant()&&a?(i=e,n&&n.lessThan(0)&&(n=k(n),i=(r=Number(e).toExponential().toString().split("e"))[0],s=r[1]),o=new Ft(et(i,Number(n||0))),t.multiply(o,t.pow(new Ft(10),new Ft(s||0)))):t.symfunction("round",arguments)}function qt(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 Ct(t){if(!isFinite(t)){var e=Math.sign(t),n=new Ft(String(Math.abs(t)));return n.multiplier=n.multiplier.multiply(new Bt(e)),n}if(U(t))return t;if("number"==typeof t)try{t=Bt.simple(t)}catch(e){t=new Bt(t)}var i=new Ft(0);return i.multiplier=t,i}function Tt(e,n){if(Array.isArray(e))return e.map(function(t){return Tt(t,n)});if(n=n||{},e.group===p&&""===e.fname){var i=Tt(e.args[0],n),r=Tt(t.pow(i,t.parse(e.power)),n);return t.multiply(t.parse(e.multiplier),r).distributeMultiplier()}if(-1!==[u,l,c].indexOf(e.group))return e;var s=e.clone();try{var o=e.multiplier.toString(),a=Number(e.power),f=e;if(e.isComposite()&&V(e.power)&&e.power>0){var g=a-1;i=new Ft(0);e.each(function(e){i=t.add(i,Tt(t.parse(e),n))});for(var d=t.parse(i),w=0;w1&&(i=Tt(t.pow(i,t.parse(i.power)),n)),f=t.multiply(t.parse(o),i).distributeMultiplier()):f=i):(f=i,M.forEach(function(e){f=t.multiply(f,e)}),f=t.multiply(f,t.parse(o)).distributeMultiplier()),f.group===m&&(f=t.parse(f))}else f=e;return f}catch(t){return s}return s}function Dt(t){if(!U(t.power)&&t.power.absEquals(.5)){var e=t.power.sign(),n=W(t.group===l?new Ft(t.value):t.toLinear());return e<0&&n.invert(),n}return t}this.toTeX=function(e,n){var i=!0===(n=n||{}).decimals?"decimals":void 0,r="string"==typeof e?this.toObject(e):e,s=[],o=void 0===n.cdot?"\\cdot":n.cdot;if(r=function(t){for(var e=[];t.length;){var n=t.shift(),i=t[0],r=Z(i),s="-"===i;if("^"===n&&("+"===i?t.shift():r&&"+"===i[0]&&i.shift(),r&&1===i.length&&t.unshift(t.shift()[0])),"^"===n&&(r&&"-"===i[0]||s)){var o=e.pop(),a=e[e.length-1],u="1";"*"===a?(e.pop(),u=e.pop()):Z(a)&&(u=e.pop()),e.push(u,"/",o,n),r?i.shift():t.shift(),r&&1===i.length&&e.push(t.shift()[0])}else e.push(n)}return e}(r),Z(r)){for(var u,l,c=[],f=0;f0?"\\frac{d}{d "+A[0]+"}":"\\frac{d}{d x}"}else S=2===E.length?"\\frac{d}{d "+E[1]+"}":"\\frac{d^{"+E[2]+"}}{d "+this.toTeX(E[1])+"^{"+E[2]+"}}";v=S+"\\left("+N+"\\right)"}else if("sum"===g||"product"===g){var x=[[],[],[],[]],O=0;for(f=0;fe.length&&e.group===n.group&&([e,n]=[n,e])),e.multiplier.equals(0))return n;if(n.multiplier.equals(0))return e;if(e.isConstant()&&n.isConstant()&&a.PARSE2NUMBER)return A=new Ft(e.multiplier.add(n.multiplier).toDecimal(a.PRECISION));var d=e.group,y=n.group,b=e.power.toString(),M=n.power.toString();if(dM&&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,I=e.value,R=n.value,q=e.isComposite(),C=n.isComposite();if(q&&(N=_t(e,"hash")),C&&(S=_t(n,"hash")),d===v&&y===v&&n.isLinear()&&!e.isLinear()&&N!==S)return this.add(n,e);d===h&&y===h&&(I=N,R=S);var P=d===l&&y===u,T=e.value===n.multiplier.toString(),L=I===R||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,"add"),A=n):(A=Ft.shell(h).attach([e,n])).value=d===h?N:I;else if(q&&e.isLinear()){var k=d===y,B=d===h&&y===h;if(B&&(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 B&&e.value!==S||d===h&&!L?(A=Ft.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=W(n.toUnitMultiplier().toLinear())).multiplier=j}2===e.length&&2===n.length&&it(e.power)&&it(n.power)?A=t.add(Tt(e),Tt(n)):(A=Ft.shell(v).attach([e,n])).updateHash()}if(A.multiplier.equals(0)&&(A=new Ft(0)),1===A.length){j=A.multiplier;(A=J(A.symbols)).multiplier=A.multiplier.multiply(j)}return A}if(r&&!i){E=e;e=n,n=E,E=r,r=i,i=E}var X=G(n);if(i&&X){var Z=new Vt;n.eachElement(function(n,i,r){Z.set(i,r,t.add(e.clone(),n))}),n=Z}else if(G(e)&&X)n=e.add(n);else if(i&&F(n))n.each(function(i,r){r--,n.elements[r]=t.add(e.clone(),n.elements[r])});else if(F(e)&&F(n))n.each(function(i,r){r--,n.elements[r]=t.add(e.elements[r],n.elements[r])});else{if(F(e)&&G(n))return t.add(n,e);if(G(e)&&F(n)){if(n.elements.length===e.rows()){Z=new Vt;var V=e.cols();return n.each(function(n,i){for(var r=[],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 Ft(1));else{var O=e.power,I=t.parse(e.multiplier);(e=t.multiply(I,e.args[0].clone())).setPower(new Bt(.5).multiply(O)),E=e.group}var R=e.value,q=n.value,C=(d=new Bt(e.sign()),E===l&&N===u&&n.multiplier.equals(e.value)),P=C?new Bt(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)&&V(_)&&(g=t.multiply(e.args[0].clone(),W(_.clone())),n=new Ft(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 Ft(1),D<0){for(var k=0,B=Math.abs(D);k<=B;k++){var j=t.add(T.clone(),new Ft(k));M=t.multiply(M,j)}g=t.multiply(t.pow(T,new Ft(e.power)),t.pow(M,new Ft(n.power))),n=new Ft(1)}else{for(k=0,B=Math.abs(D);k<=B;k++){j=t.add(L.clone(),new Ft(k));M=t.multiply(M,j)}g=t.multiply(t.pow(M,new Ft(e.power)),t.pow(L,new Ft(n.power))),n=new Ft(1)}}}if(R===q&&E===h&&E===N&&(R=e.text("hash"),q=n.text("hash")),N===f&&n.previousGroup===h&&E===h&&(R=_t(e,"hash",f)),R!==q&&!C||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 X=n.symbols[j];g=g.combine(X)}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 Z=n.multiplier.clone();n.toUnitMultiplier(),(g=Ft.shell(m).combine([g,n])).multiplier=g.multiplier.multiply(Z)}}else g=n.clone().toUnitMultiplier();else{var z=e.power,H=n.power,$=U(z),Y=U(H),Q=$||Y;if(E===h&&N!==h&&n.previousGroup!==h&&z.equals(1))g=new Ft(0),e.each(function(e){g=t.add(g,t.multiply(e,n.clone()))},!0);else{if(g.power=Q?t.add(U(z)?z:new Ft(z),U(H)?H:new Ft(H)):E===u?z:z.add(H),g.power.equals(0)&&(g=g.convert(u)),Q&&g.convert(f),e.imaginary&&n.imaginary)it(g.power%2)&&(g=new Ft(1),P.negate());g.group!==f&&g.previousGroup&&(g.previousGroup=void 0),g.multiplier=g.multiplier.multiply(n.multiplier)}}if(g.group===l){var K=Math.log(g.value),tt=Math.log(S)/K,et=Math.log(A)/K,nt=P.num/S,rt=P.den/A;0!==tt&&V(tt)&&V(nt)&&(g.power=g.power.add(new Bt(tt)),P.num/=S),0!==et&&V(et)&&V(rt)&&(g.power=g.power.subtract(new Bt(et)),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(it(st)&&g.fname===w){d*=g.sign();var ot=g.power;g=g.args[0],g=t.multiply(new Ft(P),t.pow(g,new Ft(ot.divide(new Bt(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&&V(g.power.toDecimal())&&(g=g.convert(u)),g}o&&!r&&(M=e,e=n,n=M,M=o,o=r,r=M);var at=G(n),ut=G(e);if(r&&at){var lt=new Vt;n.eachElement(function(n,i,r){lt.set(i,r,t.multiply(e.clone(),n))}),n=lt}else if(ut&&at)n=e.multiply(n);else if(r&&F(n))n.each(function(i,r){r--,n.elements[r]=t.multiply(e.clone(),n.elements[r])});else if(F(e)&&F(n))n.each(function(i,r){r--,n.elements[r]=t.multiply(e.elements[r],n.elements[r])});else{if(F(e)&&G(n))return this.multiply(n,e);if(G(e)&&F(n)){if(n.elements.length===e.rows()){lt=new Vt;var ct=e.cols();return n.each(function(n,i){for(var r=[],s=0;s0&&3===st)&&O.negate()}else{var K=n.multiplier.multiply(Bt.quick(1,2)),tt=Math.pow(-1,K.num);O=it(K.den)?new Ft(-1).setPower(K,!0):new Ft(tt)}if(I<0&&!Y&&O.negate(),S&&e.group!==f){var et=it(n.multiplier.den),nt=it(e.power),st=O.power.toDecimal(),ot=it(st);if(et&&nt&&!ot){if(1===st)O=t.symfunction(y,[O]);else if(V(st))O=t.multiply(t.symfunction(y,[O.clone().toLinear()]),O.clone().setPower(new Bt(st-1)));else{R=O.power;O=t.symfunction(y,[O.toLinear()]).setPower(R)}a.POSITIVE_MULTIPLIERS&&O.fname===y&&(O=O.args[0])}}if(n.equals(2)&&O.group===m){var at=new Ft(1);O.each(function(e){at=t.multiply(at,t.pow(e,n))}),O=at}}}if(O=Dt(O),W&&J&&(O=t.multiply(O,function(t){if(t.group===l){var e=t.value,n=Ut(e)[0];if(!n)return q("Unable to compute prime factors. This should not happen. Please review and report."),t;var i=new Bt(Math.log(e)/Math.log(n)).multiply(t.power);if(i.den>t.power.den)return t;t=V(i)?Ft(Math.pow(n,i)):new Ft(n).setPower(i)}return t}(t.multiply(W,J)))),O.fname===w){var ut=O.group===f,lt=ut?O.power.multiplier.toString():O.power.toString();if(it(lt)){var ct=ut?t.divide(O.power,new Ft(2)):new Ft(O.power.divide(new Bt(2)));o=O.multiplier;(O=t.pow(O.args[0],ct)).multiplier=O.multiplier.multiply(o)}}else if(!a.IGNORE_E&&O.isE()&&O.group===f&&O.power.contains("pi")&&O.power.contains(a.IMAGINARY)&&n.group===m){var ft=n.stripVar(a.IMAGINARY);O=t.add(E.cos(ft),t.multiply(Ft.imaginary(),E.sin(ft)))}return O}if(F(e)&&s)e=e.map(function(e){return t.pow(e,n.clone())});else if(G(e)&&s){var pt=new Vt;e.eachElement(function(e,i,r){pt.set(i,r,t.pow(e,n.clone()))}),e=pt}else if(r&&G(n)){pt=new Vt;n.eachElement(function(n,i,r){pt.set(i,r,t.pow(e.clone(),n))}),e=pt}return e},this.comma=function(t,e){return t instanceof s||(t=s.create(t)),t.append(e),t},this.mod=function(t,e){return z(t,e)},this.slice=function(t,e){return new r(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 Ft(100))},this.assign=function(e,n){if(e instanceof s&&n instanceof s)return e.elements.map(function(e,i){return t.assign(e,n.elements[i])}),Zt.fromArray(n.elements);if(e.parent){var i=e.parent;return i.elements[i.getter]=n,delete i.getter,i}if(e.group!==c)throw new Rt("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 kt=function(t){return new Ft(!0===t?1:0)};this.eq=function(t,e){return kt(t.equals(e))},this.gt=function(t,e){return kt(t.gt(e))},this.gte=function(t,e){return kt(t.gte(e))},this.lt=function(t,e){return kt(t.lt(e))},this.lte=function(t,e){return kt(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(Lt),at(Lt),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)},Ut(314146179365),Dt.getExpression=function(t,e){"last"!==t&&t||(t=E.length),"first"===t&&(t=1);var n=E[t-1];return n?new Dt(n):n},Dt.prototype={text:function(t,e){return e=e||19,t=t||"decimals",this.symbol.text_?this.symbol.text_(t):_t(this.symbol,t,void 0,e)},latex:function(t){return this.symbol.latex?this.symbol.latex(t):Xt.latex(this.symbol,t)},valueOf:function(){return this.symbol.valueOf()},evaluate:function(){if(F(this.symbol)&&0===this.symbol.dimensions())return this;var t,n=arguments[0],i=1;"string"==typeof n?t="%"===n.charAt(0)?Dt.getExpression(n.substr(1)).text():n:n instanceof Dt||U(n)?t=n.text():(t=this.symbol.text(),i--);var r=arguments[i]||{};return new Dt(lt("PARSE2NUMBER",function(){return e.parse(t,r)},!0))},buildFunction:function(t){return Ht.build(this.symbol,t)},isNumber:function(){return X(this.symbol)},isInfinity:function(){return Math.abs(this.symbol.multiplier)===1/0},isImaginary:function(){return ft(e.parse(this.symbol)).isImaginary()},variables:function(){return k(this.symbol)},toString:function(){try{return Z(this.symbol)?"["+this.symbol.toString()+"]":this.symbol.toString()}catch(t){return""}},toDecimal:function(t){a.precision=t;var e=_t(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 Dt(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 Dt(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 Dt(e.expand(this.symbol))},each:function(t,e){if(this.symbol.each)this.symbol.each(t,e);else if(Z(this.symbol))for(e=0;e4&&r++,e.coeff=n+r}return e},copy:function(){var t=new kt(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:kt.round(this.coeff,t);return e=0===this.exponent&&a.SCIENTIFIC_IGNORE_INTS?this.coeff:n+"e"+this.exponent,(-1===this.sign?"-":"")+e}},kt.isScientific=function(t){return/\d+\.?\d*e[\+\-]*\d+/i.test(t)},kt.leadingZeroes=function(t){var e=t.match(/^(0*).*$/);return e?e[1]:""},kt.removeLeadingZeroes=function(t){var e=t.match(/^0*(.*)$/);return e?e[1]:""},kt.removeTrailingZeroes=function(t){var e=t.match(/0*$/);return e?t.substring(0,t.length-e[0].length):""},kt.round=function(t,e){var n=et(t,e),i=e-String(n).split(".").pop().length;return i>0&&(n+=new Array(i+1).join(0)),n},kt.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]||"",i=e[1]||"";n=kt.removeLeadingZeroes(n),i=kt.removeTrailingZeroes(i);var r=n.length,s=n+i,o=kt.leadingZeroes(s).length;this.exponent=r-(o+1);var a=kt.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=i,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),i=this.coeff.substring(t+1,t+3),r=i.charAt(0);i.charAt(1)>4&&r++,e.coeff=n+r}return e},copy:function(){var t=new kt(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 i;return this.group!==h&&this.group!==c||this.value!==t?this.group===m&&this.isLinear()?(i=new Ft(1),this.each(function(n){n.contains(t,!0)||(i=e.multiply(i,n.clone()))}),i.multiplier=i.multiplier.multiply(this.multiplier)):this.group!==v||this.isLinear()?this.group===v&&this.isLinear()?(i=new Ft(0),this.each(function(n){if(!n.contains(t)){var r=n.clone();r.multiplier=r.multiplier.multiply(this.multiplier),i=e.add(i,r)}}),i.equals(0)&&(i=new Ft(this.multiplier))):i=this.group===f&&this.power.contains(t,!0)?new Ft(this.multiplier):this.group===p&&this.contains(t)?new Ft(this.multiplier):this.clone():i=new Ft(this.multiplier):i=new Ft(n?0:this.multiplier),i},toArray:function(t,n){n=n||{arr:[],add:function(t,n){var i=this.arr[n];this.arr[n]=i?e.add(i,t):t}};var i=this.group;if(i===c&&this.contains(t))n.add(new Ft(this.multiplier),this.power);else if(i===m){var r=this.stripVar(t),s=e.divide(this.clone(),r.clone()),o=s.isConstant()?0:s.power;n.add(r,o)}else if(i===h&&this.value===t)this.each(function(e,i){n.add(e.stripVar(t),i)});else if(i===v)this.each(function(e){e.toArray(t,n)});else{if(this.contains(t))throw new Et("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=_t(this,"hash"),this.group=f);else if(t===u){var i=this.multiplier.toDecimal();this.symbols&&(this.symbols=void 0),new Ft(this.group===l?i*Math.pow(this.value,this.power):i).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 i=this.group;if(i>p){var r=t.keyForGroup(i),s=r in this.symbols&&this.symbols[r];if("add"===n){var o=r;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 Bt(0)))):(this.symbols[r]=t,this.length++)}else t.group===l&&V(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,r),t)).isConstant()&&(this.multiplier=this.multiplier.multiply(t.multiplier),t=new Ft(1)),this.length--),t.isOne(!0)?t.multiplier.lessThan(0)&&this.negate():(this.symbols[r]=t,this.length++);0===this.length&&this.convert(u),this.group!==v&&this.group!==m||this.updateHash()}}return this},attach:function(t){if(Z(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 jt={convert:function(t,e){var n;if(0===t)n=[0,1];else if(t<1e-6||t>1e20){var i=this.quickConversion(Number(t));if(i[1]<=1e20){var r=Math.abs(t),s=t/r;(n=this.fullConversion(r.toFixed((i[1]+"").length-1)))[0]=n[0]*s}else n=i}else n=this.fullConversion(t);return n},quickConversion:function(t){var e=function(t){"string"!=typeof t&&(t=t.toString());var e="",n=t.charAt(0);return"-"===n?(t=t.substr(1,t.length),e="-"):"+"===n&&(t=t.substr(1,t.length)),{sign:e,value:t}};return function(t){kt.isScientific(t)&&(t=P(t));var n,i=e(t),r=i.value.split(".");n=1===r.length?r[0]:r[0]+r[1];var s=r[1]?r[1].length:0,o=`1${"0".repeat(s)}`;return"0"!==n&&(n=n.replace(/^0+/,"")),[i.sign+n,o]}(t)},fullConversion:function(t){for(var e=!1,n=0,i=1,r=1,s=0,o=0,a=t;!e;){++o>1e4&&(e=!0);var u=Math.floor(a),l=n+u*r,c=i+u*s,f=a-u;f<1e-16&&(e=!0),a=1/f,n=r,i=s,r=l,s=c,(Math.abs(l/c-t)<1e-16||o>30)&&(e=!0)}return[l,c]}},Xt={parser:function(){var t=["classes","setOperator","getOperators","getBrackets","tokenize","toRPN","tree","units"],e=new Gt;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),Z(t)){for(var i=[],r=0;r1)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 I=N[0],R=N[1],q=N[2],C=N[3];o[h]="\\sum\\limits_{"+this.braces(R)+"="+this.braces(q)+"}^"+this.braces(C)+" "+this.braces(I)}else if("product"===S){I=N[0],R=N[1],q=N[2],C=N[3];o[h]="\\prod\\limits_{"+this.braces(R)+"="+this.braces(q)+"}^"+this.braces(C)+" "+this.braces(I)}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(r===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(Xt.latex(T[A],n));var D=L.join("+");o[h]=t.isLinear()&&t.multiplier.equals(1)&&!i?D:this.brackets(D,"parens")}else if(r===m||s===f||s===m){r===m&&t.distributeExponent();var k=[],B=[],F=[],G=[],j=0,X=0,Z=function(t,e,n){if(n>1&&e.length>0)for(var i=e.length,r=0;r1;)e.length>0&&(n="_"+this.braces(e.pop()+n));return e[0]+n},formatP:function(t){for(var e=0;e<2;e++){var n=t[e];n&&(t[e]="^"+this.braces(n))}return t},formatFrac:function(t,e){var n=t.num.toString(),i=t.den.toString();return e&&"1"===n&&"1"===i?"":"1"===i?n:this.frac(n,i)},frac:function(t,e){return"\\frac"+this.braces(t)+this.braces(e)},braces:function(t){return"{"+t+"}"},brackets:function(t,e){var n={parens:["(",")"],square:["[","]"],brace:["{","}"],abs:["|","|"],angle:["\\langle","\\rangle"]}[e=e||"parens"];return"\\left"+n[0]+t+"\\right"+n[1]},filterTokens:function(t){var e=[];Z(t)&&(e.type=t.type);for(var n=["\\","left","right","big","Big","large","Large"],i=0,r=t.length;ithis.elements.length?null:this.elements[t-1]},set:function(t,e){U(e)||(e=new Ft(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 Ft(.5))},void 0,this)},eql:function(t){var n=this.elements.length,i=t.elements||t;if(n!==i.length)return!1;do{if(Math.abs(e.subtract(this.elements[n-1],i[n-1]).valueOf())>PRECISION)return!1}while(--n);return!0},clone:function(){for(var t=new Zt,e=this.elements.length,n=0;n1&&(a=1),new Ft(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,i){return e.add(t,n[i-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,i){return e.subtract(t,n[i-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,i=new Ft(0),r=this.elements.length;if(r!==n.length)return null;do{i=e.add(i,e.multiply(this.elements[r-1],n[r-1]))}while(--r);return i},void 0,this)},cross:function(t){var n=t.elements||t;if(3!==this.elements.length||3!==n.length)return null;var i=this.elements;return lt("SAFE",function(){return new Zt([e.subtract(e.multiply(i[1],n[2]),e.multiply(i[2],n[1])),e.subtract(e.multiply(i[2],n[0]),e.multiply(i[0],n[2])),e.subtract(e.multiply(i[0],n[1]),e.multiply(i[1],n[0]))])},void 0,this)},max:function(){var t,e=0,n=this.elements.length,i=n;do{t=i-n,Math.abs(this.elements[t].valueOf())>Math.abs(e.valueOf())&&(e=this.elements[t])}while(--n);return e},magnitude:function(){var t=new Ft(0);return this.each(function(n){t=e.add(t,e.pow(n,new Ft(2)))}),e.sqrt(t)},indexOf:function(t){var e,n=null,i=this.elements.length,r=i;do{e=r-i,null===n&&this.elements[e].valueOf()===t.valueOf()&&(n=e+1)}while(--i);return n},text:function(t){return _t(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 i=0;i=l&&h[t].push(a)}while(--i);for(f.elements[t]=s,n=0;n0},is_subset:function(t){for(var e=t.elements,n=0,i=e.length;n1?o[1]:o[0])+"="+n[s]+";",r[s]=o.pop()}return[r,i]},getArgsDeps:function(t,e){for(var n=t.args,i=0;i21&&this.set("USE_BIG",!0)):"USE_LN"===t&&!0===n?(a.LOG="LN",a.LOG10="log",e.functions.log=a.LOG_FNS.log10,e.functions.log[0]=function(t){return t.isConstant()?new Ft(Math.log10(t)):e.symfunction(a.LOG10,[t])},e.functions.LN=a.LOG_FNS.log,delete e.functions.log10):a[t]=n},Wt.get=function(t){return a[t]},Wt.api=function(t){var n=function(t){return function(){for(var n=[].slice.call(arguments),i=0;i\n
    \n
  • \n'+this.tree(t).toHTML(3,e)+"\n
  • \n
\n

"},Wt.addPeeker=function(t,n){e.peekers[t]&&e.peekers[t].push(n)},Wt.removePeeker=function(t,n){ut(e.peekers[t],n)},Wt.parse=function(t){return String(t).split(";").map(function(t){return e.parse(t)})},Wt.api(),Wt}({bigInt:function(){var t=function(e){"use strict";var n=1e7,i=7,r=9007199254740992,s=f(r),o=Math.log(r);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-r

0?Math.floor(t):Math.ceil(t)}function g(t,e){var i,r,s=t.length,o=e.length,a=new Array(s),u=0,l=n;for(r=0;r=l?1:0,a[r]=i-u*l;for(;r0&&a.push(u),a}function d(t,e){return t.length>=e.length?g(t,e):g(e,t)}function w(t,e){var i,r,s=t.length,o=new Array(s),a=n;for(r=0;r0;)o[r++]=e%a,e=Math.floor(e/a);return o}function y(t,e){var i,r,s=t.length,o=e.length,a=new Array(s),u=0,l=n;for(i=0;i0;)o[r++]=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,i){return new u(t=0;--i)s=(o=s*l+t[i])-(r=v(o/e))*e,u[i]=0|r;return[u,0|s]}function O(t,e){var i,r,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;r--){for(i=h-1,w[r+f]!==g&&(i=Math.floor((w[r+f]*h+w[r+f-1])/g)),s=0,o=0,u=y.length,a=0;al&&(s=(s+1)*m),i=Math.ceil(s/o);do{if(I(a=E(e,i),f)<=0)break;i--}while(i);c.push(i),f=y(f,a)}return c.reverse(),[p(c),p(f)]}(o,c))[0];var b=t.sign!==s.sign,M=i[1],N=t.sign;return"number"==typeof r?(b&&(r=-r),r=new l(r)):r=new u(r,b),"number"==typeof M?(N&&(M=-M),M=new l(M)):M=new u(M,N),[r,M]}function I(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 R(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 q(e,n){for(var i,r,s,o=e.prev(),u=o,l=0;u.isEven();)u=u.divide(2),l++;t:for(r=0;r=0?i=y(t,e):(i=y(e,t),n=!n),"number"==typeof(i=p(i))?(n&&(i=-i),new l(i)):new u(i,n)}(n,i,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 i=e.value;return e.isSmall?new l(n-i):b(i,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,i,r,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 i=Math.max(e.length,n.length);if(i<=30)return M(e,n);i=Math.ceil(i/2);var r=e.slice(i),s=e.slice(0,i),o=n.slice(i),a=n.slice(0,i),u=t(s,a),l=t(r,o),c=d(d(u,N(y(y(t(d(s,r),d(a,o)),u),l),i)),N(l,2*i));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,i,r=$(t),s=this.value,o=r.value;if(0===o)return a[1];if(0===s)return a[0];if(1===s)return a[1];if(-1===s)return r.isEven()?a[1]:a[-1];if(r.sign)return a[0];if(!r.isSmall)throw new Error("The exponent "+r.toString()+" is too large.");if(this.isSmall&&c(e=Math.pow(s,o)))return new l(v(e));for(n=this,i=a[1];!0&o&&(i=i.times(n),--o),0!==o;)o/=2,n=n.square();return i},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],i=this.mod(e);t.isPositive();){if(i.isZero())return a[0];t.isOdd()&&(n=n.multiply(i).mod(e)),t=t.divide(2),i=i.square().mod(e)}return n},l.prototype.modPow=u.prototype.modPow,u.prototype.compareAbs=function(t){var e=$(t),n=this.value,i=e.value;return e.isSmall?1:I(n,i)},l.prototype.compareAbs=function(t){var e=$(t),n=Math.abs(this.value),i=e.value;return e.isSmall?n===(i=Math.abs(i))?0:n>i?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,i=e.value;return this.sign!==e.sign?e.sign?1:-1:e.isSmall?this.sign?-1:1:I(n,i)*(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,i=e.value;return e.isSmall?n==i?0:n>i?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=R(this);if(void 0!==n)return n;var i=this.abs(),r=i.bitLength();if(r<=64)return q(i,[2,325,9375,28178,450775,9780504,1795265022]);for(var s=Math.log(2)*r,o=Math.ceil(!0===e?2*Math.pow(s,2):s),a=[],u=0;u-r?new l(t-1):new u(s,!0)};for(var C=[1];2*C[C.length-1]<=n;)C.push(2*C[C.length-1]);var P=C.length,T=C[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,i){n=$(n);for(var r=e.isNegative(),s=n.isNegative(),o=r?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(),r&&(u=T-1-u),l=(f=O(a,T))[1].toJSNumber(),s&&(l=T-1-l),o=c[0],a=f[0],p.push(i(u,l));for(var h=0!==i(r?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(C[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,C[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,i="number"==typeof e?e|U:e[0]+e[1]*n|D;return i&-i}function B(t,e){return t=$(t),e=$(e),t.greater(e)?t:e}function F(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,i,r=a[1];t.isEven()&&e.isEven();)n=Math.min(k(t),k(e)),t=t.divide(n),e=e.divide(n),r=r.multiply(n);for(;t.isEven();)t=t.divide(k(t));do{for(;e.isEven();)e=e.divide(k(e));t.greater(e)&&(i=e,e=t,t=i),e=e.subtract(t)}while(!e.isZero());return r.isUnit()?t:t.multiply(r)}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,i){if(i.compareTo(n)<=0){var r=e(n,i.square(i)),s=r.p,o=r.e,a=s.multiply(i);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,i=Math.abs(e),r=0;r=i){if("1"===c&&1===i)continue;throw new Error(c+" is not a valid digit in base "+e+".")}if(c.charCodeAt(0)-87>=i)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(r=u?1:0;r"!==t[r]);a.push($(t.slice(p+1,r)))}}return X(a,e,u)};function X(t,e,n){var i,r=a[0],s=a[1];for(i=t.length-1;i>=0;i--)r=r.add(t[i].times(s)),s=s.times(e);return n?r.negate():r}function Z(t){return t<=35?"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t):"<"+t+">"}function V(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 i=Array.apply(null,Array(+e-1)).map(Array.prototype.valueOf,[0,1]);return i.unshift([1]),{value:[].concat.apply([],i),isNegative:!1}}var r=!1;if(e.isNegative()&&n.isPositive()&&(r=!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:r};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:r}}function z(t,e){var n=V(t,e);return(n.isNegative?"-":"")+n.value.map(Z).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 r=t.split(/e/i);if(r.length>2)throw new Error("Invalid integer: "+r.join("e"));if(2===r.length){var s=r[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=r[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=i,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 V(this,t)},l.prototype.toArray=function(t){return V(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,i=n.length,r=String(n[--i]);--i>=0;)e=String(n[i]),r+="0000000".slice(e.length)+e;return(this.sign?"-":"")+r},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 Y=0;Y<1e3;Y++)a[Y]=new l(Y),Y>0&&(a[-Y]=new l(-Y));return a.one=a[1],a.zero=a[0],a.minusOne=a[-1],a.max=B,a.min=F,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 i=F(t=$(t),e=$(e)),r=B(t,e).subtract(i).add(1);if(r.isSmall)return i.add(Math.floor(Math.random()*r));for(var s=[],o=!0,a=r.value.length-1;a>=0;a--){var c=o?r.value[a]:n,f=v(Math.random()*c);s.unshift(f),f0){for(s+=o,e=1;en)throw Error(h+t)}function R(t,e,n,i){var r,s,o,a;for(s=t[0];s>=10;s/=10)--e;return--e<0?(e+=N,r=0):(r=Math.ceil((e+1)/N),e%=N),s=d(10,N-e),a=t[r]%s|0,null==i?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[r+1]/s/100|0)==d(10,e-2)-1||(a==s/2||0==a)&&0==(t[r+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=(i||n<4)&&9999==a||!i&&n>3&&4999==a):o=((i||n<4)&&a+1==s||!i&&n>3&&a+1==s/2)&&(t[r+1]/s/1e3|0)==d(10,e-3)-1,o}function q(t,e,n){for(var i,r,s=[0],o=0,u=t.length;on-1&&(void 0===s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/n|0,s[i]%=n)}return s.reverse()}x.absoluteValue=x.abs=function(){var t=new this.constructor(this);return t.s<0&&(t.s=1),P(t)},x.ceil=function(){return P(new this.constructor(this),this.e+1,2)},x.comparedTo=x.cmp=function(t){var e,n,i,r,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=(i=o.length)<(r=a.length)?i:r;ea[e]^u<0?1:-1;return i===r?0:i>r^u<0?1:-1},x.cosine=x.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())+N,i.rounding=1,n=function(t,e){var n,i,r=e.d.length;r<32?i=(1/$(4,n=Math.ceil(r/3))).toString():(n=16,i="2.3283064365386962890625e-10"),t.precision+=n,e=H(t,1,e.times(i),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,Y(i,n)),i.precision=t,i.rounding=e,P(2==r||3==r?n.neg():n,t,e,!0)):new i(1):new i(NaN)},x.cubeRoot=x.cbrt=function(){var t,e,n,i,r,s,o,a,u,l,c=this,p=c.constructor;if(!c.isFinite()||c.isZero())return new p(c);for(f=!1,(s=c.s*d(c.s*c,1/3))&&Math.abs(s)!=1/0?i=new p(s.toString()):(n=O(c.d),(s=((t=c.e)-n.length+1)%3)&&(n+=1==s||-2==s?"0":"00"),s=d(n,1/3),t=g((t+1)/3)-(t%3==(t<0?-1:2)),(i=new p(n=s==1/0?"5e"+t:(n=s.toExponential()).slice(0,n.indexOf("e")+1)+t)).s=c.s),o=(t=p.precision)+3;;)if(l=(u=(a=i).times(a).times(a)).plus(c),i=C(l.plus(c).times(a),l.plus(u),o+2,1),O(a.d).slice(0,o)===(n=O(i.d)).slice(0,o)){if("9999"!=(n=n.slice(o-3,o+1))&&(r||"4999"!=n)){+n&&(+n.slice(1)||"5"!=n.charAt(0))||(P(i,t+1,1),e=!i.times(i).times(i).eq(c));break}if(!r&&(P(a,t+1,0),a.times(a).times(a).eq(c))){i=a;break}o+=4,r=1}return f=!0,P(i,t,p.rounding,e)},x.decimalPlaces=x.dp=function(){var t,e=this.d,n=NaN;if(e){if(n=((t=e.length-1)-g(this.e/N))*N,t=e[t])for(;t%10==0;t/=10)n--;n<0&&(n=0)}return n},x.dividedBy=x.div=function(t){return C(this,new this.constructor(t))},x.dividedToIntegerBy=x.divToInt=function(t){var e=this.constructor;return P(C(this,new e(t),0,1,1),e.precision,e.rounding)},x.equals=x.eq=function(t){return 0===this.cmp(t)},x.floor=function(){return P(new this.constructor(this),this.e+1,3)},x.greaterThan=x.gt=function(t){return this.cmp(t)>0},x.greaterThanOrEqualTo=x.gte=function(t){var e=this.cmp(t);return 1==e||0===e},x.hyperbolicCosine=x.cosh=function(){var t,e,n,i,r,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,i=o.rounding,o.precision=n+Math.max(s.e,s.sd())+4,o.rounding=1,(r=s.d.length)<32?e=(1/$(4,t=Math.ceil(r/3))).toString():(t=16,e="2.3283064365386962890625e-10"),s=H(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 P(s,o.precision=n,o.rounding=i,!0)},x.hyperbolicSine=x.sinh=function(){var t,e,n,i,r=this,s=r.constructor;if(!r.isFinite()||r.isZero())return new s(r);if(e=s.precision,n=s.rounding,s.precision=e+Math.max(r.e,r.sd())+4,s.rounding=1,(i=r.d.length)<3)r=H(s,2,r,r,!0);else{t=(t=1.4*Math.sqrt(i))>16?16:0|t,r=H(s,2,r=r.times(1/$(5,t)),r,!0);for(var o,a=new s(5),u=new s(16),l=new s(20);t--;)o=r.times(r),r=r.times(a.plus(o.times(u.times(o).plus(l))))}return s.precision=e,s.rounding=n,P(r,e,n,!0)},x.hyperbolicTangent=x.tanh=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+7,i.rounding=1,C(n.sinh(),n.cosh(),i.precision=t,i.rounding=e)):new i(n.s)},x.inverseCosine=x.acos=function(){var t,e=this,n=e.constructor,i=e.abs().cmp(1),r=n.precision,s=n.rounding;return-1!==i?0===i?e.isNeg()?U(n,r,s):new n(0):new n(NaN):e.isZero()?U(n,r+4,s).times(.5):(n.precision=r+6,n.rounding=1,e=e.asin(),t=U(n,r+4,s).times(.5),n.precision=r,n.rounding=s,t.minus(e))},x.inverseHyperbolicCosine=x.acosh=function(){var t,e,n=this,i=n.constructor;return n.lte(1)?new i(n.eq(1)?0:NaN):n.isFinite()?(t=i.precision,e=i.rounding,i.precision=t+Math.max(Math.abs(n.e),n.sd())+4,i.rounding=1,f=!1,n=n.times(n).minus(1).sqrt().plus(n),f=!0,i.precision=t,i.rounding=e,n.ln()):new i(n)},x.inverseHyperbolicSine=x.asinh=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+2*Math.max(Math.abs(n.e),n.sd())+6,i.rounding=1,f=!1,n=n.times(n).plus(1).sqrt().plus(n),f=!0,i.precision=t,i.rounding=e,n.ln())},x.inverseHyperbolicTangent=x.atanh=function(){var t,e,n,i,r=this,s=r.constructor;return r.isFinite()?r.e>=0?new s(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(t=s.precision,e=s.rounding,i=r.sd(),Math.max(i,t)<2*-r.e-1?P(new s(r),t,e,!0):(s.precision=n=i-r.e,r=C(r.plus(1),new s(1).minus(r),n+t,1),s.precision=t+4,s.rounding=1,r=r.ln(),s.precision=t,s.rounding=e,r.times(.5))):new s(NaN)},x.inverseSine=x.asin=function(){var t,e,n,i,r=this,s=r.constructor;return r.isZero()?new s(r):(e=r.abs().cmp(1),n=s.precision,i=s.rounding,-1!==e?0===e?((t=U(s,n+4,i).times(.5)).s=r.s,t):new s(NaN):(s.precision=n+6,s.rounding=1,r=r.div(new s(1).minus(r.times(r)).sqrt().plus(1)).atan(),s.precision=n,s.rounding=i,r.times(2)))},x.inverseTangent=x.atan=function(){var t,e,n,i,r,s,o,a,u,l=this,c=l.constructor,p=c.precision,h=c.rounding;if(l.isFinite()){if(l.isZero())return new c(l);if(l.abs().eq(1)&&p+4<=A)return(o=U(c,p+4,h).times(.25)).s=l.s,o}else{if(!l.s)return new c(NaN);if(p+4<=A)return(o=U(c,p+4,h).times(.5)).s=l.s,o}for(c.precision=a=p+10,c.rounding=1,t=n=Math.min(28,a/N+2|0);t;--t)l=l.div(l.times(l).plus(1).sqrt().plus(1));for(f=!1,e=Math.ceil(a/N),i=1,u=l.times(l),o=new c(l),r=l;-1!==t;)if(r=r.times(u),s=o.minus(r.div(i+=2)),r=r.times(u),void 0!==(o=s.plus(r.div(i+=2))).d[e])for(t=e;o.d[t]===s.d[t]&&t--;);return n&&(o=o.times(2<this.d.length-2},x.isNaN=function(){return!this.s},x.isNegative=x.isNeg=function(){return this.s<0},x.isPositive=x.isPos=function(){return this.s>0},x.isZero=function(){return!!this.d&&0===this.d[0]},x.lessThan=x.lt=function(t){return this.cmp(t)<0},x.lessThanOrEqualTo=x.lte=function(t){return this.cmp(t)<1},x.logarithm=x.log=function(t){var e,n,i,r,s,o,a,u,l=this.constructor,c=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(r=n[0];r%10==0;)r/=10;s=1!==r}if(f=!1,o=X(this,a=c+5),i=e?_(l,a+10):X(t,a),R((u=C(o,i,a,1)).d,r=c,p))do{if(o=X(this,a+=10),i=e?_(l,a+10):X(t,a),u=C(o,i,a,1),!s){+O(u.d).slice(r+1,r+15)+1==1e14&&(u=P(u,c+1,0));break}}while(R(u.d,r+=10,p));return f=!0,P(u,c,p)},x.minus=x.sub=function(t){var e,n,i,r,s,o,a,u,l,c,p,h,m=this,v=m.constructor;if(t=new v(t),!m.d||!t.d)return m.s&&t.s?m.d?t.s=-t.s:t=new v(t.d||m.s!==t.s?m:NaN):t=new v(NaN),t;if(m.s!=t.s)return t.s=-t.s,m.plus(t);if(l=m.d,h=t.d,a=v.precision,u=v.rounding,!l[0]||!h[0]){if(h[0])t.s=-t.s;else{if(!l[0])return new v(3===u?-0:0);t=new v(m)}return f?P(t,a,u):t}if(n=g(t.e/N),c=g(m.e/N),l=l.slice(),s=c-n){for((p=s<0)?(e=l,s=-s,o=h.length):(e=h,n=c,o=l.length),s>(i=Math.max(Math.ceil(a/N),o)+2)&&(s=i,e.length=1),e.reverse(),i=s;i--;)e.push(0);e.reverse()}else{for((p=(i=l.length)<(o=h.length))&&(o=i),i=0;i0;--i)l[o++]=0;for(i=h.length;i>s;){if(l[--i](o=(s=Math.ceil(a/N))>o?s+1:o+1)&&(r=o,n.length=1),n.reverse();r--;)n.push(0);n.reverse()}for((o=l.length)-(r=c.length)<0&&(r=o,n=c,c=l,l=n),e=0;r;)e=(l[--r]=l[r]+c[r]+e)/E|0,l[r]%=E;for(e&&(l.unshift(e),++i),o=l.length;0==l[--o];)l.pop();return t.d=l,t.e=L(l,i),f?P(t,a,u):t},x.precision=x.sd=function(t){var e,n=this;if(void 0!==t&&t!==!!t&&1!==t&&0!==t)throw Error(h+t);return n.d?(e=D(n.d),t&&n.e+1>e&&(e=n.e+1)):e=NaN,e},x.round=function(){var t=this,e=t.constructor;return P(new e(t),t.e+1,e.rounding)},x.sine=x.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())+N,i.rounding=1,n=function(t,e){var n,i=e.d.length;if(i<3)return H(t,2,e,e);n=(n=1.4*Math.sqrt(i))>16?16:0|n,e=H(t,2,e=e.times(1/$(5,n)),e);for(var r,s=new t(5),o=new t(16),a=new t(20);n--;)r=e.times(e),e=e.times(s.plus(r.times(o.times(r).minus(a))));return e}(i,Y(i,n)),i.precision=t,i.rounding=e,P(r>2?n.neg():n,t,e,!0)):new i(NaN)},x.squareRoot=x.sqrt=function(){var t,e,n,i,r,s,o=this,a=o.d,u=o.e,l=o.s,c=o.constructor;if(1!==l||!a||!a[0])return new c(!l||l<0&&(!a||a[0])?NaN:a?o:1/0);for(f=!1,0==(l=Math.sqrt(+o))||l==1/0?(((e=O(a)).length+u)%2==0&&(e+="0"),l=Math.sqrt(e),u=g((u+1)/2)-(u<0||u%2),i=new c(e=l==1/0?"5e"+u:(e=l.toExponential()).slice(0,e.indexOf("e")+1)+u)):i=new c(l.toString()),n=(u=c.precision)+3;;)if(i=(s=i).plus(C(o,s,n+2,1)).times(.5),O(s.d).slice(0,n)===(e=O(i.d)).slice(0,n)){if("9999"!=(e=e.slice(n-3,n+1))&&(r||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(P(i,u+1,1),t=!i.times(i).eq(o));break}if(!r&&(P(s,u+1,0),s.times(s).eq(o))){i=s;break}n+=4,r=1}return f=!0,P(i,u,c.rounding,t)},x.tangent=x.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,P(2==r||4==r?n.neg():n,t,e,!0)):new i(NaN)},x.times=x.mul=function(t){var e,n,i,r,s,o,a,u,l,c=this,p=c.constructor,h=c.d,m=(t=new p(t)).d;if(t.s*=c.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=g(c.e/N)+g(t.e/N),(u=h.length)<(l=m.length)&&(s=h,h=m,m=s,o=u,u=l,l=o),s=[],i=o=u+l;i--;)s.push(0);for(i=l;--i>=0;){for(e=0,r=u+i;r>i;)a=s[r]+m[i]*h[r-i-1]+e,s[r--]=a%E|0,e=a/E|0;s[r]=(s[r]+e)%E|0}for(;!s[--o];)s.pop();return e?++n:s.shift(),t.d=s,t.e=L(s,n),f?P(t,p.precision,p.rounding):t},x.toBinary=function(t,e){return W(this,2,t,e)},x.toDecimalPlaces=x.toDP=function(t,e){var n=this,i=n.constructor;return n=new i(n),void 0===t?n:(I(t,0,o),void 0===e?e=i.rounding:I(e,0,8),P(n,t+n.e+1,e))},x.toExponential=function(t,e){var n,i=this,r=i.constructor;return void 0===t?n=T(i,!0):(I(t,0,o),void 0===e?e=r.rounding:I(e,0,8),n=T(i=P(new r(i),t+1,e),!0,t+1)),i.isNeg()&&!i.isZero()?"-"+n:n},x.toFixed=function(t,e){var n,i,r=this,s=r.constructor;return void 0===t?n=T(r):(I(t,0,o),void 0===e?e=s.rounding:I(e,0,8),n=T(i=P(new s(r),t+r.e+1,e),!1,t+i.e+1)),r.isNeg()&&!r.isZero()?"-"+n:n},x.toFraction=function(t){var e,n,i,r,s,o,a,u,l,c,p,m,v=this,g=v.d,w=v.constructor;if(!g)return new w(v);if(l=n=new w(1),o=(s=(e=new w(i=u=new w(0))).e=D(g)-v.e-1)%N,e.d[0]=d(10,o<0?N+o:o),null==t)t=s>0?e:l;else{if(!(a=new w(t)).isInt()||a.lt(l))throw Error(h+a);t=a.gt(e)?s>0?e:l:a}for(f=!1,a=new w(O(g)),c=w.precision,w.precision=s=g.length*N*2;p=C(a,e,0,1,1),1!=(r=n.plus(p.times(i))).cmp(t);)n=i,i=r,r=l,l=u.plus(p.times(r)),u=r,r=e,e=a.minus(p.times(r)),a=r;return r=C(t.minus(n),i,0,1,1),u=u.plus(r.times(l)),n=n.plus(r.times(i)),u.s=l.s=v.s,m=C(l,i,s,1).minus(v).abs().cmp(C(u,n,s,1).minus(v).abs())<1?[l,i]:[u,n],w.precision=c,f=!0,m},x.toHexadecimal=x.toHex=function(t,e){return W(this,16,t,e)},x.toNearest=function(t,e){var n=this,i=n.constructor;if(n=new i(n),null==t){if(!n.d)return n;t=new i(1),e=i.rounding}else{if(t=new i(t),void 0===e?e=i.rounding:I(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]?(f=!1,n=C(n,t,0,e,1).times(t),f=!0,P(n)):(t.s=n.s,n=t),n},x.toNumber=function(){return+this},x.toOctal=function(t,e){return W(this,8,t,e)},x.toPower=x.pow=function(t){var e,n,i,r,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(d(+a,l));if((a=new u(a)).eq(1))return a;if(i=u.precision,s=u.rounding,t.eq(1))return P(a,i,s);if((e=g(t.e/N))>=t.d.length-1&&(n=l<0?-l:l)<=9007199254740991)return r=B(u,a,n,i),t.s<0?new u(1).div(r):P(r,i,s);if((o=a.s)<0){if(eu.maxE+1||e0?o/0:0):(f=!1,u.rounding=a.s=1,n=Math.min(12,(e+"").length),(r=j(t.times(X(a,i+n)),i)).d&&R((r=P(r,i+5,1)).d,i,s)&&(e=i+10,+O((r=P(j(t.times(X(a,e+n)),e),e+5,1)).d).slice(i+1,i+15)+1==1e14&&(r=P(r,i+1,0))),r.s=o,f=!0,u.rounding=s,P(r,i,s))},x.toPrecision=function(t,e){var n,i=this,r=i.constructor;return void 0===t?n=T(i,i.e<=r.toExpNeg||i.e>=r.toExpPos):(I(t,1,o),void 0===e?e=r.rounding:I(e,0,8),n=T(i=P(new r(i),t,e),t<=i.e||i.e<=r.toExpNeg,t)),i.isNeg()&&!i.isZero()?"-"+n:n},x.toSignificantDigits=x.toSD=function(t,e){var n=this.constructor;return void 0===t?(t=n.precision,e=n.rounding):(I(t,1,o),void 0===e?e=n.rounding:I(e,0,8)),P(new n(this),t,e)},x.toString=function(){var t=this,e=t.constructor,n=T(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()&&!t.isZero()?"-"+n:n},x.truncated=x.trunc=function(){return P(new this.constructor(this),this.e+1,1)},x.valueOf=x.toJSON=function(){var t=this,e=t.constructor,n=T(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()?"-"+n:n};var C=function(){function t(t,e,n){var i,r=0,s=t.length;for(t=t.slice();s--;)i=t[s]*e+r,t[s]=i%n|0,r=i/n|0;return r&&t.unshift(r),t}function e(t,e,n,i){var r,s;if(n!=i)s=n>i?1:-1;else for(r=s=0;re[r]?1:-1;break}return s}function i(t,e,n,i){for(var r=0;n--;)t[n]-=r,r=t[n]1;)t.shift()}return function(r,s,o,a,u,l){var c,f,p,h,m,v,d,w,y,b,M,S,A,x,O,I,R,q,C,T,L=r.constructor,_=r.s==s.s?1:-1,U=r.d,D=s.d;if(!(U&&U[0]&&D&&D[0]))return new L(r.s&&s.s&&(U?!D||U[0]!=D[0]:D)?U&&0==U[0]||!D?0*_:_/0:NaN);for(l?(m=1,f=r.e-s.e):(l=E,m=N,f=g(r.e/m)-g(s.e/m)),C=D.length,R=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+(r.e-s.e)+1:o,x<0)b.push(1),v=!0;else{if(x=x/m+2|0,p=0,1==C){for(h=0,D=D[0],x++;(p1&&(D=t(D,h,l),U=t(U,h,l),C=D.length,R=U.length),I=C,S=(M=U.slice(0,C)).length;S=l/2&&++q;do{h=0,(c=e(D,M,C,S))<0?(A=M[0],C!=S&&(A=A*l+(M[1]||0)),(h=A/q|0)>1?(h>=l&&(h=l-1),1==(c=e(d=t(D,h,l),M,w=d.length,S=M.length))&&(h--,i(d,C=10;h/=10)p++;y.e=p+f*m-1,P(y,u?o+y.e+1:o,a,v)}return y}}();function P(t,e,n,i){var r,s,o,a,u,l,c,p,h,m=t.constructor;t:if(null!=e){if(!(p=t.d))return t;for(r=1,a=p[0];a>=10;a/=10)r++;if((s=e-r)<0)s+=N,o=e,u=(c=p[h=0])/d(10,r-o-1)%10|0;else if((h=Math.ceil((s+1)/N))>=(a=p.length)){if(!i)break t;for(;a++<=h;)p.push(0);c=u=0,r=1,o=(s%=N)-N+1}else{for(c=a=p[h],r=1;a>=10;a/=10)r++;u=(o=(s%=N)-N+r)<0?0:c/d(10,r-o-1)%10|0}if(i=i||e<0||void 0!==p[h+1]||(o<0?c:c%d(10,r-o-1)),l=n<4?(u||i)&&(0==n||n==(t.s<0?3:2)):u>5||5==u&&(4==n||i||6==n&&(s>0?o>0?c/d(10,r-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]=d(10,(N-e%N)%N),t.e=-e||0):p[0]=t.e=0,t;if(0==s?(p.length=h,a=1,h--):(p.length=h+1,a=d(10,N-s),p[h]=o>0?(c/d(10,r-o)%d(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]==E&&(p[0]=1));break}if(p[h]+=a,p[h]!=E)break;p[h--]=0,a=1}for(s=p.length;0===p[--s];)p.pop()}return f&&(t.e>m.maxE?(t.d=null,t.e=NaN):t.e0?s=s.charAt(0)+"."+s.slice(1)+k(i):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(t.e<0?"e":"e+")+t.e):r<0?(s="0."+k(-r-1)+s,n&&(i=n-o)>0&&(s+=k(i))):r>=o?(s+=k(r+1-o),n&&(i=n-r-1)>0&&(s=s+"."+k(i))):((i=r+1)0&&(r+1===o&&(s+="."),s+=k(i))),s}function L(t,e){var n=t[0];for(e*=N;n>=10;n/=10)e++;return e}function _(t,e,n){if(e>S)throw f=!0,n&&(t.precision=n),Error(m);return P(new t(u),e,1,!0)}function U(t,e,n){if(e>A)throw Error(m);return P(new t(l),e,n,!0)}function D(t){var e=t.length-1,n=e*N+1;if(e=t[e]){for(;e%10==0;e/=10)n--;for(e=t[0];e>=10;e/=10)n++}return n}function k(t){for(var e="";t--;)e+="0";return e}function B(t,e,n,i){var r,s=new t(1),o=Math.ceil(i/N+4);for(f=!1;;){if(n%2&&J((s=s.times(e)).d,o)&&(r=!0),0===(n=g(n/2))){n=s.d.length-1,r&&0===s.d[n]&&++s.d[n];break}J((e=e.times(e)).d,o)}return f=!0,s}function F(t){return 1&t.d[t.d.length-1]}function G(t,e,n){for(var i,r=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?(f=!1,u=v):u=e,a=new h(.03125);t.e>-2;)t=t.times(a),p+=5;for(u+=i=Math.log(d(2,p))/Math.LN10*2+5|0,n=s=o=new h(1),h.precision=u;;){if(s=P(s.times(t),u,1),n=n.times(++c),O((a=o.plus(C(s,n,u,1))).d).slice(0,u)===O(o.d).slice(0,u)){for(r=p;r--;)o=P(o.times(o),u,1);if(null!=e)return h.precision=v,o;if(!(l<3&&R(o.d,u-i,m,l)))return P(o,h.precision=v,m,f=!0);h.precision=u+=10,n=s=a=new h(1),c=0,l++}o=a}}function X(t,e){var n,i,r,s,o,a,u,l,c,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?(f=!1,c=y):c=e,d.precision=c+=10,i=(n=O(g)).charAt(0),!(Math.abs(s=v.e)<15e14))return l=_(d,c+2,y).times(s+""),v=X(new d(i+"."+n.slice(1)),c-10).plus(l),d.precision=y,null==e?P(v,y,w,f=!0):v;for(;i<7&&1!=i||1==i&&n.charAt(1)>3;)i=(n=O((v=v.times(t)).d)).charAt(0),m++;for(s=v.e,i>1?(v=new d("0."+n),s++):v=new d(i+"."+n.slice(1)),p=v,u=o=v=C(v.minus(1),v.plus(1),c,1),h=P(v.times(v),c,1),r=3;;){if(o=P(o.times(h),c,1),O((l=u.plus(C(o,new d(r),c,1))).d).slice(0,c)===O(u.d).slice(0,c)){if(u=u.times(2),0!==s&&(u=u.plus(_(d,c+2,y).times(s+""))),u=C(u,new d(m),c,1),null!=e)return d.precision=y,u;if(!R(u.d,c-10,w,a))return P(u,d.precision=y,w,f=!0);d.precision=c+=10,l=o=v=C(p.minus(1),p.plus(1),c,1),h=P(v.times(v),c,1),r=a=1}u=l,r+=2}}function Z(t){return String(t.s*t.s/0)}function V(t,e){var n,i,r;for((n=e.indexOf("."))>-1&&(e=e.replace(".","")),(i=e.search(/e/i))>0?(n<0&&(n=i),n+=+e.slice(i+1),e=e.substring(0,i)):n<0&&(n=e.length),i=0;48===e.charCodeAt(i);i++);for(r=e.length;48===e.charCodeAt(r-1);--r);if(e=e.slice(i,r)){if(r-=i,t.e=n=n-i-1,t.d=[],i=(n+1)%N,n<0&&(i+=N),it.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,r=t.constructor,a&&(o=(u=(n=n.replace(".","")).length)-o,s=B(r,new r(i),o,2*o)),o=p=(c=q(n,i,E)).length-1;0===c[o];--o)c.pop();return o<0?new r(0*t.s):(t.e=L(c,p),t.d=c,f=!1,a&&(t=C(t,s,4*u)),l&&(t=t.times(Math.abs(l)<54?d(2,l):e.pow(2,l))),f=!0,t)}function H(t,e,n,i,r){var s,o,a,u,l=t.precision,c=Math.ceil(l/N);for(f=!1,u=n.times(n),a=new t(i);;){if(o=C(a.times(u),new t(e++*e++),l,1),a=r?i.plus(o):i.minus(o),i=C(o.times(u),new t(e++*e++),l,1),void 0!==(o=a.plus(i)).d[c]){for(s=c;o.d[s]===a.d[s]&&s--;);if(-1==s)break}s=a,a=i,i=o,o=s}return f=!0,o.d.length=c+1,o}function $(t,e){for(var n=t;--e;)n*=t;return n}function Y(t,e){var n,i=e.s<0,s=U(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 W(t,e,i,r){var s,u,l,c,f,p,h,m,v,g=t.constructor,d=void 0!==i;if(d?(I(i,1,o),void 0===r?r=g.rounding:I(r,0,8)):(i=g.precision,r=g.rounding),t.isFinite()){for(d?(s=2,16==e?i=4*i-3:8==e&&(i=3*i-2)):s=e,(l=(h=T(t)).indexOf("."))>=0&&(h=h.replace(".",""),(v=new g(1)).e=h.length-l,v.d=q(T(v),10,s),v.e=v.d.length),u=f=(m=q(h,10,s)).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,i,r,0,s)).d,u=t.e,p=n),l=m[i],c=s/2,p=p||void 0!==m[i+1],p=r<4?(void 0!==l||p)&&(0===r||r===(t.s<0?3:2)):l>c||l===c&&(4===r||p||6===r&&1&m[i-1]||r===(t.s<0?8:7)),m.length=i,p)for(;++m[--i]>s-1;)m[i]=0,i||(++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,s,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 Q(t){return new this(t).abs()}function K(t){return new this(t).acos()}function tt(t){return new this(t).acosh()}function et(t,e){return new this(t).plus(e)}function nt(t){return new this(t).asin()}function it(t){return new this(t).asinh()}function rt(t){return new this(t).atan()}function st(t){return new this(t).atanh()}function ot(t,e){t=new this(t),e=new this(e);var n,i=this.precision,r=this.rounding,s=i+4;return t.s&&e.s?t.d||e.d?!e.d||t.isZero()?(n=e.s<0?U(this,i,r):new this(0)).s=t.s:!t.d||e.isZero()?(n=U(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=U(this,s,1),this.precision=i,this.rounding=r,n=t.s<0?n.minus(e):n.plus(e)):n=this.atan(C(t,e,s,1)):(n=U(this,s,1).times(e.s>0?.25:.75)).s=t.s:n=new this(NaN),n}function at(t){return new this(t).cbrt()}function ut(t){return P(t=new this(t),t.e+1,2)}function lt(t){if(!t||"object"!=typeof t)throw Error(p+"Object expected");var e,n,i,r=!0===t.defaults,a=["precision",1,o,"rounding",0,8,"toExpNeg",-s,0,"toExpPos",0,s,"maxE",0,s,"minE",-s,0,"modulo",0,9];for(e=0;e=a[e+1]&&i<=a[e+2]))throw Error(h+n+": "+i);this[n]=i}if(n="crypto",r&&(this[n]=c[n]),void 0!==(i=t[n])){if(!0!==i&&!1!==i&&0!==i&&1!==i)throw Error(h+n+": "+i);if(i){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(v);this[n]=!0}else this[n]=!1}return this}function ct(t){return new this(t).cos()}function ft(t){return new this(t).cosh()}function pt(t,e){return new this(t).div(e)}function ht(t){return new this(t).exp()}function mt(t){return P(t=new this(t),t.e+1,3)}function vt(){var t,e,n=new this(0);for(f=!1,t=0;t=429e7?e[s]=crypto.getRandomValues(new Uint32Array(1))[0]:u[s++]=r%1e7;else{if(!crypto.randomBytes)throw Error(v);for(e=crypto.randomBytes(i*=4);s=214e7?crypto.randomBytes(4).copy(e,s):(u.push(r%1e7),s+=4);s=i/4}else for(;s=10;r/=10)i++;is.maxE?(r.e=NaN,r.d=null):t.e=10;n/=10)e++;return void(f?e>s.maxE?(r.e=NaN,r.d=null):e
L'Hopital's Rule Calculator | Best Full Solution Steps (2024)
Top Articles
Latest Posts
Article information

Author: Madonna Wisozk

Last Updated:

Views: 6379

Rating: 4.8 / 5 (48 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Madonna Wisozk

Birthday: 2001-02-23

Address: 656 Gerhold Summit, Sidneyberg, FL 78179-2512

Phone: +6742282696652

Job: Customer Banking Liaison

Hobby: Flower arranging, Yo-yoing, Tai chi, Rowing, Macrame, Urban exploration, Knife making

Introduction: My name is Madonna Wisozk, I am a attractive, healthy, thoughtful, faithful, open, vivacious, zany person who loves writing and wants to share my knowledge and understanding with you.