{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Homework 1

# Homework 1 - >>%This program uses the Bisection Method...

This preview shows pages 1–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: >> %This program uses the Bisection Method to find the roots of f% >> a=-2; >> b=-1; >> %a and b is the interval within which we are confined% >> f = inline('x^4-2*x^3-4*x^2+4*x+4') f = Inline function: f(x) = x^4-2*x^3-4*x^2+4*x+4 >> max=8; %Maximum number of interations% >> i=1; >> a_1 = f(a); >> while i < max p= (a+b)/2 b_1= f(p); if isequal(b_1, 0) display('We found the root') p end i = i +1; if a_1*b_1>0 a=p; a_1=b_1; else b=p; end end p =-1.50000000000000 p =-1.25000000000000 p =-1.37500000000000 p =-1.43750000000000 p =-1.40625000000000 p =-1.42187500000000 p =-1.41406250000000 >> %This program uses the Bisection Method to find the roots of f% >> a=0; >> b=2; %a and b make up the interval we are working with% >> f = inline('x^4-2*x^3-4*x^2+4*x+4') f = Inline function: f(x) = x^4-2*x^3-4*x^2+4*x+4 >> max=9; >> %Maximum number of interations% >> i=1;a_1 = f(a); >> while i < max p= (a+b)/2 b_1= f(p); if isequal(b_1, 0) display('We found the root') p end i = i +1; if a_1*b_1>0 a=p; a_1=b_1;...
View Full Document

{[ snackBarMessage ]}

### Page1 / 8

Homework 1 - >>%This program uses the Bisection Method...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online