Question: I am unsure how to graph the interpolated graph with the regular graph on the interval $[1,4]$. Not even the Show
line works about even if I'm pretty sure it's written correctly.
Clear["Global`*"]
f[x_] = x e^-x - 1
f[1];
f[2];
f[3];
f[4];
XY = {{1, -1 + 1/e}, {2, -1 + 2/e^2}, {3, -1 + 3/e^3}, {4, -1 + 4/
e^4}};
p4[x_] = Fit[XY, {1, x, x^2, x^3, x^4}, x]
dots = ListPlot[XY, PlotStyle -> {PointSize[0.02]}];
gr5 = Plot[{f[x], p4[x]}, {x, -0.6, 2.1}, PlotStyle -> {Red, Green}];
Show[gr5, dots, PlotRange -> {{0, 1.2}, {0.0, 1.15}}]