{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# numerical - COMPUTER SCIENCE 349A ASSIGNMENT#4 DUE MONDAY...

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

COMPUTER SCIENCE 349A ASSIGNMENT #4 DUE MONDAY FEBRUARY 6, 2012 (in class) 1. (a) Write a MATLAB function M-file for Newton’s method corresponding to the following pseudocode: converge to failed output while end root x i i if end exit root x if root i output x f x f x root while i heading output i ) ε , , x newton ( oot function r + < = 0 0 0 0 0 0 1 / 1 , ) ( / ) ( imax 1 imax ε Use the following (or similar) MATLAB print statements. fprintf ( ‘ iteration approximation \n’) fprintf ( ‘ %6.0f ‘, i ), fprintf ( ‘%18.10f \n’, root ) fprintf ( ‘ failed to converge in %g ‘, imax ), fprintf (‘ iterations \n ‘ ) HAND IN a copy of your MATLAB M-file. (b) An oscillating current in an electric circuit is described by ) 2 cos( 9 t e i t π = , where t is in seconds. Determine all positive values of t such that i = 3.5 . The solution to this problem can be posed as determining the positive zeros of a function ) ( x f . Careful analysis of the graph of the function ) ( x f shows that ) ( x f has only one positive zero, and it is in the interval [0, 1]. Use the MATLAB function M-file newton with 6 0 10 , 1 . 0 = = ε x and imax = 20 to solve the above problem. Note that in MATLAB, 6 10 is 1e-6 (not 10e-6). Note. You will need to write MATLAB function M-files with headers something like

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

View Full Document