To work out the value of p, half the x coefficient EG:6/2=3. Then work out the square EG: (x+3)^2=x^2+6x+9. To work out the value for q, place the constant of the original equation equal to the constant of the square plus q EG: -12=9+q. Rearrange to find q EG: q=-12-9=-21. Thus x^2+6x-12=(x+3)^2-21