Explore BrainMass
Share

# Non-linear scalar equation(Matlab only)

This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

All the roots of the scalar equation

x-4sin(2x)-3=0,

are to be determined with at least 10 accurate digits, (n accurate digits is equivalent to a relative error smaller than 0.5 x 10^-n)

1) Using Matlab, plot f(x)=x-4sin(2x)-3. All the zero crossings should be in the plot. How many are there?

2) Write a program in Matlab that computes the roots using the fixed point iteration x_n+1=-sin(2x_n) +(5/4)x_n -(3/4). Use a stopping criterium that gives an answer with ten correct digits. Find, empirically which of the roots that can be found with the above iteration. Give a theoretical explanation.

3) Write a program using Matlab that computes the roots with Newton's method (with ten correct digits). As a rule of thumb the number of correct digits are doubled every Newton iteration. Can you see this in your results?

4) Now you will compare the convergence properties of the 2 methods. Choose a root where both methods work and use the same initial guess. Plot the error absolute value of ( x_n) -(x^*) as a function of the number of iterates n. Use semilogy to get a logarithmic scale on the y axis. Here x^* is a very accurate approximation, say 15 digits, that you have to compute before you can compute the error. From your figure you should be able to see how much faster Newton's method converges. Another way to quantify how fast a method converged is the rate of convergence. The rate of convergence states how much smaller the error e_n+1 is compared to e_n. Precisely, the rate of convergence is given by the largest number p (often an integer) such that the fraction (e_n+1)/e^p_n converges to a non zero number when n becomes large. Plot (as a function of n) (e_n+1)/e^p_n, with p=1,2,3 for both methods and decide if the methods are linearly, quadratically, or cubically convergent.

5) Write a function, with calling sequence function r=bisect(f,a,b,tol) that finds a root r of f in the interval [a,b] to within tolerance tol, if one exists, and prints an error message otherwise. Use this function for the equation above.