How does one construct general forms that certain variables in an equation must take? Srinivasa Ramanujan was one of the greatest mathematicians of all time $-$ the greatest in the $20^\text{th}$ century. One day, he stumbled across the equation $$\rm3^3+4^3+5^3=6^3\tag1$$ and only days later, he was able to discover the general form that this equation takes place in: $$\big(3a^2+5ab-5b^2\big)^3+\big(4a^2-4ab+6b^2\big)^3+\big(5a^2-5ab-3b^2\big)^3=\big(6a^2-4ab+4b^2\big)^3\tag2$$ for all integers $a$ and $b$, with Eq. $(1)$ being created when $a=1$ and $b=0$. Now I know that barely anyone knows how Ramanujan obtained his results $-$ but he did, and they are brilliant.
My question is, are there any useful techniques or methods that I can learn so I may be able to pull something like finding Eq. $(2)$? What algorithms are there to discover some general equations? I was not convinced when I looked at it, so I evaluated, and the left hand side weighs the same as the right hand side.
But are there any such algorithms at all? For example, $a^2-b^2$ looks like some regular expression, but just add in the clever substitution $ab - ab$ and then this happens: $$\begin{align}a^2-b^2&=a^2+ab-ab-b^2\\ &= a(a+b)-b(a+b) \\ &= (a+b)(a-b).\end{align}$$ So now when anybody says what $915^2-914^2$ is, I can say it right away: it is $915+914=1829$.
How does anybody know to put such clever substitutions? When I was first given the problem to factorise $a^2-b^2$, I just did this: $$\begin{align}(a-b)^2&=a^2-2ab+b^2 \\ \Leftrightarrow a^2-b^2&=(a-b)^2 + 2ab - 2b^2 \\ &= (a-b)^2 + 2b(a-b) \\ &= (a-b)(a-b+2b) \\ &= (a+b)(a-b).\end{align}$$ I got the same result, but it was not as efficient as the first method.
I want to become a great mathematician one day; I don't want to just tell my friends that I do math for a living $-$ I want to prove something, or make a theorem, especially if it involves prime numbers. What are some helpful algebraic formulae that I should know when it comes to constructing generalised equations and such? I know the quadratic and cubic formula... but that is it.

For example: $$x^2 + 3y^2 = 7z^2.$$ These are the forms that $x$, $y$ and $z$ must take for integers $p$ and $s$: $$\begin{align}x&=2\big(3p^2+3ps-s^2\big) \\ y&=-3p^2+4ps+s^2 \\ z&=3p^2+s^2.\end{align}$$
Go here to find some similar general equations (and let's not forget about pythagorean triples!).
How does one find such equations for $x$, $y$ and $z$? Is it just trial and error?

Thank you in advance, and I apologise if the post is too long and/or too broad.
 A: The great thing about being a number theorist in the 21st century is that we have the potential to use computers to comb through millions of numbers and try to find patterns. This is the idea behind experimental mathematics. 

My number theory experience is only a little beyond pre-algebra. Let's experiment computationally with your equation $x^2 + 3y^2 = 7z^2$.
We try some values of $(x,y,z)$ in a computer and a couple milliseconds later we get many solutions (only positive $x,y,z$ are shown):
$$(10,9,7), (10,5,5), (10,2,4), (8,4,4), (6,3,3), (5,1,2), (4,2,2), (3,9,6), \dots$$
Let's guess there's a parameterization of the form 
$$x = ar^2 + brs + cs^2 \\ y = dr^2 + ers + fs^2 \\ z = gr^2 + hrs + is^2$$
If we let $r=0, s=1$ we see $c^2 + 3f^2 = 7i^2$, so $(c,f,i)$ must be a solution we found. Similarly letting $r=1,s=0$ we know $(a,d,g)$ must be a solution we found. Letting $r=1,s=1$ we see $(a+b+c,d+e+f,g+h+i)$ must be a solution we found, and so on. Then we can try lots of different values of $a$ through $i$ with all our solutions in a hash table for constant time lookup. This method is very inefficient but on a large enough scale it might work. 
We can also try turning our problem into an optimization problem: attempt assigning $a$ through $i$ such that we get close solutions. We have a set of candidates for each variable, and we randomly perturb them in the hopes of getting a better solution in the style of basin hopping or simulated annealing.

Other methods are listed in solving system of polynomial equations which is way beyond my knowledge. These papers may be more insightful than the Wikipedia article:
Sturmfels, B., 2002. Solving Systems of Polynomial Equations. American Mathematical Society, Providence
D. Lazard: Thirty years of Polynomial System Solving, and now?, J. Symbolic Computation, 44, 222–231 (2009) for a much shorter introduction.
A: (OP) enquiry about derivation of the Ramanujan Identity. Derivation is given below:
Assume that below equation is true:
$\big(3p^2+mp-5\big)^3+\big(4p^2-np+6\big)^3+\big(5p^2-mp-3\big)^3=\big(6p^2-np+4\big)^3\tag1$
Let: 
$u=3p^2+mp-5$
$v=4p^2-np+6$
$w=5p^2-5p-3$
$z=6p^2-np+4$
We have identity:
$(a+b+c)^3=a^3+b^3+c^3+3(a+b)(b+c)(c+a)$
Hence $(u^3+v^3+w^3-z^3)$=
$(3p+m)(mp-5)(3p^2-5)-(5p-m)(mp+3)(5p^2-3)-2(3p^2+2)(4-np)(6p-n)+2(2p^2+3)(6-np)(4p-n)=0$
or
$4p^4(5n-4m)+2p^3(4m^2-n^2-84)-2p(4m^2-n^2-84)-4(5n-4m)=0$ -----(2)
Equation  (2) has solution at $(m,n)=(5,4)$
Hence after substituting in equation (1) $(m,n,p)=(5,4,(a/b))$ we get:
$\big(3a^2+5ab-5b^2\big)^3+\big(4a^2-4ab+6b^2\big)^3+\big(5a^2-5ab-3b^2\big)^3=\big(6a^2-4ab+4b^2\big)^3$
