patent != copyright

e=mc^2 is not an algorithm; it's an equation that describes an aspect of the Universe. If you like, it's a Platonic ideal, like any other law of Nature. Of course you can't patent it. But an algorithm is an invented method of doing something; so is a crankshaft. The patent on the crankshaft held up James Watt for twenty years when he was first building steam engines, so he had to design a work-around. It's no different from an algorithm - you have to design an alternative solution if you don't want to license the patent.

Copyright protects the code, not the algorithm. You can get round copyright by recoding (without inspecting the original code), using exactly the same algorithm.