# Find 3 iterations of Newton's method with x0=2 to approximate the # solution to f(x)=0 where f(x)=log(x)-x+2. println("This is Problem 2 for Exam 2.") xngold=[3.386294361119891, 3.149938393803694, 3.1461942570271373 ] x0=2.0 # Define any additional functions you need here function newton(x) # Please add lines to this function and fix # the return value so it's not zero return 0 end correct=0 x=x0 println() for i=1:3 global x,correct x=newton(x); println("x_$(i) = $x") if abs(x-xngold[i])<1e-7 correct+=1 end end println() if correct!=3 println("Please try again. Your answer is incorrect.") else println("Congratulations! Your answer is correct!") end