# Plot the functions from Exer. 3.7. Exercise 3.7 defines the approximation S(t; n) to a function…

Plot the functions from Exer. 3.7.

Exercise 3.7 defines the approximation S(t; n) to a function

f(t). Plot S(t; 1), S(t; 3), S(t; 20), S(t; 200), and the exact f(t) function

in the same plot. Use T = 2π. Name of program file: sinesum1_plot.py. ⋄

Exercise 3.7

Approximate a function by a sum of sines. We consider the

piecewise constant function

Sketch this function on a piece of paper. One can

approximate f(t) by the sum

It can be shown that S(t; n) → f(t) as n →

∞.

Write a Python function S(t, n, T) for returning the value

of S(t; n). Also write a Python f(t, T) for computing f(t). Write out tabular

information showing how the error f(t) − S(t; n) varies with n and t for

the case where n = 1, 3, 5, 10, 30, 100 and t = αT, with T = 2π, and

α = 0.01, 0.25, 0.49. Make a sketch of f(t) and mark the t points in the

table. Use the table to comment on how the quality of the approximation depends

on α and n. Name of program file: sinesum1.py.