save_figs = FALSE # Plot the solution: # ts = seq(0, 2*pi, length.out=200 ) ys = -(1/5) * exp(-ts) * cos(2*ts) - (1/10) * exp(-ts) * sin(2*ts) + 1/5 c = -(1/5)*(1 + exp(pi/2)) mask = ts > pi/2 ys[mask] = c * exp(-ts[mask]) * cos(2*ts[mask]) + (c/2) * exp(-ts[mask]) * sin(2*ts[mask]) # Plot the right-hand-side: # rhs = rep(1, length(ts)) rhs[mask] = 0 y_min = min( c(ys, rhs) ) y_max = max( c(ys, rhs) ) if( save_figs ){ postscript("../../WriteUp/Graphics/Chapter3/chap_3_sect_5_prob_32_plot.eps", onefile=FALSE, horizontal=FALSE) } plot(ts, ys, type='l', ylim=c(y_min, y_max), xlab='t', ylab='y(t)', main='Question 32') lines(ts, rhs, type='l', col='red') grid() if( save_figs ){ dev.off() }