瀏覽代碼

improved cubic function design a lot

Martin Thoma 13 年之前
父節點
當前提交
2d68e35461

+ 32 - 8
tikz/cubic-function-intermediate-value-theorem/cubic-function-intermediate-value-theorem.tex

@@ -2,8 +2,15 @@
 \usepackage[pdftex,active,tightpage]{preview}
 \setlength\PreviewBorder{2mm}
 \usepackage{pgfplots}
+\usepackage{units}
+\pgfplotsset{compat=1.3}% <-- moves axis labels near ticklabels
+                        % (respects tick label widths)
 \usepackage{tikz}
 \usetikzlibrary{arrows, positioning, calc, intersections, decorations.markings}
+
+\usepackage{xcolor}
+\definecolor{horizontalLineColor}{HTML}{008000}
+\definecolor{verticalLineColor}{HTML}{FF0000}
  
 \begin{document}
 
@@ -19,11 +26,12 @@
 \begin{preview}
 \begin{tikzpicture}
     \begin{axis}[
-        %width=15cm, height=15cm,     % size of the image
-        %xmin= 0,      % start the diagram at this x-coordinate
-        %xmax= 250,    % end   the diagram at this x-coordinate
-        %ymin=-7,     % start the diagram at this y-coordinate
-        %ymax= 7,   % end   the diagram at this y-coordinate
+        label distance=0mm,
+        width=8cm, height=7cm,     % size of the image
+        xmin= 40,      % start the diagram at this x-coordinate
+        xmax= 180,    % end   the diagram at this x-coordinate
+        ymin=60,     % start the diagram at this y-coordinate
+        ymax=170,   % end   the diagram at this y-coordinate
         ylabel=y,
         xlabel=x,
         axis lines=left,
@@ -31,9 +39,25 @@
         xticklabels={,,},
         yticklabels={,,}
     ]
-      \addplot[name path global=a, domain=30:250, red, thick,samples=500] 
-        {-0.00192*x*x*x+0.85*x*x-121.92*x+5815.75};
-%        {-226/117649*x*x*x+100005/117649*x*x-14343768/117649*x+684216906/117649};
+      \addplot[name path global=a, domain=55:161, dotted, blue, 
+               very thick,samples=500, label=$y=f(x)$] 
+        {113/132078*x*x*x-11865/44026*x*x+1169437/44026*x-93155207/132078};
+      % ( 55 |  82.7344) and (161 | 156.011) are on the graph
+      \coordinate (b) at (axis cs: 55,170);
+      \coordinate (c) at (axis cs:161,170);
+      \coordinate (d) at (axis cs:161,82.7344);
+      \coordinate (e) at (axis cs:161,156.011);
+      \coordinate (a1) at (axis cs:55,111.494);
+      \coordinate (a2) at (axis cs:161,111.494);
+      \draw[verticalLineColor, thick, <->](a1) -- (a2);
+      \draw[verticalLineColor,dashed](b |- 0,0) -- (b);
+      \draw[verticalLineColor,dashed](c |- 0,0) -- (c);
+      \draw[horizontalLineColor,dashed, thick](d -| 0,0) -- (d);
+      \draw[horizontalLineColor,dashed, thick](e -| 0,0) -- (e);
+
+      % (100 | 111.494)
+      \coordinate (f) at (axis cs:100, 111.494);
+      \draw[red,dashed](f |- 0,0) -- (f);
     \end{axis} 
 \end{tikzpicture}
 \end{preview}