function SOLNfactors(A,B,C,v,ka,a,kb,b){   var r1=new RAT(-B+Math.round(Math.sqrt(B*B-4*A*C)),2*A), r2=new RAT(-B-Math.round(Math.sqrt(B*B-4*A*C)),2*A);   if(arguments.length==4){ka=r1.bot;a=-r1.top; kb=r2.bot;b=-r2.top;};   var K=gcd(A,gcd(B,C));if(K>1){document.writeln(      showterms([[A,v,2],[B,v],[C,1]," = ",[K,1],"(",[A/K,v,2],[B/K,v],[C/K,1],")"])," and we now factor the right-hand side:<br>");A=A/K;B=B/K;C=C/K};   if(A<0){document.writeln("The roots are the same as those of  ",showterms([[-A,v,2],[-B,v],[-C,1]]),".<br>");            A=-A;B=-B;C=-C};    if(C==0){document.writeln("Both terms have a factor of ",showterms([[gcd(A,B),v]]),"<br>",         "So the complete factorization is ",showterms([[K*gcd(A,B),v],"(",[Math.round(A/gcd(A,B)),v],[Math.round(B/gcd(A,B)),1],")"]));         return};  if(B==0 && issq(A) && (C<0) && issq(-C))     {document.writeln("Both of the terms are squares: ",showterms([[A,v,2]]),     (A!=1?showterms([" = (",[Math.round(Math.sqrt(A)),v],")<sup>2</sup>"]):""),     " and ",     showterms([[-C,1]," = ",[Math.round(Math.sqrt(-C)),1],"<sup>2</sup>"]),":<br>",      "So we can use <b>the difference of two squares:</b><blockquote> ",       showterms([[1,'a'],"<sup>2</sup> &ndash; ",[1,'b<sup>2</sup>']," = (",[1,'a'],[1,'b'],")(",[1,'a'],[-1,'b'],")"]),       "</blockquote>Therefore ",showterms([[A,v,2],[B,v],[C,1]," = (",[ka,v],[a,1]," )( ",[kb,v],[b,1],")"]),       (K>1?" and "+showterms([[K*A,v,2],[K*B,v],[K*C,1]," = ",[K,1],"(",[ka,v],[a,1]," )( ",[kb,v],[b,1],")"]):"")        );     return   };  if(A==1)   {var fps=factorpairs(Math.abs(C));    document.writeln("<span class=ul>The coefficient of ",showterms([[1,v,2]])," is ",showterms([[1,1]]),"</span> so our reference equation is<blockquote>",     showterms(["(",[1,v],[1,'p'],")(",[1,v],[1,'q'],") = ",[1,v,2],' + (',[1,'p'],[1,'q'],')',[1,v],[1,'pq']]),    "</blockquote>We will look for two numbers ",showterms([[1,'p']])," and ",showterms([[1,'q']]),    " that<br> multiply to <span class=ul>the constant term: ",showterms([[C,1]]),"</span>",showterms([" = ",[1,'p q']])," and <br>",    "sum to <span class=ul>the ",  showterms([[1,v]])," coefficient: ",showterms([[B,1]]),"</span>",showterms([" = ",[1,'p'],[1,'q']]),"<p>" ,    (fps.length>1?"There are "+fps.length+" pairs of factors ":"There is only one pair of factors "),     "that multiply to ", showterms([[Math.abs(C),1]]),": <blockquote>",showfactorpairs(C),"</blockquote>",    "The sign of the constant term,",showterms([[C,1]]),", is ",(C>0?"positive":"negative"),", so ",showterms([[1,'p']])," and ",    showterms([[1,'q']])," will have ",(C>0?"the same":"opposite")," signs.<br>",    (C>0?"Since the sign of the "+showterms([[1,v]])+" term is "+(B>0?"positive":"negative")+", "+          showterms([[1,'p']])+" and "+showterms([[1,'q']])+" are both "+(B>0?"positive":"negative")+".<br>":""),    (fps.length>1?"The only combination that gives a sum of ":"So the pair of signed factors that sum to "),    showterms([[B,1]]),", the coefficient of ",showterms([[1,v]]),", is ",showterms([showsign(a),[Math.abs(a),1]]),    " and ",showterms([showsign(b),[Math.abs(b),1]]),":<br>",    showterms([[A,v,2],[B,v],[C,1]," = (",[1,v],[a,1],")(",[1,v],[b,1],")"]),    (K>1? "<br>"+implies+showterms([[K*A,v,2],[K*B,v],[K*C,1]," = ",[K,1],"(",[ka,v],[a,1]," )( ",[kb,v],[b,1],")"]):"")    );    return};    var V=(v=='x'?'y':'x'),P='p',Q='q',R='r',S='s';if((P+Q+R+S).indexOf(v)!=-1){P='a';Q='b';R='c';S='d'}; document.writeln("To factorize ",showterms([[A,v,2],[B,v],[C,1]]),"<br>",    "<blockquote>Our reference formula is ",showterms(["(",[1,P+v],[1,Q]," )( ",[1,R+v],[1,S]," ) = ",        [1,P+R+v,2],"+ (",[1,P+S],[1,Q+R],") ",[1,v],[1,Q+S]]),"<br>",        "Method:  find two factors of ",showterms(["coefficient of ",[1,v,2],"&times;",["constant term",1]," = ",       [1,P+Q+R+S]," = ",[1,P+S]," &times;",[1,Q+R]]),"<br> that sum to the ",showterms([["coefficient of ",v]," = ",[1,P+S],[1,Q+R]]),"<br>",     "</blockquote>",     "First find the <i>product</i> of <span class=ul>the ",showterms([[1,v,2]]),     " coefficient: ",showterms([[A,1]]),"</span>  and  <span class=ul>the constant term: ",showterms([[C,1]]),     "</span> which is ",showterms([[negb(A),1],times,[negb(C),1]," = ",[A*C,1]]),     "<br>Now find the pairs of factors of this number:<blockquote>",     showfactorpairs(A*C),"</blockquote>",     (A*C<0     ?"but the product we want is "+showterms([[A*C,1]])+" so one of each factor pair must be negative, the other positive."     :" and also the same pairs with both factors being negative."     ),     "<br>Of these choose the (signed) factor pair that <i>sums</i> to ",     "<span class=ul> the coefficient of ",showterms([[1,v]]),": ",showterms([[B,1]]),"</span> ...<blockquote>",     "The pair to choose is ",showterms([[ka*b,1],", ",[a*kb,1]])," because ",     showterms([[A*C,1]," = ",[negb(ka*b),1],"&times;",[negb(a*kb),1]])," and ",showterms([[ka*b,1],[a*kb,1]," = ",[B,1]]),     ".</blockquote> We can therefore rewrite our quadratic substituting ",showterms([[ka*b,v],[a*kb,v]])," for ",showterms([[B,v]]),":<br>",     showterms([[A,v,2],[B,v],[C,1]," = ",[A,v,2],[ka*b,v],[a*kb,v],[C,1]]),     " which enables us to factor the first two and last two terms:<br>",     showterms([[A,v,2],[B,v],[C,1]," = ",[ka,v],"(",[kb,v],[b,1],")"+(a>0?" + ":""),[a,1],"(",[kb,v],[b,1],")"]),     " and the bracketed term now factors out too:<br>",     showterms([[A,v,2],[B,v],[C,1]," = (",[ka,v],[a,1],")(",[kb,v],[b,1],")"]),     (K>1?"<br>"+implies+showterms([[K*A,v,2],[K*B,v],[K*C,1]," = ",[K,1],"(",[ka,v],[a,1]," )( ",[kb,v],[b,1],")"]):"")    ); };        function SOLNfomula(A,B,C,v,ka,a,kb,b){document.writeln("The Formula</b> that gives the two roots of a quadratic is:<br>",     oneline("If ",showterms([["a ",v,2],["b ",v],["c",1]," = 0"])," then ",showterms([[1,v]," = "]),        Frac("<span class=poly>&ndash;"+Var('b')+" &plusmn; &radic;("+showterms([[1,"b",2 ],[-4,"ac"]],false)+")</span>",             showterms([[2,'a']],"false")+"</span>")),     " and these 2 values of ",showterms([[1,v]])," we will call <span class=poly>root1</span> and <span class=poly>root2</span>.<br>",     "The factors of ",showterms([["a ",v+"<sup>2</sup>"],["b ",v],["c",1]]),         " will therefore be <span class=poly>( ",v," &ndash; root1 )</span> and <span class=poly>( ",v," &ndash; root2 )</span><p>",      "For this question, we need the roots of ",showterms([[A,v,2],[B,v],[C,1]])," so ",      "<span class=poly>a = ",A,", b = ",B,"</span> and <span class=poly>c = ",C,"</span><br>",      "The formula gives the roots <span class=poly>",v," = "+new RAT(-a,ka).toString(),"</span> and <span class=poly>",v,             " = "+new RAT(-b,kb).toString()+"</span><br>",      "So the factors are <span class=poly>(",showterms([[ka,v],[a,1]],false)," )</span> and <span class=poly>( ",           showterms([[kb,v],[b,1]],false)," )</span>") };      