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