Suppose I have a function
$$ f(x) = \frac{1}{1+e^x}$$
I can use the function Series[]
to generate a series expansion of $f$ as follows
x0 = 0;
f[x_] = 1/(1 + E^x);
poly[n_] := Normal[Series[f[x], {x, x0, n}]]
poly[3]
which yields
$$ f(x) \approx \frac{1}{2}-\frac{x}{4}+\frac{x^3}{48} $$
Denote by $f_n(x)$ the series truncated after the nth term. I want to generate a plot of the error $|f(x)-f_n(x)|$ versus $|x|$ on log scales. I think I can do this with LogLogPlot[]
as follows
Clear[error]
error[n_] := error[n] = Abs[f[x] - poly[n]]
LogLogPlot[error[3], {x, 10^-10, 1}]
This generates the plot
Which I think looks correct, the error curve is a straight line as expected. But now suppose I change the point of expansion to $x_0 = 1$. Now I want to plot $|f(x)-f_n(x)|$ versus $|x-x_0|$ on log scales. How can I do this?
I have tried
ParametricPlot[{Log[error[2]], Log[Abs[x - x0]]}, {x, x0, x0 + 1}]
but I don't know how I can label the ticks correctly as above.
I think maybe I need to use ListLogLogPlot[]
but I'm not sure how to generate the points for the x range.
What i'm looking to do is plot something similar to
the matlab code to do this is available here