![geogebra 代码错误](https://linux22.com/image/386947/geogebra%20%E4%BB%A3%E7%A0%81%E9%94%99%E8%AF%AF.png)
大家好,我正在尝试用 geogebra 绘制一个图表,但我不知道为什么,但出现错误。:(
你能帮助我吗?谢谢
\documentclass[border=5mm]{standalone}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\definecolor{ffqqqq}{rgb}{1.0,0.0,0.0}
\definecolor{cqcqcq}{rgb}{0.7529411764705882,0.7529411764705882,0.7529411764705882}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\draw [color=cqcqcq,dash pattern=on 2pt off 2pt, xstep=1.0cm,ystep=1.0cm] (-5.0,-5.000000000000001) grid (13.60966,6.550825852439807);
\draw[->,color=black] (-5.0,0.0) -- (13.60966,0.0);
\foreach \x in {-5.0,-4.0,-3.0,-2.0,-1.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0}
\draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt) node[below] {\footnotesize $\x$};
\draw[->,color=black] (0.0,-5.000000000000001) -- (0.0,6.550825852439807);
\foreach \y in {-5.0,-4.0,-3.0,-2.0,-1.0,1.0,2.0,3.0,4.0,5.0,6.0}
\draw[shift={(0,\y)},color=black] (2pt,0pt) -- (-2pt,0pt) node[left] {\footnotesize $\y$};
\draw[color=black] (0pt,-10pt) node[right] {\footnotesize $0$};
\clip(-5.0,-5.000000000000001) rectangle (13.60966,6.550825852439807);
\draw[line width=2.8000000000000003pt,smooth,samples=100,domain=-5.0:13.60966] plot(\x,{1.0/2.0*(\x)^(3.0)-2.0*(\x)});
\draw (-4.498348295652174,4.244636869852858) node[anchor=north west] {$f(x) \, = \,\frac{1}{2} \; x^{3} - 2 \; x$};
\draw[line width=2.8000000000000003pt,color=ffqqqq,smooth,samples=100,domain=-5.0:13.60966] plot(\x,{1.0/((\x)^(2.0)+1.0)});
\draw [color=ffqqqq](3.6251728521739124,3.349994592125162) node[anchor=north west] {$g(x) \, = \,\frac{1}{x^{2} + 1}$};
\begin{scriptsize}
\draw[color=black] (-2.5402884173913045,-4.741547786434222) node {$f$};
\draw[color=ffqqqq] (-4.870541495652174,-0.08940794225020257) node {$g$};
\end{scriptsize}
\end{tikzpicture}
\end{document}
答案1
罪魁祸首是
\draw[line width=2.8000000000000003pt,smooth,samples=100,domain=-5.0:13.60966] plot(\x,{1.0/2.0*(\x)^(3.0)-2.0*(\x)});
但好消息是,完全没有必要使用这么大的情节范围。
\documentclass[border=5mm]{standalone}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\definecolor{ffqqqq}{rgb}{1.0,0.0,0.0}
\definecolor{cqcqcq}{rgb}{0.7529411764705882,0.7529411764705882,0.7529411764705882}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\draw [color=cqcqcq,dash pattern=on 2pt off 2pt, xstep=1.0cm,ystep=1.0cm] (-5.0,-5.000000000000001) grid (13.60966,6.550825852439807);
\draw[->,color=black] (-5.0,0.0) -- (13.60966,0.0);
\foreach \x in {-5.0,-4.0,-3.0,-2.0,-1.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0}
{\draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt) node[below]
{\footnotesize $\x$};}
\draw[->,color=black] (0.0,-5.000000000000001) -- (0.0,6.550825852439807);
\foreach \y in {-5.0,-4.0,-3.0,-2.0,-1.0,1.0,2.0,3.0,4.0,5.0,6.0}
{\draw[shift={(0,\y)},color=black] (2pt,0pt) -- (-2pt,0pt) node[left]
{\footnotesize $\y$};}
\draw[color=black] (0pt,-10pt) node[right] {\footnotesize $0$};
\clip(-5.0,-5.000000000000001) rectangle (13.60966,6.550825852439807);
\draw[line width=2.8000000000000003pt,smooth,samples=100,domain=-4:4]
plot(\x,{1.0/2.0*(\x)^3-2*(\x)}); %13.60966
\draw (-4.498348295652174,4.244636869852858) node[anchor=north west] {$f(x) \, = \,\frac{1}{2} \; x^{3} - 2 \; x$};
\draw[line width=2.8000000000000003pt,color=ffqqqq,smooth,samples=100,domain=-5.0:13.60966] plot(\x,{1.0/((\x)^(2.0)+1.0)});
\draw [color=ffqqqq](3.6251728521739124,3.349994592125162) node[anchor=north west] {$g(x) \, = \,\frac{1}{x^{2} + 1}$};
\draw[color=black] (-2.5402884173913045,-4.741547786434222)
node[font=\scriptsize] {$f$};
\draw[color=ffqqqq] (-4.870541495652174,-0.08940794225020257) node[font=\scriptsize] {$g$};
\end{tikzpicture}
\end{document}
我还想说的是,你采取的策略在我看来有些奇怪。你使用了一些软件,GeoGebra,它会产生一段你似乎无法 100% 理解的代码。然后你在在线论坛上寻求帮助。别误会我的意思,这本身并没有什么错。但是,我个人不想受这种软件的摆布,如果我理解正确的话,它会产生导致错误的输出。顺便说一句,代码真的远非漂亮或优雅。如果我是你,我会考虑放弃 GeoGebra 并改用 pgfplots,在那里可以轻松生成此类图表,并且你将不会遇到dimension too large
此处的错误。