
Ich habe die folgende Differentialgleichung, die ich grafisch darstellen möchte:
dy/dx = \frac{2x}{x^4+1}
. Außerdem möchte ich die Lösung grafisch darstellen, die durch den Punkt verläuft (1,1)
. Folgendes habe ich derzeit:
\documentclass{report}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{external}
\tikzexternalenable
\begin{document}
\begin{tikzpicture}[declare function={f(\x)=2*\x/(\x^4+1);}]
\begin{axis}[
xmin=-4,xmax=4,
ymin=-4,ymax=4,
domain=-4:4,
]
\def\xmax{4} \def\xmin{-4}
\def\ymax{4} \def\ymin{-4}
\def\nx{15}
\def\ny{15}
\def\yo{1}
\pgfmathsetmacro{\hx}{(\xmax-\xmin)/\nx}
\pgfmathsetmacro{\hy}{(\ymax-\ymin)/\ny}
\foreach \i in {0,...,\nx}
\foreach \j in {0,...,\ny}{
\pgfmathsetmacro{\yprime}{f({\xmin+\i*\hx})}
\addplot [blue,shift={({\xmin+\i*\hx},{\ymin+\j*\hy})}]
(0,0)--($(0,0)!2mm!(.1,.1*\yprime)$);
}
\addplot [<->,red] {-1/4*pi+rad(atan(x^2))+1};
\end{axis}
\end{tikzpicture}
\end{document}
Ich erhalte jedoch ständig die folgende Fehlermeldung:
! Missing number, treated as zero.
<to be read again>
{
l.30 }
?
Ich hatte ursprünglich „ \pgfmathsetmacro{\yprime}{f({\xmin+\i*\hx},{\ymin+\j*\hy})}
ersetzen von“ verwendet, \pgfmathsetmacro{\yprime}{f({\xmin+\i*\hx})}
da ich \y nicht übergeben muss, da die Funktion es nicht verwendet. Aber selbst wenn ich dies tue und die Funktionsdefinition von f(\x) = ...
auf aktualisiere f(\x,\y) = ...
, stürzt das Programm immer noch ab und gibt Folgendes aus:
! Undefined control sequence.
\pgfmath@dimen@ ...men@@ #1=0.0pt\relax \pgfmath@
l.32 \end{axis}
?
Die folgenden Fragen sind mir bekannt. Ich habe sie verwendet und keine davon hat funktioniert: