Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- f(x) = frac{x^4}{12}-frac{2x^3}{3}+frac{3 x^2}{2}
- documentclass[tikz,border=3.14mm]{standalone}
- usepackage{pgfplots}
- pgfplotsset{compat=1.16}
- usepgfplotslibrary{fillbetween}
- makeatletter
- defparsenode[#1]#2pgf@nil{%
- tikzset{label node/.style={#1}}
- defnodetext{#2}
- }
- tikzset{
- add node at x/.style 2 args={
- name path global=plot line,
- /pgfplots/execute at end plot visualization/.append={
- begingroup
- @ifnextchar[{parsenode}{parsenode[]}#2pgf@nil
- path [xshift=-0.1pt,name path global = position line #1-1]
- ({axis cs:#1,0}|-{rel axis cs:0,0}) --
- ({axis cs:#1,0}|-{rel axis cs:0,1});
- path [xshift=0.1pt, name path global = position line #1-2]
- ({axis cs:#1,0}|-{rel axis cs:0,0}) --
- ({axis cs:#1,0}|-{rel axis cs:0,1});
- path [
- name intersections={
- of={plot line and position line #1-1},
- name=left intersection
- },
- name intersections={
- of={plot line and position line #1-2},
- name=right intersection
- },
- label node/.append style={pos=1}
- ] (left intersection-1) -- (right intersection-1)
- node [label node]{nodetext};
- endgroup
- }
- }
- }
- makeatother
- begin{document}
- begin{tikzpicture}[>=latex]
- begin{axis}[
- xtick={-2,-1,...,5},
- xticklabel=empty,
- ytick={-2,-1,...,5},
- yticklabel=empty, grid=major,
- axis x line=center,
- axis y line=center,
- xlabel={$x$},
- ylabel={$y$},
- xlabel style={below},
- ylabel style={left},
- xmin=-2,
- xmax=5,
- ymin=-2,
- ymax=5,
- tangent/.style={
- add node at x={#1}{
- [
- sloped,
- append after command={(tikzlastnode.west) edge [thick,black] (tikzlastnode.east)},
- minimum width=0.2textwidth
- ]
- }
- }]
- 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};
- end{axis}
- end{tikzpicture}
- end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement