Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. f(x) = frac{x^4}{12}-frac{2x^3}{3}+frac{3 x^2}{2}
  2.  
  3. documentclass[tikz,border=3.14mm]{standalone}
  4. usepackage{pgfplots}
  5. pgfplotsset{compat=1.16}
  6. usepgfplotslibrary{fillbetween}
  7. makeatletter
  8. defparsenode[#1]#2pgf@nil{%
  9. tikzset{label node/.style={#1}}
  10. defnodetext{#2}
  11. }
  12.  
  13. tikzset{
  14. add node at x/.style 2 args={
  15. name path global=plot line,
  16. /pgfplots/execute at end plot visualization/.append={
  17. begingroup
  18. @ifnextchar[{parsenode}{parsenode[]}#2pgf@nil
  19. path [xshift=-0.1pt,name path global = position line #1-1]
  20. ({axis cs:#1,0}|-{rel axis cs:0,0}) --
  21. ({axis cs:#1,0}|-{rel axis cs:0,1});
  22. path [xshift=0.1pt, name path global = position line #1-2]
  23. ({axis cs:#1,0}|-{rel axis cs:0,0}) --
  24. ({axis cs:#1,0}|-{rel axis cs:0,1});
  25. path [
  26. name intersections={
  27. of={plot line and position line #1-1},
  28. name=left intersection
  29. },
  30. name intersections={
  31. of={plot line and position line #1-2},
  32. name=right intersection
  33. },
  34. label node/.append style={pos=1}
  35. ] (left intersection-1) -- (right intersection-1)
  36. node [label node]{nodetext};
  37. endgroup
  38. }
  39. }
  40. }
  41. makeatother
  42.  
  43. begin{document}
  44. begin{tikzpicture}[>=latex]
  45. begin{axis}[
  46. xtick={-2,-1,...,5},
  47. xticklabel=empty,
  48. ytick={-2,-1,...,5},
  49. yticklabel=empty, grid=major,
  50. axis x line=center,
  51. axis y line=center,
  52. xlabel={$x$},
  53. ylabel={$y$},
  54. xlabel style={below},
  55. ylabel style={left},
  56. xmin=-2,
  57. xmax=5,
  58. ymin=-2,
  59. ymax=5,
  60. tangent/.style={
  61. add node at x={#1}{
  62. [
  63. sloped,
  64. append after command={(tikzlastnode.west) edge [thick,black] (tikzlastnode.east)},
  65. minimum width=0.2textwidth
  66. ]
  67. }
  68. }]
  69. addplot[color=blue,smooth,samples=501, thick,tangent/.list={1,3},domain=-5:5] {(3* x^2)/2 - (2 *x^3)/3 + x^4/12};
  70. end{axis}
  71. end{tikzpicture}
  72. end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement