How to optimize the tangent equation of a curve at a certain point as follows:
How to draw the images of the original function, derivative function and tangent equation into the same coordinate system?
ClearAll["`*"]
f[x_] := Log[1 + x] + x E^-x
g[x_] := D[f[x], x] // FullSimplify
point = {0, f[0]}
point[[1]]
k = D[f[x], x] /. x -> point[[1]]
y - point[[2]] == k (x - point[[1]])
Plot[{f[x], g[x],%}, {x, -1, 2}]
Update 1:
f[x_] = Log[1 + x] + x E^-x;
point = {0, f[0]}
k = D[f[x], x] /. x -> point[[1]]
y - point[[2]] == k (x - point[[1]])
Plot[{f[x], f'[x]}, {x, -1, 4},
Epilog -> {Red,
InfiniteLine[{x, f[x]}, D[{x, f[x]}, x]] /. x -> point[[1]]},
PlotLabels -> "Expressions", AspectRatio -> 1]
Update 2:
Clear[f, expr];
f[x_] = Log[1 + x] + x E^-x;
point = {2, f[2]}
k = D[f[x], x] /. x -> point[[1]]
y - point[[2]] == k (x - point[[1]])
expr = {f[x], f'[x], f[x0] + f'[x0] (x - x0) /. x0 -> point[[1]]} //
Evaluate;
Plot[expr, {x, -1, 7}, AspectRatio -> 1,
PlotLabels -> Thread[{"f(x)", "f'(x)", "y"} == expr],
ImageSize -> Full]
Update 3
Clear[f, expr];
f[x_] = Log[1 + x] + x E^-x; point = {0, f[0]}
k = D[f[x], x] /. x -> point[[1]]
y - point[[2]] == k (x - point[[1]])
expr = {f[x], f'[x], f[x0] + f'[x0] (x - x0) /. x0 -> point[[1]]} //
Evaluate;
Plot[expr, {x, -1, 7},
Epilog -> {Red, PointSize[0.02], Point[point],
Text[point, point, {-2, 1}]}, AspectRatio -> 1,
PlotLabels -> Thread[{"f(x)", "f'(x)", "y"} == expr],
ImageSize -> 500]
Update 4:
Clear[f, expr];
f[x_] = Log[x] + E^(x - 1);
point = {1, f[1]}
k = D[f[x], x] /. x -> point[[1]]
y - point[[2]] == k (x - point[[1]])
expr = {f[x], f'[x],
f[x0] + f'[x0] (x - x0) /. x0 -> point[[1]] // FullSimplify} //
Evaluate; Plot[expr, {x, -1, 7},
Epilog -> {Red, PointSize[0.02], Point[point],
Text[point, point, {-2, 1}]}, AspectRatio -> 1,
PlotLabels -> Thread[{"f(x)", "f'(x)", "y"} == expr],
ImageSize -> 500]
Normal[Series[f[x], {x, x0, 1}]]
? $\endgroup$f[x],f'[x]
need one argumentx
but tangent equation needs two argumentsx,x0
! That's why it's necessary to choosex0
before plotting $\endgroup$