source( 'utils.R') # Plot the forcing function: # t = seq( 0, 6*pi, length.out=500 ) n = 15 f = u_sub_c( t, 0 ) for( k in 1:n ){ f = f + 2 * (-1)^k * u_sub_c( t, k*pi ) } #postscript("../../WriteUp/Graphics/Chapter6/sect_4_prob_19_f_t_plot.eps", onefile=FALSE, horizontal=FALSE) plot( t, f, type='l', xlab='t', ylab='f(t)' ) grid() #dev.off() # Plot the solution: # t = seq( 0, 60, length.out=1000 ) n = 15 y = u_sub_c( t, 0 ) for( k in 1:n ){ y = y + 2 * (-1)^k * u_sub_c( t, k*pi ) } y = y - cos(t) for( k in 1:n ){ y = y - 2 * (-1)^k * cos( t - k*pi ) * u_sub_c( t, k*pi ) } #postscript("../../WriteUp/Graphics/Chapter6/sect_4_prob_19_y_t_plot.eps", onefile=FALSE, horizontal=FALSE) plot( t, y, type='l', col='black', xlab='t', ylab='y(t)' ) grid() #dev.off()