t_max = 1.0 t = seq( 0, t_max, length.out=500 ) y = 2 * exp(-10 * t) * cos(4 * sqrt(6) * t) + (5/sqrt(6)) * exp(-10 * t) * sin(4 * sqrt(6) * t) # Find the time tau after which |u(t)| < 0.05 for all t>tau # y_thresh = 0.05 below_t = abs(y) < y_thresh # Walk backwards until we get the first FALSE: # t_index = length(y) while( below_t[t_index] ){ t_index = t_index-1 } tau = t[t_index+1] print(sprintf('tau= %.3f', tau)) #postscript("../../WriteUp/Graphics/Chapter3/sect_7_prob_9_plot.eps", onefile=FALSE, horizontal=FALSE) plot( t, y, type='l', main='problem 9' ) abline(v=t[t_index+1], col='black') abline(h=c(-y_thresh, y_thresh), col='red') grid() #dev.off()