Question

Matlab Regula Falsi Method

A zero of f(x) = x^2 -4x-12.2 is known to exist on the interval [1.2 , 2.2 , 3.2,...9.2] and respective right endpoints x1 =[2.2 ,3.2, 4.2....10.2], find the sub-interval in which the zero exists. Set the left endpoint of this sub-interval =a and the right endpoint=b

With tolerance of 10^-9, use the Regular Falsi method to compute the root of (f) in [a,b]

User input is required at #####CONTENTS Close Courses LMS Integration Documentation 1 %% INPUT: Define the tolerance 2 tol = 10^-9 %% found zero if f(c) <=

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The Matlab scripts regulaFalsiMethod.m and f.m are posted below. Run the script regulaFalsiMethod.m to generate the result in the Command Window. The screen shot of the result is attached at the end.

regulaFalsiMethod.m

%% INPUT: Define the tolerance
tol = 10^-9;     %% found zero if f(c) <= tol

epsilon = 10^4; %% an arbitrary large value to begin with
steps = 1;       %% to keep track of the number of bisections

%% INPUT: Define the left endpoints of the coarse grid
x0 = 1.2 : 1 : 9.2; %% x0 and x1 set the endpoints of a coarse grid
x1 = x0 + 1;         %% for finding a zero

y0 = f(x0);          %% evaluate the function at the left endpoints
y1 = f(x1);          %% evaluate the function at the right endpoints
product = y0 .* y1; %% product of the endpoint values
index = find( product < 0 ); %% find the position where product < 0
a = x0(index);                %% define the left and right boundaries for
b = x1(index);                %% the finer grid

while epsilon > tol
    %% INPUT: Insert the formula for computing
    c = a - f(a) * (b - a)/(f(b)-f(a));
    epsilon = abs(f(c)); %% this is really |f(c)-0|
    if epsilon <= tol %% enter this if root is found
        fprintf('With a tolerance of %.0e, ater %d steps the root = %.16f\n', tol, steps, c);
        %% INPUT: Store the final value of the root in fnroot
        %% and store the total number of steps in numsteps
        fnroot = c;
        numsteps = steps;
    else
        if f(b) * f(c) < 0
            %% INPUT: Pay close attention to the if test above and decide where b=c and a=c should go
            a = c;
        else
            %% INPUT: Pay close attention to the if test above and decide where b=c and a=c should go
            b = c;
        end
        steps = steps + 1;
    end
end

f.m

function an = f(x)
    an = x.^2 - 4 * x - 12.2;
end

28 regulaFalsiMethod.mx .m x + 24 fprintf(with a tolerance of $.ve, ater $d steps the root = 8.16f\n, tol, 25 %% INPUT: Stor

Add a comment
Know the answer?
Add Answer to:
Matlab Regula Falsi Method A zero of f(x) = x^2 -4x-12.2 is known to exist on...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Problem 4 (programming): Create a MATLAB function named mynewton.m to estimate the root for any a...

    Problem 4 (programming): Create a MATLAB function named mynewton.m to estimate the root for any arbitrary function f given an initial guess xo, an absolute error tolerance e and a maximum number of iterations max iter. Follow mynewton.m template posted in homework 2 folder on TritonED for guidance. You are not required to use the template. The function should return the approximated root ^n and the number of steps n taken to reach the solution. Use function mynewton.m to perform...

  • (1 point) In this problem you will calculate the area between f(x) = x2 and the...

    (1 point) In this problem you will calculate the area between f(x) = x2 and the x-axis over the interval [3,12] using a limit of right-endpoint Riemann sums: Area = lim ( f(xxAx bir (3 forwar). Express the following quantities in terms of n, the number of rectangles in the Riemann sum, and k, the index for the rectangles in the Riemann sum. a. We start by subdividing [3, 12) into n equal width subintervals [x0, x1], [x1, x2),..., [Xn-1,...

  • This program has to be written in matlab 2. Write a function to find a root...

    This program has to be written in matlab 2. Write a function to find a root of f(c) using the secant method. Call this routine secant, call the file secant.m; its first line should be function [x,nf] = secant (fname, x0, x1, tol) fname is the name of the m-file which evaluates the function f(x), 20 and 21 are initial approximations to .c", and tol is a stopping tolerance. Your code should return an approximation x = 2X+1 to 3*...

  • Estimate the area of the region bounded by the graph of f(x)-x + 2 and the x-axis on [0,4] in the following ways a. Divide [0,4] into n = 4 subintervals and approximate the area of the region using...

    Estimate the area of the region bounded by the graph of f(x)-x + 2 and the x-axis on [0,4] in the following ways a. Divide [0,4] into n = 4 subintervals and approximate the area of the region using a left Riemann sum. Illustrate the solution geometrically. b. Divide [0,4] into n = 4 subintervals and approximate the area of the region using a midpoint Riemann sum· illustrate the solution geometrically. C. Divide [04] into n = 4 subintervals and...

  • Questions: 1. Write a MATLAB program to find all the roots of a given, twice continuously differe...

    Questions: 1. Write a MATLAB program to find all the roots of a given, twice continuously differentiable, function f E C2[a, b]. Your program should first probe the function f(x) on the given interval to find out where it changes sign. (Thus, the program has, in addition to f itself, four other input arguments: a, b, the number nprobe of equidistant values between a and b at which f is probed, and a tolerance tol.) For each subinterval [ai,b] over...

  • I'm working on the newton's method on matlab, could someone help me and show what two...

    I'm working on the newton's method on matlab, could someone help me and show what two lines are needed to be added in the codes in order to make this function work? function sample_newton(f, xc, tol, max_iter) % sample_newton(f, xc, tol, max_iter) % finds a root of the given function f over the interval [a, b] using Newton-Raphson method % IN: % f - the target function to find a root of % function handle with two outputs, f(x), f'(x)...

  • Numerical Analysis hr2 h 2 f(x) = a. x3. e-(0.1)x -- +4. x. In(x) – 1500...

    Numerical Analysis hr2 h 2 f(x) = a. x3. e-(0.1)x -- +4. x. In(x) – 1500 = 0 VX + 2 We want to find the root of the above equation. (In order to ease the reading, points are used between variables. Only the number above “e” is equal to “zero point one”.) b) If "a=1.5” and “b=0.8" at the above function, find the root between Xa=50 and Xu=70 using method of false position “Regula-Falsi” until Ea of approximation satisfies...

  • Use the following pseudocode for the Newton-Raphson method to write MATLAB code to approximate the cube...

    Use the following pseudocode for the Newton-Raphson method to write MATLAB code to approximate the cube root (a)1/3 of a given number a with accuracy roughly within 10-8 using x0 = a/2. Use at most 100 iterations. Explain steps by commenting on them. Use f(x) = x3 − a. Choose a = 2 + w, where w = 3 Algorithm : Newton-Raphson Iteration Input: f(x)=x3−a, x0 =a/2, tolerance 10-8, maximum number of iterations100 Output: an approximation (a)1/3 within 10-8 or...

  • c++ Newton method for iteratively finding the root f(x) = 0. The equation is Where f(x)...

    c++ Newton method for iteratively finding the root f(x) = 0. The equation is Where f(x) is the function, f'(x) is the derivative of f9x), Write a C++ program to find root for the function of f(x). The function is on your C++ homework 2 for F(x) = x + 2x -10 You may have two functions, for example, float f(float x) float f=x*x-4; //any function equation return f; float prime(float x) float prime = 2 * x; //derivative of...

  • Newton's Method Derivation (20 pts) Derive Newton's method, also known as Newton- Raphson method, starting from...

    Newton's Method Derivation (20 pts) Derive Newton's method, also known as Newton- Raphson method, starting from Taylor Series. (a) Write the first order Taylor series expansion for f (x) about xo. We will call this polynomial To(x). Define your step as (xı - xo) (b) What kind of curve is To(x) (line, parabola, cubic, ...)? (c) Solve for the root of To(x). This will give you x1. If you're not sure what to do (d) Repeat the steps above but...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT