An "algorithm" for calculating $ax+b$ would take the steps
- Calculate $a$ times $x$
- Calculate $b$ plus the result of previous line.
But if the values of $a$ and $b$ are known, can we create a more efficient algorithm for the task?
Of course, when $a = 1$, I can optimize the previous algorithm by simply skipping the first step, and when $b = 0$, an optimization would be to skip step 2. But is there always an optimization that I can do?
More formally
Let $originalAlgorithm$ be the two-step algorithm above. What I want is a meta-algorithm, $M$ that $$ M(a,b) = optimizedAlgorithm $$ and, of course, $$ optimizedAlgorithm(x) = originalAlgorithm(x) = ax+b $$ but $optimizedAlgorithm$ is more time-efficient than $originalAlgorithm$.