Commercial application is the motivation behind patent law, and logical consistency is not the point, but rather legal consistency. When you patent an algorithm you do not patent the idea any more than you patent thermodynamics when you patent an engine. You patent a particular application of an idea that performs some function or functions. The algorithm -- or thermodynamics -- stay completely free for anyone to know, study and disseminate. In fact, patents are designed to make the knowledge public so that they could be studied and improved upon.
Whether or not it works is a separate question (and I completely agree that software patents do not perform their role), but patenting a device to predict stock prices is not patenting math, just as patenting a drug is not patenting chemistry.
Whether or not it works is a separate question (and I completely agree that software patents do not perform their role), but patenting a device to predict stock prices is not patenting math, just as patenting a drug is not patenting chemistry.