Ok.
You have a difficult problem to solve, and you solve it then start to patent it.
Six months later, I have the same or similar problem to solve and solve it in a similar way. I have no knowledge of your solution and there's no way for me to find out about it (patents are kept secret in the US until they are granted).
12 months after I've written, published and used my solution, I'm suddenly in the position of infringing your patent. Along you come and ask for royalties. The software industry moves so fast that there's no way to avoid this problem - after all, all you need to do is sit down and think a bit. No investment required except a little time.
The only way that I can defend against this is to patent my own solutions and hope that you infringe on one or more of them yourself - a cold war of mutually assured destruction by software patents. If you don't then I have no choice but to pay you off ... something that John Carmack once referred to as effectively being mugged by a patent.
I have no problem with you copyrighting your algorithm, and I have no problem with you keeping it as a trade secret, but I do have a problem with patents limiting my independent methods of solving a problem by saying that I can't think of the same solution as you did. That's the reason that Mathematical formulae are also not patentable.
Now it's your turn. Patents are intended to encourage innovation for the benefit of society (you are awarded a limited monopoly in turn for making your invention public, purely so that when you pass on, your secret isn't lost with you). Show me the evidence that patents in software actually do this. The European parliament had the examples of all the software patents within both the Japanese and US systems, and
still didn't implement them in Europe. The calls within the US to remove patents from software get ever louder. If software patents are such a good idea, why is that?