Guest User

Untitled

a guest
Mar 20th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. f[x_] := 4 - x^2
  2.  
  3. vector[tail : {_, _}, slope_, length_: 1.] :=
  4. Module[{θ = ArcTan[slope]}, {tail, tail + length {Cos[θ], Sin[θ]}}]
  5.  
  6. tangetVectors = N @ Table[vector[{x, f[x]}, f'[x], .5], {x, Subdivide[-2, 2, 8]}]
  7.  
  8. {{{-2., 0.}, {-1.87873, 0.485071}},
  9. {{-1.5, 1.75}, {-1.34189, 2.22434}},
  10. {{-1., 3.}, {-0.776393, 3.44721}},
  11. {{-0.5, 3.75}, {-0.146447, 4.10355}},
  12. {{0., 4.}, {0.5, 4.}},
  13. {{0.5, 3.75}, {0.853553, 3.39645}},
  14. {{1., 3.}, {1.22361, 2.55279}},
  15. {{1.5,1.75}, {1.65811, 1.27566}},
  16. {{2., 0.}, {2.12127, -0.485071}}}
  17.  
  18. Plot[f[x], {x, -2, 2},
  19. AspectRatio -> 1,
  20. PlotStyle -> {Red, Dotted},
  21. PlotRangePadding -> {{Automatic, .2}, {.5, Automatic}},
  22. Epilog -> {AbsoluteThickness[1.5], Arrow /@ tangetVectors}]
  23.  
  24. Graphics[{AbsoluteThickness[1.75], Arrow /@ tangetVectors}]
Add Comment
Please, Sign In to add comment