# Steps to get Inverse of Pentagonal

I have solved http://projecteuler.net/problem=44 by getting the inverse equation from Wikipedia http://en.wikipedia.org/wiki/Pentagonal_number:

Pentagonal: $f(n) = \frac{n(3n - 1)}{2}$

Inverse Pentagonal: $n = \frac{\sqrt{24f(n) + 1}+1}{6}$

am interested in the steps from Pentagonal equation (quadratic?) to the Inverse.

I note that it is similar to What is the inverse of $f(n)=\frac{n^2+n}{2}$? and I've tried the same strategy:

$f(n) = \frac{n(3n - 1)}{2}$

*6 + 1 on each side

$6f(n) + 1 = 9n^2 -3n + 1$

but this isn't correct because I want:

$6f(n) + 1 = 9n^2 -6n + 1$

to give:

$(3n-1)^2$ on the right hand side

-
You have multiplied by 6, try to multiply by 24 –  Aang Jun 29 '12 at 17:33

To imitate the procedure used in the solution of the other problem, starting from $$2f(n)=3n^2-n,$$ multiply both sides by $12$. We get $$24f(n)=36n^2-12n.$$ Note that $36n^2-12n=(6n-1)^2-1$. The rest is easy. We get $(6n-1)^2=24f(n)+1$, then $6n-1=\sqrt{24f(n)+1}$, then $6n=\sqrt{24f(n)+1}+1$.
Another way to solve the same problem is to write our equation as $$3n^2-n-2f(n)=0,$$ and use the Quadratic Formula.
Remark: Look at the quadratic equation $ax^2+bx+c=0$, where $a\ne 0$. Multiply both sides by $4a$. We get the equivalent equation $$4a^2x^2+4abx+4ac=0.$$ Note that $4a^2x^2+4abx=(2ax+b)^2-b^2.$ So quickly we arrive at the equation $$(2ax+b)^2=b^2-4ac.$$ From this we conclude that $$2ax+b=\pm\sqrt{b^2-4ac},$$ and then straightforward algebra yields $$x=\frac{-b\pm\sqrt{b^2-4ac}}{2a},$$ the important Quadratic Formula.
From $f(n)=n(3n-1)/2 \implies 3n^2-n=2f(n)\implies 3n^2-n-2f(n)=0$.This is a quadratic equation which gives $n=\frac{1+\sqrt{1+24f(n)}}{6}$.