I am looking for the best way to approximate $\exp(x)$ on a finite domain $[0,M]$ with a piecewise-linear function. My initial approach is to take $K$ evenly-spaced segments from $0$ to $M$. For each segment $[s\_k, s\_{k+1}]$, I add the line from point $(s\_k, \exp(s\_k))$ to point $(s\_{k+1}, \exp(s\_{k+1}))$.


But what I've noticed is that the approximation gets worse for segments closer to $M$. Intuitively, this suggests that the segments need to start large and then reduce in size as we approach $M$. But how would one approach this formally? I am also interested in heuristics, or approximations.



Approximating exp(x) with a piecewise-linear function accurately
For $b$ not much larger than $a$, the maximum difference between $e^x$ and the line from $(a,e^a)$ to $(b,e^b)$, for $x\in[a,b]$, is approximately $\frac 18 (b-a)^2 e^a$.


So you should choose your points so that $(b-a)^2 e^a$ is approximately constant for each interval. After selecting the first interval, use this rule to select further intervals. They will get gradually smaller.


