2

y=C/(x+1) ( I get it from sol=DSolve[y'[x]==-y[x]/(x+1),y[x],x])

How I can plot this "sol" with showing tangents in list of points?

kglr
  • 394,356
  • 18
  • 477
  • 896
  • 1
    Possible duplicate: https://mathematica.stackexchange.com/questions/18090/sliding-a-tangent-line-along-a-curve – Michael E2 Nov 19 '18 at 01:11

1 Answers1

4
ClearAll[t, f]
f[c_][x_] := Evaluate[First[y[x] /. sol /. C[1] -> c]];
t[c_][x_, a_] := f[c][a] + (x - a) (D[f[c][s], s] /. s -> a)
mesh = -1/2;

Show[Plot[Evaluate[Table[f[c][z], {c, {-2, -1, 1, 2}}]], {z, -3, 3}, 
  PlotLegends -> (HoldForm[f][#][x] & /@ {-2, -1, 1, 2}), ImageSize -> Large],
 Plot[Evaluate[Table[ConditionalExpression[t[c][z, mesh], -1/3 + mesh <= z <= 1/3 + mesh],
   {c, {-2, -1, 1, 2}}]], {z, -3, 3}, 
  Mesh -> {{mesh}}, MeshStyle -> Directive[Red, PointSize[Large]], PlotStyle -> Dashed,
  PlotLegends -> (HoldForm[f[#]'][a] & /@ {-2, -1, 1, 2})]]

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896