lambs = seq(0.01, 0.2, length.out=200) lhs = function(lam, n=15){ one_plus_lambda = 1 + lam one_plus_lambda_to_the_n = one_plus_lambda^n 1/one_plus_lambda_to_the_n + (0.1/lam) * ( 1 - 1/one_plus_lambda_to_the_n ) } # Find the value of lambda where lhs(lambda)=1.05: # source('http://waxworksmath.com/Authors/A_F/Conte/Code/Chapter3/utils.R') rt = bisection_method(0.05, 0.10, function(x){ lhs(x) - 1.05 }) print(rt) # Plot the left-hand-side and this value of lambda: # plot(lambs, lhs(lambs), type='l', xlab='lambda', ylab='left-hand-side') abline(h=1.05, col='blue') abline(v=rt[1], col='green') grid()