| > | # CESARO SUMMATION OF A SQUARE WAVE |
| > |
| > | bodd := k -> (4/Pi)*(1/(2*k+1)); |
| > | partialsum := K -> sum(bodd(k)*sin((2*k+1)*x), k=0..K); |
| > | mean := M -> (1/(M+1))*sum(partialsum(K), K=0..M); |
| > | plot([partialsum(1), mean(1)], x=-1..4); |
| > | plot([partialsum(2), mean(2)], x=-1..4); |
| > | # Qualitatively, the Cesaro mean looks more like a square wave than the partial sum does. |
| > | # Notice, however, that the Cesaro approximation is NUMERICALLY WORSE close to the discontinuity. |
| > |
| > | plot([partialsum(8), mean(8)], x=-1..4); |
| > | # REMARK: What we're doing is not the smartest way to organize the calculation from the point of view of minimizing computer time. We are calculating the same partial sums over and over again. |
| > |
| > | plot([partialsum(16), mean(16)], x=-1..4); |
| > | plot([partialsum(32), mean(32)], x=-1..4); |
| > | plot([partialsum(64), mean(64)], x=-1..4); |
| > | plot([partialsum(128), mean(128)], x=-1..4); |
| > |
| > |
| > |