# Find 9 iterations of Newton's method for x0=1 and the
# polynomial p(x)=x^5-3x^3-5x^2+15.
println("This is the example problem for Quiz 2.")
xn=[1.57142857142857, 1.65117170652226,
1.68628082475969, 1.70211084458455,
1.70837387112583, 1.70987638821569,
1.7099755102779, 1.70997594666823,
1.7099759466767 ]
function newton(x)
# Please fix this function
return x
end
# Please fix the definition of x
x=3.0
wrong=9
for i=1:9
global wrong,x
x=newton(x);
println("x_$i = $x")
if abs(x-xn[i])<1e-7
wrong-=1
end
end
if wrong>0
println("Please try again. Your answer is incorrect.")
else
println("Congratulations! Your answer is correct!")
end
to approximate a solution to p(x)=0 using 9
iterations of Newton's method
where
Note that the correct answer is
x3 ≈ 1.68628082475969, x4 ≈ 1.70211084458455,
x5 ≈ 1.70837387112583, x6 ≈ 1.70987638821569,
x7 ≈ 1.7099755102779, x8 ≈ 1.70997594666823,
x9 ≈ 1.7099759466767.