给一个f(x)=x (x \in (0,\pi))的例子吧:
Simplify[2/Pi * Integrate[Sin[n x] x, {x, 0, pi}],
Assumptions -> n \[Element] Integers]
得到正弦的系数:(因为延拓成了奇函数)
-2*((-1)^n/n)
然后画出来即可,搞点花样吧,使用了Manipulate,这样可以动感一点:
Manipulate[
Show[{Plot[Evaluate[Sum[-2*(-1)^n/n Sin[n x], {n, 1, k}]], {x, 0, 1},
PlotRange -> {0, 1}],
Plot[x, {x, 0, 1}, PlotStyle -> {Red, Dashed}]}], {k, 10, 50}]
另一个修行靠个人了,呵呵~
用plot函数就可以了.