Question

1. 10 points Find the positive solution of the equation cosx=0.3x (ie. the positive root of cosx-03x=0) using the bisection method with [0, 2] chosen as the initial interval. (a) Perform the first 3 iterations by hand and calculate the relative error for the last iteration; (b) Write a MATLAB code to find the root. The solution will be considered satisfactory if its relative error is smaller than 1%. Plot the relative error vs the number of iterations (must be computer generated plot!). c) Attach your MATLAB code with your submission.

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

(a) The function is, f(x)=cos x -0.3x The interval of x is [0,2]. f(0)=cos(0) -0.3x0)=1 f(2)= cos(2)-0.3x2 =-1.016 Find the s

Again Repeat Step 2: Determine whether the true solution lies between [1,1.25] or [1.25,1.5] by determining the value of the

ſ check for the condition if fa* fn<0 b=xn; else a=xn; end end end it=1:1:n; plot(it,rei) xlabel (Number of iterations) yla

_---------------------------------------------------------------

% MATLAB code to find the zero value of the function

fx=@(x) cos(x)-0.3*x;

fzero(fx,1.25)

-----------------------------------------------------------------------------

% define the anonymous function f

f=@(x) cos(x)-0.3*x;

% define the interval a b , iterations, tolerance

a=1;b=2;imax=20;re=1;

% determine the values of the function at x=a,x=b

fa=f(a);fb=f(b);

if fa*fb>0

    disp('error: function has the same sign at points a and b')

else

    disp('iteration     a           b             x              f(x)           relative')

    for i=1:imax

% determine xn

        xn=(a+b)/2;

        rei(i)=abs((b-a)*100/a);

        fn=f(xn);

        fprintf('%3i    %11.6f   %11.6f    %11.6f    %11.6f     %11.6f\n',i,a,b,xn,fn,rei(i))

        if fn==0

            fprintf('exact solution of x=%11.6f is found',xn)

            break

        end

       

        if rei(i)<re

            n=i;

            break

        end

       

        if i==imax

            fprintf('solution cannot be determined in max iterations \n')

            break

        end

% check for the condition

if fa*fn<0

            b=xn;

        else

            a=xn;

        end

    end

end

it=1:1:n;

plot(it,rei)

xlabel ('Number of iterations')

ylabel (' Percentage tolerance')

Add a comment
Know the answer?
Add Answer to:
1. 10 points Find the positive solution of the equation cosx=0.3x (ie. the positive root of...
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
  • Write a Matlab function for: 1. Root Finding: Calculate the root of the equation f(x)=x^3 −5x^2...

    Write a Matlab function for: 1. Root Finding: Calculate the root of the equation f(x)=x^3 −5x^2 +3x−7 Calculate the accuracy of the solution to 1 × 10−10. Find the number of iterations required to achieve this accuracy. Compute the root of the equation with the bisection method. Your program should output the following lines: • Bisection Method: Method converged to root X after Y iterations with a relative error of Z.

  • Need solution for question 5.6 using python? tation to within e, 5.11 Determine the real root...

    Need solution for question 5.6 using python? tation to within e, 5.11 Determine the real root of x 80: (a) analytically and (b) with the false-position method to within e, = 2.5%. Use initial guesses of 2.0 and 5.0. Compute the estimated error Ea and the true error after each 1.0% teration 5.2 Determine the real root of (x) 5r - 5x2 + 6r -2 (a) Graphically (b) Using bisection to locate the root. Employ initial guesses of 5.12 Given...

  • (la) Determine the root of the x – ez* + 5 = 0 using the Newton-Raphson...

    (la) Determine the root of the x – ez* + 5 = 0 using the Newton-Raphson method with equation initial guess of xo = 1. Perform the computation until the percentage error is less than 0.03%. (1b) Employ bisection method to determine the root of the f(x)=x* – 3x + 7 =0) using equation two initial guesses of x; =-2.1 and x;, =-1.8 . Perform three iterations and calculate the approximate relative error for the third iteration. What is the...

  • please show answer in full with explanation, also show matlab 1. Consider the function f(x)2.753 +18r2 21 12 a) Plot...

    please show answer in full with explanation, also show matlab 1. Consider the function f(x)2.753 +18r2 21 12 a) Plot the graph of f(x) in MATLAB and find all the roots of the function f(x) graphically. Provide the code and the plot you obtained. b) Compute by hand the first root of the function with the bisection method, on the interval -1; 0) for a stopping criterion of 1% c) How many iterations on the interval -1, 0 are needed...

  • Using the Bisection method, find an approximate root of the equation sin(x)=1/x that lies between x=1...

    Using the Bisection method, find an approximate root of the equation sin(x)=1/x that lies between x=1 and x=1.5 (in radians). Compute upto 5 iterations. Determine the approximate error in each iteration. Give the final answer in a tabular form.

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

  • need a matlab script to show this 1. Apply the bisection routine bisect to find the...

    need a matlab script to show this 1. Apply the bisection routine bisect to find the root of the function f(x)= -1.1 starting from the interval [0,21 (that is, a 0 and b 2), with atol 1.c-8. Gopy 3.6. Exercises 59 required? Does the iteration count match the expectations. (a) How many iterations are based on our convergence analysis? (b) What is the resulting absolute error? Could this absolute error he predicted by our con- vergence analysis? 1. Apply the...

  • 1. (30 points) Write a MATLAB code to perform the Secant method of root finding. Write...

    1. (30 points) Write a MATLAB code to perform the Secant method of root finding. Write the code to output the table used in class showing the iteration, root estimate r,, function value at the root estimate f(r,), and the approximate error. Show that the code works by using it to re-solve Homework Assignment II Problem 2c. Which asked you to find the positive root of f(r) r,1.0 and 6 10-6, have the code iterate until the approximate error is...

  • 45-3. Modify the code used in Example 4 to find the root only at f(x)<0.01 using...

    45-3. Modify the code used in Example 4 to find the root only at f(x)<0.01 using Newton-Rephson Method without showing any iteration. Also find the root of equation, f(x) = x 9-3x -10, take initial guess, Xo=2 العقدة College of 9:05 mybb.qu.edu.ca Numerical Methods (Lab.) GENG 300 Summer 2020 5.1.2 Open Methods - Newton-Raphson Method f(x) *1+1 = x; - Matlab Code Example:4 function mynewtraph.t1.x0,-) XXO for ilin x - x - x)/1 x) disp 1 x) <0.01 break end...

  • Submission Items: (1) A Word document in which you: a. Describe in brief the problem you...

    Submission Items: (1) A Word document in which you: a. Describe in brief the problem you are solving and the numerical method used. b. Snapshot of the output, when you run the program for the conditions mentioned in the questions. c. Discuss your results. (2) MATLAB code (m) file() Question 1: [10 points) Write a MATLAB function that calculates the approximate value of arctan(x) using the Maclaurin series approximation: arctan(x) = x- + +... The function should accept 3 parameters:...

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