t_max = 2.5 t = seq(0, t_max, length.out=1000 ) y = ( 1/(8*sqrt(31)) ) * exp(-2*t) * sin( 2 * sqrt(31) * t ) # Find the time tau after which lu(t)| < 0.01 for all t>tau # y_thresh = 0.01/12 # in feet 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_10_plot.eps", onefile=FALSE, horizontal=FALSE) plot( t, y, type='l', main='problem 10' ) abline(v=t[t_index+1], col='black') abline(h=c(-y_thresh, y_thresh), col='red') grid() #dev.off()