Question

In: Advanced Math

The Ostrowski method for finding a single root of ?(?)=0 is given by Initial guess ?0...

The Ostrowski method for finding a single root of ?(?)=0 is given by
Initial guess ?0 ??=??−?(??)?′(??), ??+1=??−?(??)?′(??) ?(??)?(??)−2?(??).
a) Write MATLAB or OCTAVE coding to implement the Ostrowski method.
(Hint: You may use the coding of Newton Method given in Moodle pages)
b) Use your coding to find a root of the equation
(?−2)2−ln(?)=0
With initial guess ?0=1.0 and ?0 = 3.0.
Write or print the results in your Homework sheet.

Solutions

Expert Solution


%%Matlab code for finding root using newton secant bisection and false
clear all
close all

%function for which root have to find
fun=@(x) (x-2).^2-log(x);
fprintf('For the function f(x)=')
disp(fun)
xx=linspace(0,4);
yy=fun(xx);

plot(xx,yy)
xlabel('x')
ylabel('f(x)')
title('x vs. f(x) plot')
box on; grid on;
[root1]=newton_method(fun,1,1000);
[root2]=newton_method(fun,3,1000);
hold on
plot(root1,fun(root1),'r*')
plot(root2,fun(root2),'r*')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Matlab function for Newton Method
function [root]=newton_method(fun,x0,maxit)
syms x
g1(x) =diff(fun,x);   %1st Derivative of this function
xx=x0;            %initial guess]
fprintf('\nRoot using Newton method for initial guess %f\n',x0)
%Loop for all intial guesses
    n=5*10^-15; %error limit for close itteration
    for i=1:maxit
        x2=double(xx-(fun(xx)./g1(xx))); %Newton Raphson Formula
        cc=double(fun(x2));                 %Error
        err(i)=cc;
        xx=x2;
        if cc<=n
            break
        end
      
    end
    fprintf('\tAfter %d iteration root using Newton method is %f\n',i,xx)
    root=xx;
end
  
%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%


Related Solutions

Consider the Newton-Raphson method for finding root of a nonlinear function ??+1=??−?(??)?′(??), ?≥0. a) Prove that...
Consider the Newton-Raphson method for finding root of a nonlinear function ??+1=??−?(??)?′(??), ?≥0. a) Prove that if ? is simple zero of ?(?), then the N-R iteration has quadratic convergence. b) Prove that if ? is zero of multiplicity ? , then the N-R iteration has only linear convergence.
Use the False Position method to find a guess of the root of f(x) = cos(x2...
Use the False Position method to find a guess of the root of f(x) = cos(x2 ) with lower and upper bounds of 0 and 2, respectively. Then, narrow the interval and find a new guess of the root using False Position. What is your relative approximate error? a. 8.47% answer b. 12.45% c. 0.112 d. 0.243 e. None of the above Please provide complete solution how the answer is a thumbs up for correct and neat solution! step by...
I'm writing a code for the Secant Method for root finding, but my code makes an...
I'm writing a code for the Secant Method for root finding, but my code makes an infinite code of the correct answer. Below is my code, how do I fix it? def f(x): return (x**6)+7*(x**5)-15*(x**4)-70*(x**3)+75*(x**2)+175*x-125 def secant(): p0=float(input('Enter an initial guess for the root ')) p1=float(input('Enter another guess ')) TOL=float(input('Enter a tolerance in decimal form ')) n=15 i=1 while i<=n: p=p1-f(p1)*(p1-p0)/(f(p1)-f(p0)) if abs(p-p1)<TOL: print(p) else: p0=p1 p1=p i=i+1 else: print(p) return p    print(secant())
Name and sketch two ways in which an open method for root finding can fail to...
Name and sketch two ways in which an open method for root finding can fail to locate a root even when a root exists.
How could a root finding algorithm like the bisection method be used to approximate a value...
How could a root finding algorithm like the bisection method be used to approximate a value such as sqrt(3). In other words how can a root finding algorithm find an x value with a given y value? Write a script to illustrate this usage scenario. Compare the output of your script with the result from a calculator. You must use matlab!! using a while loop.
Given the function f(x) on the right solve the following root finding questions: a) Find a...
Given the function f(x) on the right solve the following root finding questions: a) Find a positive root (x > 0) of f(x) using the Bisection Method . b) Find a negative root (x < 0) of f(x) using the Bisection Method. c) Find a positive root (x > 0) of f(x) using the False Position Method. d) Find a negative root (x < 0) of f(x) using the False Position Method. Find your initial Bracket via Trial-and-Error. Use |...
USING BISECTION METHOD, FIND THE ROOT OF 0.5e^x - 5x + 2 = 0 ON THE...
USING BISECTION METHOD, FIND THE ROOT OF 0.5e^x - 5x + 2 = 0 ON THE INTERVAL [ 0 , 1 ] UP TO 3 DECIMAL PLACES. USE NEWTON'S METHOD TO APPROXIMATE THE ROOT OF f(x)=x^2-5    IN THE INTERVAL  [ 2 , 3 ] UP TO 4 DECIMAL PLACES.
GIVEN: COS(x) +3xe^-x=0 USING NEWTON RAPHSON METHOD Find: 1.) The POSITIVE ROOT USING X0=2 2.) THE...
GIVEN: COS(x) +3xe^-x=0 USING NEWTON RAPHSON METHOD Find: 1.) The POSITIVE ROOT USING X0=2 2.) THE NEGATIVE ROOT USING X0=-0.5 *STOPPING CRITERION ≤ 0.01% use radian mode in calcu and i dont want a program answers pls i need the manual method.
Consider the initial value problem given below. y'=x+4cos(xy), Y(0)=0 Use the improved​ Euler's method subroutine with...
Consider the initial value problem given below. y'=x+4cos(xy), Y(0)=0 Use the improved​ Euler's method subroutine with step size h=0.3 to approximate the solution to the initial value problem at points x= 0.0,0.3,0.6.....3.0
Solve the given initial-value problem by finding, as in Example 4 of Section 2.4, an appropriate...
Solve the given initial-value problem by finding, as in Example 4 of Section 2.4, an appropriate integrating factor. (x2 + y2 ? 3) dx = (y + xy) dy,    y(0) = 1
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT