Homework 23 – Heuns Method with Iteration

$24.99 $18.99

Rules / Suggestions The following rules apply to ALL of our Algorithm Development Problems. These are helpful when you are testing your function and we will grade you on them. You must use the correct function name. Check number of function inputs and outputs (vector and scalar inputs) Clear variables in workspace prior to running…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)

Rules / Suggestions

The following rules apply to ALL of our Algorithm Development Problems. These are helpful when you are testing your function and we will grade you on them.

  1. You must use the correct function name.

  1. Check number of function inputs and outputs (vector and scalar inputs)

  1. Clear variables in workspace prior to running tests

  1. If variable names are not given, use appropriate and consistent names

  1. Check function for all possible number of inputs (use nargin during devel-opment to catch errors)

  2. Run algorithm for at least 2 different input values

  1. Check algorithm does not produce extraneous output

  1. Comment code for readability

Instructions

Write a general MATLAB function for solving differential equations using Heun’s Method with iteration.

The first line of your MATLAB function should look like:

function [t,y] = Heun(dydt,tspan,y0,h,es,maxit)

Where the function finds the numerical solution to the differential equation dydt, over the span tspan, with an initial condition y0, and step size h. The variables es and maxit should be optional and default to 0.001 and 50 if a user does not specify values for those inputs. es and maxit refer to the stopping criterion and maximum number of iterations, respectively, for iterations involving the predictor-corrector.

Your matlab function should also include the following:

  • An ability to function if tspan is a little out of whack with h. For example, the program should work correctly if a user says tspan = [0 2.1] and h = 0.2 without throwing an error.

  • When run the function should display a plot of the t and y variables.

  • The input dydt should work when the user inputs the differential equation as an anonymous function. Do not worry about symbolic equations!

1

Homework 23 - Heuns Method with Iteration
$24.99 $18.99