
但我的程式碼根本不起作用
\begin{tikzpicture}
\begin{axis}[
width=18cm,
axis lines=middle,
xmin=0,xmax=1.02,
ymin=0.86,ymax=1.02,,
xlabel=\Large $c$,ylabel=\Large $F_g$,
xtick={0.2,0.4,0.6,0.8,1.0},
ytick={0.88,0.94,0.98,1},
]
\addplot[blue,samples=800,domain=0:1,smooth] {0.25*((sqrt{(1+(\x))*(1+ (sqrt{\x}))}) + (sqrt{((1+(\x))*(1+(sqrt{\x})))}))^2};
\end{axis}
\end{tikzpicture}
有人可以幫我解決這個問題嗎?因此,像 (f(\x) + g(\x))^2 這樣的東西永遠不會起作用。有沒有錯字或有更好的方法嗎?
答案1
您輸入了錯誤的函數(+
在這兩個術語中,人們應該輸入錯誤的函數-
),而就此而言,您sqrt(x)
不應該輸入錯誤的函數。sqrt{x}
還有其他問題,但我只是從頭開始重寫:
\addplot[blue,samples=80,domain=0:1,smooth] {0.25*(sqrt((1-x)*(1-sqrt(x))) + sqrt((1+x)*(1+sqrt(x))))^2};
完整的程式碼,對軸限制和刻度標籤進行了一些修改:
\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
width=18cm,
axis lines=middle,
xmin=0,xmax=1.02,
ymin=0.98,ymax=1.01,
xlabel=\Large $c$,ylabel=\Large $F_g$,
xtick={0.2,0.4,0.6,0.8,1.0},
ytick={0.98,0.985,...,1.01},
yticklabel style={
/pgf/number format/fixed zerofill,
/pgf/number format/precision=3,
}
]
\addplot[blue,samples=80,domain=0:1,smooth] {0.25*(sqrt((1-x)*(1-sqrt(x))) + sqrt((1+x)*(1+sqrt(x))))^2};
\end{axis}
\end{tikzpicture}
\end{document}