How do you know which substitutions to make to cancel out a term? I am doing problem B45 from Ivan Niven's "Maxima and Minima Without Calculus" which says:
"Consider the quadratic polynomial $f(x, y)=ax^2+2bxy+cy^2+dx+cy+k$ , where the coefficients are real constants with $a>0$ and $c>0$ . In case $b \not =0$ , verify that the transformation $x=X-by/a$ produces a quadratic polynomial $f(X-by/a , y)$ with no $Xy$ term." 
The reason why he didn't want an $Xy$ terms is because if there is none then the function is easy to minimize by minimizing the two variables separately. My question is, what steps led to the substitution $x=X-by/a$? How did he know that making this substitution would lead you to having no $Xy$ term? How can this method be extended more generally to other functions? Thanks.
 A: I would say that he decided to make a linear substitution of the form $x=X+\lambda y$ (or equivalently $X = x-\lambda y$) and then figured out what the $Xy$ term would be after the substitution. Careful choice of $\lambda$ (in this case $\lambda=-b/a$) made that coefficient $0$. 
It's not trial and error at the level of what substitution to make, but it is, to some extent, trial and error at the level of what type of substitution to make.
A: The technique is called (for quadratics) completing the square. You have done it often, though probably mostly with explicit numbers. We can write the quadratic part as 
$$a\left(x^2+2\frac{b}{a}xy +\frac{c}{a}y^2\right).$$
Rewrite this as 
$$\frac{1}{a}\left(\left(x+\frac{b}{a}y\right)^2-\frac{b^2}{a^2}y^2+\frac{c}{a}y^2\right).$$
The substitution $X=x+\frac{b}{a}y$ is now natural.
Remark: Variants of the completing the square idea show up all over. To get away from squares, consider the cubic equation $x^3+bx^2+cx+d=0$. A step in "Cardano's" solution of the cubic was to make the equivalent of the substitution $x=t-\frac{b}{3}$.
When we do the substitution, we end up with a cubic equation of the shape $t^3+et+f=0$, with no term in $t^2$.
