Question

Hi, I need help doing this. 3. Use the bisection MATLAB program to estimate the roots...

Hi, I need help doing this.

3. Use the bisection MATLAB program to estimate the roots of the function k(x) = x2 - 4, where x’s range is [-1, 3]. Include solutions for this method in the report.

Write a MATLAB program that uses the false-position method to estimate the roots of the function k(x) in problem#3. Include your m-file and solutions for this method in the report. In addition, submit your m-file separately.

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

Bisection Method in MATLAB

the code is as follows:

a=input('Enter function with right hand side zero:','s');

f=inline(a);

xl=input('Enter the first value of guess interval:') ;

xu=input('Enter the end value of guess interval:');

tol=input('Enter the allowed error:');

if f(xu)*f(xl)<0

else

    fprintf('The guess is incorrect! Enter new guesses\n');

    xl=input('Enter the first value of guess interval:\n') ;

    xu=input('Enter the end value of guess interval:\n');

end

for i=2:1000

xr=(xu+xl)/2;

if f(xu)*f(xr)<0

    xl=xr;

else

    xu=xr;

end

if f(xl)*f(xr)<0

    xu=xr;

else

    xl=xr;

end

xnew(1)=0;

xnew(i)=xr;

if abs((xnew(i)-xnew(i-1))/xnew(i))<tol,break,end

end

str = ['The required root of the equation is: ', num2str(xr), '']

For false position method the code is as follows:

clc

x0 = input('enter the value of x0 = ');

x1 = input('enter the value of x1 = ');

tolerance=input('inter the tolerance = ');

f =@(x) sin(2*pi*x)+ exp(1.2*x) + x - 2.5;

for i=0:inf

x2= x1 - (f(x1)* (x1-x0)/(f(x1)-f(x0)))

c = f(x2)

absolute_c= abs(c);

if absolute_c < tolerance

break

end

if f(x0)*c <0

x1=x2;

continue

else

x0=x2;

continue

end

end

i

Add a comment
Know the answer?
Add Answer to:
Hi, I need help doing this. 3. Use the bisection MATLAB program to estimate the roots...
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
  • 3. Use the bisection MATLAB program to estimate the roots of the function k(x) = x2...

    3. Use the bisection MATLAB program to estimate the roots of the function k(x) = x2 - 4, where x's range is [-1, 3). Include solutions for this method in the report. 4. Write a MATLAB program that uses the false-position method to estimate the roots of the function k(x) in problem#3. Include your m-file and solutions for this method in the report. In addition, submit your m-file separately.

  • #6 Write a Matlab program that finds numerically all the roots (or the zeros) of the...

    #6 Write a Matlab program that finds numerically all the roots (or the zeros) of the algebraic equation below in the interval 1.0 <=x<=3.0: sqrt(log(x^2+1))=x^2*sin(e^x)+2 Part a) Prompt the user to enter a positive integer number n, defined the range 2<=n<=15, and then verify if the number entered lies within the specifications. Your program must allow the user to reenter the number without the need to rerun the program. Part b) Create a user-defined function for the bisection method(see details...

  • 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...

  • 13. Write a MATLAB program to find all the roots of a given, twice continuously differentiable,...

    13. Write a MATLAB program to find all the roots of a given, twice continuously differentiable, function f e C2la,b]. on the given interval to find out where it Your program should first probe the function f(x) 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 [a,b;] over which the...

  • i need the answer to be on a MatLab window 1. Consider the following equation, which...

    i need the answer to be on a MatLab window 1. Consider the following equation, which represents the concentration (c, in mg/ml) of a drug in the bloodstream over time (t, in seconds). Assume we are interested in a concentration of c2 mg/ml C3te-0.4t A. Estimate the times at which the concentration is 2 mg/ml using a graphical method Be sure to show your plot(s). Hint: There are 2 real solutions B. Use MATLAB to apply the secant method (e.g....

  • 1. Of the four methods use to estimate the roots, which one appeared to be fastest...

    1. Of the four methods use to estimate the roots, which one appeared to be fastest (take the fewest iterations) to arrive at a solution: a)False-position method b)Bisection method c)Secant Method d)Newton’s Method e)They all took the same number of iterations 2.The Bisection and False-position method are: a)Interval (bracketing) methods b)Calculus-bases methods c)Secant methods d)Uses Ohm’s law 3.The Secant method is similar to Newton’s method except: a)for the use of an approximation for the tangent-line b)that two points (defining the...

  • Using MATLAB or FreeMat ---------------------------- Bisection Method and Accuracy of Rootfinding Consider the function f(0) =...

    Using MATLAB or FreeMat ---------------------------- Bisection Method and Accuracy of Rootfinding Consider the function f(0) = 3 cos 2r cos 4-2 cos Garcos 3r - 6 cos 2r sin 2r-5.03r +5/2. This function has exactly one root in the interval <I<1. Your assignment is to find this root accurately to 10 decimal places, if possible. Use MATLAB, which does all calculations in double precision, equivalent to about 16 decimal digits. You should use the Bisection Method as described below to...

  • 2) (15 points) a) Determine the roots of f(x)=-12 – 21x +18r? - 2,75x' graphically. In...

    2) (15 points) a) Determine the roots of f(x)=-12 – 21x +18r? - 2,75x' graphically. In addition, determine the first root of the function with b) bisection and c) false-position. For (b) and (c), use initial guesses of x, =-land x, = 0, and a stopping criterion of 1%. 3) (25 points) Determine the highest real root of f(x) = 2x – 11,7x² +17,7x-5 a) Graphically, b) Fixed-point iteration method (three iterations, x, = 3) c) Newton-Raphson method (three iterations,...

  • im having trouble doing this problem with matlab code and we can not use ode45 in...

    im having trouble doing this problem with matlab code and we can not use ode45 in our code unfortunitely. thank you! T L =undeformed length k =stiffness om The mass m is suspended from an elastic cord with an extensional stiffness k and undeformed length L. If the mass is released from rest at 0 = 60° with the cord unstretched, find the length r of the cord when the position =0 is reached for the first time. The differential...

  • Use matlab or python please! 3. Estimate the order of accuracy by doing a least squares...

    Use matlab or python please! 3. Estimate the order of accuracy by doing a least squares fit of the form log(E(H))- Kplog(H) to determine K and p based on the 500 data points. Recall that this can be done by solving the following linear system in the least squares sense: 1 log(Hi) 1 log(H2) 1 Гкі log(E(Hi)) | log(E(H2)) 1 log(Hsoo log(E(H,00 NOTE: "In the least-squares sense means that one should solve the rectangular system Ax = b, by solving...

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