# Completing the square of a very long expression

I have completed a square many times, but for expressions of two variables, this one however has more. So a couple of questions come to mind, how would I even know that the following can be made into square (relatively efficiently, i.e I do not have to deduct many terms after completing a square) and then is there a method for completing a square for expressions of more than two variables?

Here is the expression:

$$x^2 + \log^2S + r^2t^2 + \frac{1}{4}\sigma^4t^2-2x\log S-2xrt-x\sigma^2t+2rt\log S -\sigma^2 t \log S + r\sigma^2 t^2$$

• Trial And Error! :) The brutal way is to subtract the expression from the square you think it might be! :) – H. R. Dec 25 '15 at 14:34

## 3 Answers

The square should have the form $(\Bigl(x\pm\log S\pm rt\pm\frac12\sigma^2t\Bigr)^2\!$. The double products should have the forms $$\pm 2x\log S,\quad \pm 2xrt,\quad\pm x\sigma^2t,\quad \pm 2rt\log S,\quad \pm\sigma^2t\log S, \quad\pm r\sigma^2t^2.$$ By trial and errors, we see $\log S, \frac12\sigma^2t$ and $rt$ must have a $-$ sign, except instead of the double product $+2\log S\cdot\frac12\sigma^2t$, we have $-\sigma^2t\log S$, hence:

$$\Bigl(x-\log S-rt-\frac12\sigma^2t\Bigr)^2-2\sigma^2t\log S.$$

• I know the answer. I am asking for a method – i squared - Keep it Real Dec 25 '15 at 12:41
• I believe your first term should be $2x\log S$ – i squared - Keep it Real Dec 25 '15 at 16:51
• You're right. Thanks for pointing the typo! – Bernard Dec 25 '15 at 20:08

HINT:

$$x^2+\ln^2(S)+r^2t^2+\frac{1}{4}\sigma^4t^2-2x\ln(S)-2xrt-x\sigma^2t+2rt\ln(S) -\sigma^2t\ln(S)+r\sigma^2t^2=$$ $$\ln^2(S)+\frac{1}{4}\left(\sigma^2t+2rt-2x\right)^2-\ln(S)\left(\sigma^2t-2rt+2x\right)$$

Hint multinomial theorem. $(a+b+c+d)^2=a^2+b^2+c^2+d^2+2ab+2cd+2ac+2bc+2ad+2bd$ . You can replace $+$ by $-$ as its simple modification.