# How to use MMA to solve this numerical analysis problem?

The equidistant node function table of the function $$f(x)=e^{x}$$ is given on $$-4 leqslant x leqslant 4 quad$$.

In order to find the value of $$e^{x}$$ by linear interpolation and make the truncation error less than $$10 ^ {- 6}$$, what is the maximum step size of the function table used?

The source of this problem(中国科学院武汉岩石力学研究所2000年数值分析科目入学考试):

After class exercises of numerical analysis

``````piecewiseLinear(
points : {{_, _} ..} /; ¬ OrderedQ(points((All, 1)))) :=
(*保证输入点按横坐标顺序排列*)
piecewiseLinear(points // SortBy(First))
piecewiseLinear(points : {{_, _} ..})(x_) :=
With({px = points((All, 1)), pfx = points((All, 2)),
n = Length@points},
Do(
If(px((i)) <= x <= px((i + 1)),
Throw((pfx((i + 1)) - pfx((i)))/(
px((i + 1)) - px((i))) (x - px((i))) + pfx((i)))
),
{i, n - 1});
Undefined
) // Catch

Block({φ = piecewiseLinear(Table({x, E^x}, {x, -4, 4, 1}))},
Plot({φ(x), E^x}, {x, -4, 4}, PlotTheme -> "Monochrome",
PlotLegends -> {Defer(φ(x)), Defer(f(x))})
)
``````