Is there any well-defined method or algorithm to spot any particular pattern in a problem or get to the root of the problem? I would like to start the discussion with this question:

Are proofs or solutions to mathematical problems merely discovered, or can one get the starting point of a proof or a solution using a well-defined method?

I will explain the above question using this example:
Suppose we are given a problem to find the maximum and minimum values of a function. The problem is as follows:
Let $f:\mathbb R\to \mathbb R$, such that $f(x)=a\cos x+b\sin x$.
Now, my book starts with a very illogical statement: Let $a=r\cos\alpha$ and let $b=r \cos\alpha$. How can this statement be true? We chose any $r$ and $\alpha$ such that the above relation for $a$ is true, how can we be sure that the same $r$ multiplied by $\cos\alpha$ give us $b$?
I spent some time on this problem, but couldn't solve it. So I checked the solution somewhere else. I saw a pdf file where, first they drew a graph of the function, and it very clearly was the graph of a cosine. So from the graph, it was observable that this function is of the form $r\cos(x+\alpha)$, since it had a shift too. But, my question is not regarding this particular problem.
Now, like in the above example, we had to do an analysis of the function first, to obtain the relation and from there, we solved the problem. But is there any way we can do all this without this analysis, which sometimes take a lot of time?
Suppose I just give this problem to you:"Find the maximum and minimum values of the function given". How will you know that it is of a particular form, how will you know there is an identity you can apply to it, how will you know there is a special technique for it? 
So finally: Is there any easier way of spotting patterns in a problem, or finding the starting point at least? Or is it just time consuming to find a pattern? How do great mathematicians start when they encounter a new problem?
 A: There's no magic route to mathematics, no algorithm to solve all problems, nothing like that. Hilbert had the dream of such an algorithm. But in fact there is a theorem in logic which dashed Hilbert's dream entirely: There does not exist an algorithm which will accept as input any mathematical sentence and will tell you whether that sentence is true or false. This theorem is a consequence of work of Gödel and of Turing. 
Instead, mathematics is like any other human endeavor: with experience, knowledge, intuition, sweat, and perhaps some tears, you work and you think and you figure out a solution. 
Your example of the zeroes of $f(x) = a \cos(x) + b \sin (x)$ is pertinent. What works for solving this problem is to look at many examples for different values of $a$ and $b$, plot their graphs, ponder the similarities and the differences, try to find a common pattern, and then at some point you hit upon the correct pattern by intuition: "Hey, they all look like what you would get from the cosine graph if you stretched it and shifted it... what formula would produce that? ..."
