Lab10 - Riti Gupta/20249537 Section 22/Lab10 1.a.) >...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Riti Gupta/20249537 Section 22/Lab10 1.a.) >> fplot(@(x) 2*sin(2*x^3)+1.25*x-0.5,[-10 10 -10 10]) b.) A = @(x) 2*sin(2*x^3)+1.25*x-0.5 B = [] for i= -3:.1:3 C = fzero(A, i); B = [B, C]; end roots: 3072, 1.2258, 1.4095, 1.7330, 1.7921. 2. function [root_aprox]=bisection(fh1, x, eps, iter) x1=x(1); x2=x(2); m=(x1+x2)/2; for i=1:iter while abs(fh1(m)) > eps m=(x1+x2)/2; if fh1(m)*fh1(x1)<0 x2=m; m=(x1+x2)/2; m fh1(m) elseif fh1(m)*fh1(x2)<0 x1=m; m=(x1+x2)/2; m fh1(m) end -10 -8 -6 -4 -2 0 2 4 6 8 10 -10 -8 -6 -4 -2 0 2 4 6 8 10
Background image of page 1

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

View Full DocumentRight Arrow Icon
end end end >> fh1=@(x) 2*sin(2*x^3)+1.25*x-0.5 fh1 = @(x)2*sin(2*x^3)+1.25*x-0.5 >> bisection(fh1, [0,2],.0001,100) m = 0.5000 ans = 0.6198 m = 0.2500 ans = -0.1250 m = 0.3750 ans = 0.1793 m = 0.3125 ans = 0.0126 m = 0.2813 ans = -0.0595
Background image of page 2
0.2969 ans = -0.0243 m = 0.3047 ans = -0.0061 m = 0.3086 ans = 0.0032 m = 0.3066 ans = -0.0014 m = 0.3076 ans = 8.9293e-004 m = 0.3071 ans = -2.7007e-004 m =
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/01/2009 for the course ENGIN 7 taught by Professor Horowitz during the Spring '08 term at University of California, Berkeley.

Page1 / 6

Lab10 - Riti Gupta/20249537 Section 22/Lab10 1.a.) &gt;...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online