f = function(t){ t/10 - cos(t)/5 + 1/5 - log(2) } ts = seq( 0, 10, length.out=100 ) y = f(ts) plot( ts, y, type='l' ) grid() library(stats) res = uniroot( f, c(2.25, 3.5) ) res 10*log(2) f = function(t){ t/10 - cos(t)/(10*pi) + 1/(10*pi) - log(2) } ts = seq( 0, 10, length.out=100 ) y = f(ts) plot( ts, y, type='l' ) grid() library(stats) res = uniroot( f, c(6, 8) ) res # Part d: # #postscript("../../WriteUp/Graphics/Chapter2/chap_2_sect_3_prob_14_plot.eps", onefile=FALSE, horizontal=FALSE) y0 = 1 t = seq( 0, 8, length.out=500 ) ya = y0 * exp( t/10 - cos(t)/5 + 1/5 ) yb = y0 * exp( t/10 ) yc = y0 * exp( t/10 - cos(t)/(10*pi) + 1/(10*pi) ) plot( t, ya, col='blue', type='l', xlab='t', main='Problem 14' ) lines( t, yb, type='l', col='green' ) lines( t, yc, type='l', col='red' ) abline(h=2, col='black') legend( 'topleft', c('Part (a)', 'Part (b)', 'Part (c)'), lwd=2, lty=rep(1, 3), col=c( 'blue', 'green', 'red' ) ) grid() #dev.off()