我想绘制一个函数,它是到的f(x)
总和。定义域是从到。cos(n*x)
n=0
n=100
0
2π
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}
\begin{document}
\begin{pspicture}(-5,-5)(5,5)
\psplot[plotpoints=100]{0}{TwoPi}{%
/k 0 def
/out 0 def
0 1 10
{
x k mul RadtoDeg cos out add /out ED
k 1 add /k ED
} for
out
}
\end{pspicture}
\end{document}
输出似乎错误,如下所示。
这里如何使用 PostScript for
?
答案1
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}
\begin{document}
\begin{pspicture}(-1,-7)(7,7)
\psaxes{->}(0,0)(0,-7)(7,7)
\psplot[plotpoints=5000,linewidth=0.2pt]{0}{TwoPi}{%
/out 0 def
0 1 100
{ % loop variable is on the stack
x mul RadtoDeg cos out add /out ED
} for
out
}
\end{pspicture}
\end{document}
和
\psplot[plotpoints=5000,plotstyle=dots,dotscale=0.4]{0}{TwoPi}{%