ClearAll@f;
f[x_] := 2 Sin[x] - x - Log[x + 1]
Manipulate[Refresh[functions = Table[D[f[x], {x, n}], {n, 0, nMax, 1}];
orders =
Table[D[f[x], {x, n}] // Inactivate // TraditionalForm //
ToString, {n, 0, nMax, 1}];
labels =
MapThread[#1 <> " = " <> ToString[#2, TraditionalForm] &, {orders,
functions}];];
Plot[functions, {x, 0, 3}, PlotLabels -> labels, ImageSize -> 700,
AspectRatio -> 1,
PlotLabel -> Row[{"f(x) = ", f[x]}]], {{nMax, 1, "Order"}, 1, 10, 1,
PopupMenu}]
The above code ran with errors. How to modify it? I want to modify the code to make it universal. You can input any function and draw the corresponding function image and derivative image.