This question already has an answer here:

I could use some help with this. This is my first time using mathematica and im trying to get use to the coding. Find an equation of the tangent to the curve and graph the curve and tangents. x=sin(t) y=t+t^2 Point (0,0)

Where is a good place to start? how would i go about coding this?



marked as duplicate by Sjoerd C. de Vries, Daniel Lichtblau, RunnyKine, eldo, Öskå Oct 6 '14 at 19:20

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ Hint: D[f(x), x] computes the derivative of f with respect to x. $\endgroup$ – Igor Rivin Oct 6 '14 at 17:32
  • 2
    $\begingroup$ A good place to start would be to use the word 'tangent' in the search box. At least three questions deal with this. $\endgroup$ – Sjoerd C. de Vries Oct 6 '14 at 17:34
  • $\begingroup$ @SjoerdC.deVries From JM in his answer there "This is based on the fact that the tangent line is the unique Hermite interpolating polynomial of degree 1." :D $\endgroup$ – Dr. belisarius Oct 6 '14 at 17:38
  • 1
    $\begingroup$ @belisarius I agree, probably not the easiest treatment. How about this one? $\endgroup$ – Sjoerd C. de Vries Oct 6 '14 at 17:41
  • $\begingroup$ See also this How to make a Line with no end? $\endgroup$ – Artes Oct 6 '14 at 17:44

It is always good to start with a working technology, what you have already learned in Calculus helps you. Embark familiar with the basics of Mathematica and the search functions on this page.


Write down in Mathematica notation what you have:

f[t_] := Sin[t]

g[t_] := t + t^2

p1 = {0, 0};

Make it a plot:

Plot[{f[t], g[t]}, {t, -\[Pi], \[Pi]}
 , PlotRange -> {{-\[Pi]/2, \[Pi]/2}, {-1.5, 1.5}}
 , Frame -> True
 , Epilog -> {Red, PointSize[0.02], Point[p1]}]

enter image description here

The tangent line goes through the point P (0, 0), calculate the slope and plot it:

expr = (g[t] - 0)/(t - 0)

m = Limit[expr, t -> 0]

 , {t, -\[Pi]/2, \[Pi]/2}
 , PlotStyle -> Darker[Green]
 , Frame -> True]

enter image description here

The tangent as a function:

tangent[t_] := m (t - 0) + 0

And now all together:

  , g[t]
  , tangent[t]}
 , {t, -\[Pi], \[Pi]}
 , PlotRange -> {{-\[Pi], \[Pi]}, {-1.5, 1.5}}
 , Frame -> True
 , Epilog -> {Red, PointSize[0.02], Point[p1]}
 , PlotLegends -> "Expressions"]

enter image description here

I hope that gives you a good start - have fun!


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