Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- f[x_] := 4 - x^2
- vector[tail : {_, _}, slope_, length_: 1.] :=
- Module[{θ = ArcTan[slope]}, {tail, tail + length {Cos[θ], Sin[θ]}}]
- tangetVectors = N @ Table[vector[{x, f[x]}, f'[x], .5], {x, Subdivide[-2, 2, 8]}]
- {{{-2., 0.}, {-1.87873, 0.485071}},
- {{-1.5, 1.75}, {-1.34189, 2.22434}},
- {{-1., 3.}, {-0.776393, 3.44721}},
- {{-0.5, 3.75}, {-0.146447, 4.10355}},
- {{0., 4.}, {0.5, 4.}},
- {{0.5, 3.75}, {0.853553, 3.39645}},
- {{1., 3.}, {1.22361, 2.55279}},
- {{1.5,1.75}, {1.65811, 1.27566}},
- {{2., 0.}, {2.12127, -0.485071}}}
- Plot[f[x], {x, -2, 2},
- AspectRatio -> 1,
- PlotStyle -> {Red, Dotted},
- PlotRangePadding -> {{Automatic, .2}, {.5, Automatic}},
- Epilog -> {AbsoluteThickness[1.5], Arrow /@ tangetVectors}]
- Graphics[{AbsoluteThickness[1.75], Arrow /@ tangetVectors}]
Add Comment
Please, Sign In to add comment