.variable { font-style:italic; font-size: 125%; } .exponent { font-size: 75%; vertical-align: super; } .equation { background: #ccffcc; padding: 10px; box-shadow: 10px 10px 5px #888888; display: inline-block; } .bracket:before { content:”(“; } .bracket:after { content:”)”; } .wrong { color: #ff0000; } .right { color: #00ff00; } // Create HTML to display polynomial // Assumes: 1) All coefficients in array // 2) Lowest power of x first i.e. zero // 3) No leading-zero coefficients function showPolynomial(c,anchorID){ poly=’‘ for(i=c.length-1;i>=0;i–){ // Suppress 1 multiplier and last coefficient=0 cases if((c[i]==1) && (i>0)){ // Not c[0] and is 1 multiplier coeff=”” }else{ if((c[i]==0) && (i==0)){ // c[0] and 0 is multiplier coeff=”” }else{ // Normal case coeff=c[i] } } // Print term if non-zero coefficient if(c[i]!=”0″){ switch(i){ case 0: term=’‘+coeff+’‘ break case 1: term=’‘+coeff+’x‘ break default: term=’‘+coeff+’x‘+i+’‘ } // Figure out if we want a + before term if((c[i]<0)||(i==c.length-1)){ plusTerm="" }else{ plusTerm='+‘ } poly+=plusTerm+term } } poly=poly+’‘ anchor=document.getElementById(anchorID) anchor.innerHTML=poly } function multiplyPoly(p1,p2){ order=(p1.length-1)+(p2.length-1) var result=Array() for(p=0;p<=order;p++) { result[p]=0 } for(i1=0;i1<p1.length;i1++){ for(i2=0;i2<p2.length;i2++){ result[i1+i2]+=p1[i1]*p2[i2] } } return result } function polysEqual(p1,p2){ // Polynomials need to be of the same order if(p1.length!=p2.length) return false for(i=0;i-1){ poly[0]=parseInt(factorString.substring(plusPos+1)) return poly } // check for mx-n case minusPos=factorString.indexOf(“-“) if(minusPos>-1){ poly[0]=-parseInt(factorString.substring(minusPos+1)) return poly } // check for mx case if (factorString.substring(xpos+2)==””){ poly[0]=0 return poly } // Broken case return null } function checkIt(){ // Check first factor user might’ve typed in f1=parseFactor(“f1”) if(f1==null){ alert(“Type in the first factor – such as 2x+1 or 3x or x-1.”) } // Check second factor user might’ve typed in f2=parseFactor(“f2”) if(f2==null){ alert(“Type in the second factor – such as 2x+1 or 3x or x-1.”) } // If both factors are non-null proceed if((f1!=null) && (f2!=null)){ guessMultiplied=multiplyPoly(f1,f2) showPolynomial(guessMultiplied,”product”) yesno=document.getElementById(“yesno”) if(polysEqual(p12,guessMultiplied)){ yesno.innerHTML=”correct!” yesno.setAttribute(“class”,”right”) }else{ yesno.innerHTML=”wrong.” yesno.setAttribute(“class”,”wrong”) } document.getElementById(“prodDiv”).style.display=”block” } } Factorising Polynomials

Factorising Polynomials

Factorising polynomials is a basic but satisfying exercise in algebra. Try it here, with some random machine-generated examples.

Factorising is the process of turning a polynomial such as:


Into simpler factors. In this case they would be x+1 and x+2. If you multiply the two factors together you get the original polynomial.

Notice how the 3 in the polynomial is the sum of the 1 and the 2 in the pair of factors. Also how the 2 in the polynomial is the product of the 1 and the 2 in the two factors.

This actually wouldn’t be the case if the coefficient of the x2 term weren’t 1. But it’s not difficult to extend the thinking to cope with these cases.

And now it’s your turn.



Write the two factors in the form 2x+1 or x or x-3.

Factor 1: Factor 2:


Try another

Published by Martin Packer

I'm a mainframe performance guy and have been for the past 35 years. But I play with lots of other technologies as well.

One thought on “Factorise

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: