CSS 455     Scientific Programming    C. Jackels

Winter 2012                           January 15, 2011

 

Homework Assignment #2

 

Written Homework Assignment. These are to be worked individually.   Each student is to hand in her/his own assignment at the Catalyst Drop Box the HW2.  However, you are expected to communicate with your partner, discuss strategies for solving the problems, etc.  In the end, you are to solve it yourself, and your solution should not be identical to your partner’s.  What is not allowed is for you to jointly solve the set and turn in your collaborative solution.

 

The following are to be completed and handed in electronically in final form by Saturday, January 21, 2012, at 11:59 PM.   The assignment will be accepted up to 24 hours late for 75% credit and up to 48 hrs late for 50% credit.  For each problem hand in whatever is needed for me to understand your work.  This should certainly include a program listing (m-file), the relevant output, and any notes needed to understand your approach.  The notes should all be gathered in one Word document.  The m-files and outputs can either be cut into the Word document or submitted separately as part of the *zip archive.  The m-files and outputs, if submitted separately, need to have file names that identify them as a particular homework problem.  Your name should be on the Word document and in the comments of the code..

 

These algorithms are all described in Ch 2 of Turner.  In some cases, he provides code; in others, I have provided it in the slides.  Feel free to make use of Turner and my examples in writing your own code for this problem.  Be sure to note in comments where the algorithms and/or code came from.

 

 

Problem 2.1    This is a problem based on some of the work you are doing in MP1 and the material covered in chapter 2 of Turner.    It’s purpose is to explore the convergence of the different algorithms in that chapter. 

 

Given the following function: 

Write a matlab script and associated functions that solve this equation for l  with the following parameters: L= 300ft and s=40 ft.  The main script should call functions that solve it in turn by: a) iteration, b) secant method, c) Newton method , d) bisection method, and e) built-in function fzero.  The script should generate output that shows a table of the algorithm name, the number of iterations, and the final value found for the root.

 

In methods with a single starting point needed, use a guess of 270.  In those such as secant and bisection that need two points, use 270 & 300.  Use a convergence tolerance (absolute) of 1.E-10 (10 decimal places) for each method.  Print out your final table with  long (12 decimal place) format so that it demonstrates whether or not it is converged to the desired tolerance.

 

I suggest writing a single main script, with the various methods and functions in either functions, subfunctions, nested functions or in-line functions.