In my mathematical programming class, I have to write a function in Mathematica that takes in a function f and a point pt and gives the graph of f and the tangent line of f at pt. This is probably a very simple task, however, I'm having some difficulty. This is what I have:
drawTangent[f_, {x0_, y0_}] :=
Plot[{f, f'[x0]*(x - x0) + y0}, {x, x0 - 10, y0 + 10},
PlotRange -> {y0 - 10, y0 + 10}];
I really think this should work. The problem is that instead of giving the tangent line it gives f[x]=y0. drawTangent[g[x], {-3, 9}], where g[x_]:=x^2, gives g[x^2] and f[x]=9. I think instead of f'[x]=-6 mathematica gives f'[x]=0. I checked and it does this for all other points on the graph. Yet, when I input g'[-3] in a different cell by itself i get -6. Can some explain what I did wrong? Should I put something else instead of f'[x0]?