I apologise for the fairly messy handwriting (I'm not a particularly neat or fancy writer), and I decided to go Pen and Paper since it looks much neater than writing it up on the computer.
I just used basic Algebra (Year 7 level really ;I) and rearragned everything to Base =
Also, to speed things up, I skipped some steps (as in I didn't show how I moved each and every single one of the terms around.). If you can't follow it, I'll scan over a copy with every step.
![enter image description here](https://cdn.bulbagarden.net/upload/c/c1/OtherStatCalcGen34.png)
Original Formula for calculating the actual stat for non-HP.
![enter image description here](https://i.imgur.com/BN6f10A.jpg?1)
![enter image description here](https://cdn.bulbagarden.net/upload/8/80/HPStatCalcGen34.png)
Formula for calculating the actual stat for HP.
![enter image description here](https://i.imgur.com/1agMV7W.jpg?1)