Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3 MATH:3800/CS:3700 1. Use bisection to find the solution of x = 2 sin x closest to x = /2. Use = 106 . What

3 MATH:3800/CS:3700 1. Use bisection to find the solution of x = 2 sin x closest to x = /2. Use = 106 . What is the initial interval [a, b] that you use? Report the computed solution. Estimate its error by computing x 2 sin x at the computed solution. You can use the posted code bisect.m. 2. From the solution estimate computed in Q1, can you tell if the fixed point iteration xn+1 = 2 sin xn will converge to a solution? If you think it does converge, at what rate do you expect it will converge? Answer these questions for the iteration xn+1 = 2(xn sin xn ). Using the solution estimate from Q1, use one of these iterations to compute (and report) a solution estimate that is accurate to 10 digits. 3. Use Newton's method to solve x = 2 sin x using x0 = /2 as the starting guess. Report the solution you obtain, the number of iterations, and the value of x 2 sin x. 4. There is a solution of x = tan x with x 3/2. Solve this equation numerically by any suitable method discussed in class. Report your solution, the method you used, the stopping criterion you used, any code you used, and the accuracy of the result (say, by reporting x tan x). You may not use fsolve or any other outside or built-in solvers for this problem. 1 function dfdx = badcode(f,x,h) % function dfdx = badcode(f,x,h) % % Returns the centered-difference approximation % f(x+h)-f(x-h) % ------------% 2h % to f'(x). return f(x+h) - f(x-h) / 2*h; function [x,iter,xs] = bisect(func,a,b,eps,trace) % function [x,iter,x] = bisect(func,a,b,eps,trace) % Solves func(X) = 0 by bisection % Needs func(a) & func(b) to have opposite signs % eps is the tolerance for |b-a| % If trace is non-zero, trace execution % iter is the number of iterations used fa = func(a); fb = func(b); if ( fa == 0.0 ) x = a; return elseif ( fb == 0.0 ) x = b; return elseif ( (fa > 0.0 & fb > 0.0) | (fa < 0.0 & fb < 0.0 ) ) fprintf('bisect: Error: signs of func(a) and func(b) are the same\ '); return end xs = a; iter = 0; while abs(b-a) > eps if trace fprintf('Iter # %d: a = %20.15g, f(a) = %10.6g, b = %20.15g, f(b) = %10.6g\ ', ... iter,a,fa,b,fb); end c = a + 0.5*(b-a); fc = func(c); if ( fc == 0.0 ) x = c; return end if ( (fa > 0.0 & fc > 0.0) | (fa < 0.0 & fc < 0.0) ) % new interval is [c,b] a = c; fa = fc; else % new interval is [a,c] b = c; fb = fc; end iter = iter+1; if trace xs = [xs,c]; end end x = a+0.5*(b-a); \f

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Real Analysis

Authors: Robert G. Bartle, Donald R. Sherbert

4th edition

471433314, 978-1118135853, 1118135857, 978-1118135860, 1118135865, 978-0471433316

More Books

Students also viewed these Mathematics questions