# Is it possible to rearrange this term in the form I need?

If I have a term in the following form:

$$2\frac{(ak + bk - ab)}{(a^2+b^2+k^2)}$$

is it possible to rearrange it into a term like this?

$$2*f(a, k, b) + f(a, k, b)^2$$

f can by any type of function with a, k and b.

Yes it is possible.

Define $c = 2 \frac{ ak+bk-ab }{a^2+b^2+k^2}$. You're looking for a function $f$ that satisfies the equation:

$f^2 + 2f = c$

Then: just solve the quadratic equation $f^2 + 2 f - c = 0$. There are two solutions to this quadratic equation:

$f=-\sqrt{c+1}-1 = -\sqrt{2 \frac{ ak+bk-ab }{a^2+b^2+k^2}+1}-1$

and

$f=\sqrt{c+1}+1=\sqrt{2 \frac{ ak+bk-ab }{a^2+b^2+k^2}+1}+1$

So there are two ways in which you can do this. Note that sometimes this function will be complex valued (depending on your values of $a$, $b$ and $k$).