0
$\begingroup$

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

$\endgroup$
  • $\begingroup$ Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. $\endgroup$ – bbgodfrey Feb 13 '15 at 23:09
  • $\begingroup$ Do you mean like Plot[{Sin[x], x}, {x, -\[Pi], \[Pi]}]? Or are you looking for an automated way to construct such plots for arbitrary $f$? $\endgroup$ – DumpsterDoofus Feb 13 '15 at 23:17
  • $\begingroup$ For an automated way, you could do plotTangent[f_, x0_] := Plot[Evaluate[{f[x], Normal@Series[f[x], {x, x0, 1}]}], {x, x0 - 4, x0 + 4}], and then call plotTangent[f, 0], which produces the desired graph. $\endgroup$ – DumpsterDoofus Feb 13 '15 at 23:20
1
$\begingroup$

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"}}]
$\endgroup$
0
$\begingroup$

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) &}}]
$\endgroup$
  • $\begingroup$ tangent appears to be undefined. $\endgroup$ – bbgodfrey Feb 14 '15 at 0:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.