Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 3 Write a Julia function newtonsearch that take a function f(x) and an i

ID: 2085912 • Letter: P

Question

Problem 3 Write a Julia function newtonsearch that take a function f(x) and an initial guess x, and returns a root r of f using the Newton method. Find the root to an accuracy appropriate for the floating-point type of the initial guess x Hints Unlike bisection, which is guaranteed to converge, the Newton method can go haywire. Think of a good way to test if the Newton method is failing, and print an error message and exit in this case. Your function should still return a number of the same floating-point type as *o. In Julia, this is known as type stability All the hints for Problem 1 apply. In t 1

Explanation / Answer

x = 2

f(x) = x^3 - 2x - 5
fp(x) = 3x^2 - 2

y = abs(f(x))

while   y <= 0.0001

    x = x - (f(x)/fp(x))

   
    y = abs(f(x))
   
end
(x,f(x))

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote