Hi just wondering how to graph the tangent as well as this curve on the same graph : f(x)= Sin[x] at x=0 where the gradient of the tangent is 1
Asked
Active
Viewed 162 times
2 Answers
1
Here's some fun:
Manipulate[
Plot[Evaluate[{f[x], Normal@Series[f[x], {x, x0, 1}]}],
{x, -5, 5},
PlotRange -> {{-5, 5}, {-2, 2}},
Epilog -> {Red, PointSize[0.02], Point[{x0, f[x0]}]}],
{{x0, 0}, -4, 4},
{f, {Sin, Cos, Tan, 1/4 #^2 & -> "x^2/4"}}]
David G. Stork
- 41,180
- 3
- 34
- 96
0
Another approach using derivative.
tangent[f_,x0_]:=(f^\[Prime])[x0] #1+First[b/. NSolve[f[x0]==(f^\[Prime])[x0] x0+b,b]]&;
Manipulate[Plot[Evaluate[{f[x], tangent[f, x0][x]}], {x, -5, 5},
PlotRange -> {{-5, 5}, {-2, 2}},
Epilog -> {Red, PointSize[0.02], Point[{x0, f[x0]}]}], {x0, -5,
5}, {f, {Sin, Cos,(.2 #^2 - 1.5) &}}]
Zviovich
- 9,308
- 1
- 30
- 52
Plot[{Sin[x], x}, {x, -\[Pi], \[Pi]}]? Or are you looking for an automated way to construct such plots for arbitrary $f$? – DumpsterDoofus Feb 13 '15 at 23:17plotTangent[f_, x0_] := Plot[Evaluate[{f[x], Normal@Series[f[x], {x, x0, 1}]}], {x, x0 - 4, x0 + 4}], and then callplotTangent[f, 0], which produces the desired graph. – DumpsterDoofus Feb 13 '15 at 23:20