Reversing level to xp formula I have written a function to convert a given "level" from a game into the amount of XP required to reach that level. Level $0\to 1$ costs $100$ XP, from then on each level costs $25$ more than the previous

*

*$0\to 1$ = $100$ XP

*$0\to 2$ = $225$ XP

*$0\to 3$ = $375$ XP

The formula I have to convert level to XP is as follows;
$$\text{XP}=(100 \times \text{level}) + \frac{25 \times (\text{level}^2- \text{level})}{2}$$
I need to calculate the reverse of this, converting XP into the user's current level. How can I convert this into a formula for the level?
 A: Let us replace $level$ with $v$, and $xp$ with $p$. Then your formula becomes
$$p=(100\cdot v)+(25\cdot (((v-1)\cdot v)/2))$$
This is a quadratic in $v$, as can be seen by simplifying the right hand side.
$$p=100v+\frac{25}{2}(v^2-v)$$
$$p=\frac{25}{2}v^2-\frac{175}{2}v$$
If we image $p$ as a constant for a moment, we can think of this as a typical quadratic polynomial in $v$, which has a well-known solution.
$$\frac{25}{2}v^2-\frac{175}{2}v-p=0$$
Let $a=\frac{25}{2}$, $b=-\frac{175}{2}$, and $c=-p$, then the previous equation has solutions:
$$v=\frac{-b\pm\sqrt{b^2-4ac}}{2a}$$
For your purposes, one of these solution won't make sense, the one that will is the one where the $\pm$ is taken to be $+$. If you substitute the give values for $a$, $b$, and $c$ the resulting equation will only contain numbers (some simplification is possible) and $p$ (the input variable for the function you desire). This will work as long as $p>0$ (which from context appears to always be the case).
A: You have the correct equation for XP, which you  can also write as
$$XP=12.5l^2+87.5l$$
where I've replaced level with $l$. To solve for the level obtained with a particular amount of experience, simply rearrange to get $$0=12.5l^2+87.5l-XP$$
From here, you can use the quadratic formula to solve for the level.
$$l=\frac{-87.5\pm\sqrt{87.5^2+(50\cdot XP)}}{25}$$
In your case, since you know $XP$ will be positive, the second term  in the numerator will always be positive and $\geq$ the first term in magnitude. Thus, you can ignore the $\pm$ and just use $+$ for your formula.
