quadratic-function-uniform-continuity.tex 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. \documentclass{article}
  2. \usepackage[pdftex,active,tightpage]{preview}
  3. \setlength\PreviewBorder{2mm}
  4. \usepackage{amssymb,amsmath}
  5. \usepackage{pgfplots}
  6. \usepackage{tikz}
  7. \usetikzlibrary{arrows, positioning, calc, intersections, decorations.pathreplacing}
  8. \newcommand\tikzmark[1]{%
  9. \tikz[overlay,remember picture,baseline] \coordinate [anchor=base] (#1);}
  10. \newcommand\DrawBrace[3]{%
  11. \draw [ultra thick, decorate,decoration={brace,amplitude=5pt,mirror,raise=2pt}]
  12. (#1) -- (#2) node [midway,xshift=23pt] {\Huge $\displaystyle #3$};
  13. }
  14. \begin{document}
  15. \begin{preview}
  16. \begin{tikzpicture}[/pgf/declare function={f=x^2;}]
  17. \pgfplotsset{
  18. right segments/.code={\pgfmathsetmacro\rightsegments{#1}},
  19. right segments=3,
  20. right/.style args={#1:#2}{
  21. ybar interval,
  22. domain=#1+((#2-#1)/\rightsegments):#2+((#2-#1)/\rightsegments),
  23. samples=\rightsegments+1,
  24. x filter/.code=\pgfmathparse{\pgfmathresult-((#2-#1)/\rightsegments)}
  25. }
  26. }
  27. \pgfplotsset{
  28. left segments/.code={\pgfmathsetmacro\leftsegments{#1}},
  29. left segments=3,
  30. left/.style args={#1:#2}{
  31. ybar interval,
  32. domain=#1:#2,
  33. samples=\leftsegments+1,
  34. x filter/.code=\pgfmathparse{\pgfmathresult}
  35. }
  36. }
  37. \begin{axis}[
  38. axis lines=middle,
  39. width=15cm, height=15cm, % size of the image
  40. grid = major,
  41. grid style={dashed, gray!30},
  42. xmin= 0, % start the diagram at this x-coordinate
  43. xmax= 4.3, % end the diagram at this x-coordinate
  44. ymin= 0, % start the diagram at this y-coordinate
  45. ymax=17, % end the diagram at this y-coordinate
  46. axis background/.style={fill=white},
  47. ylabel=y,
  48. xlabel=x,
  49. tick align=outside,
  50. tension=0.08,
  51. legend style={at={(0.25,0.91)}, anchor=north}]
  52. \addplot[ultra thick, red, samples=1000] {f};
  53. \addplot [
  54. black!80,
  55. fill=green,
  56. opacity=.3,
  57. left segments=4,
  58. left=0:4
  59. ] {f};
  60. \legend{$f: \mathbb{R^+} \rightarrow \mathbb{R^+} ~~~ f(x) = x^2$};
  61. %\node[coordinate,label=$\delta$] at (axis cs:0.5,0) {};
  62. \node[coordinate,label=$\delta$] at (axis cs:1.5,0) {};
  63. \node[coordinate,label=$\delta$] at (axis cs:2.5,0) {};
  64. \node[coordinate,label=$\delta$] at (axis cs:3.5,0) {};
  65. \coordinate (a) at (axis cs:1,1);
  66. \coordinate (b) at (axis cs:2,4);
  67. \coordinate (c) at (axis cs:3,9);
  68. \coordinate (d) at (axis cs:4,16);
  69. \draw[ultra thick, blue,dashed](a -| current plot begin) -- (a);
  70. \draw[ultra thick, blue,dashed](a |- current plot begin) -- (a);
  71. \draw[ultra thick, blue,dashed](b -| current plot begin) -- (b);
  72. \draw[ultra thick, blue,dashed](b |- current plot begin) -- (b);
  73. \draw[ultra thick, blue,dashed](c -| current plot begin) -- (c);
  74. \draw[ultra thick, blue,dashed](c |- current plot begin) -- (c);
  75. \draw[ultra thick, blue,dashed](d -| current plot begin) -- (d);
  76. \draw[ultra thick, blue,dashed](d |- current plot begin) -- (d);
  77. \coordinate (x1) at (axis cs: 0, 1);
  78. \coordinate (x2) at (axis cs: 0, 4);
  79. \coordinate (x3) at (axis cs: 0, 9);
  80. \coordinate (x4) at (axis cs: 0,16);
  81. \DrawBrace{x1}{x2}{\varepsilon_1};
  82. \DrawBrace{x2}{x3}{\varepsilon_2};
  83. \DrawBrace{x3}{x4}{\varepsilon_3};
  84. \end{axis}
  85. \end{tikzpicture}
  86. \end{preview}
  87. \end{document}