matlab数学代写:Math 238 Matlab Project

Math 238 Matlab Project
Due Date: Wednesday August 2, 2017 in class

Instructions:

  1. (a)  Submit your PRINTED project in class by the due date. Ensure the names of each person

    in the group is included.

  2. (b)  No more than 4 people may be in a group! However, working in a group is not required.
  3. (c)  The document must be neat and legible. You must use complete sentences.
  4. (d)  The project grade will be based on the presentation of the document, relevance to the course material, and quality of the discussion. You MUST use MATLAB to complete the pro ject.

In this project we will use MATLAB to analyze the solution to the Initial Value Problem

dy=x2−y, y(0)=0 (IVP) dx

Euler’s Approximation Method
Use ”Eulers.m” in the MATLAB folder on Blackboard to find an approximation of the solution to the above differential equation at xn = 1.

  1. (a)  Run the script ”Eulers.m” with the correct initial values x0 and y0 based on the IVP above to make sure it works.
  2. (b)  It may be necessary to change the folder so that ”Eulers.m” will run. If the computer prompts you to do this use click ”add to path” or ”change folder”.
  3. (c)  Run the script ”Eulers.m” with five different h values and record the results for each:

    h = 1, 0.1, 0.01, 0.001, 0.0001

  4. (d)  Once you run the script ”Eulers.m” you should get one graph and it will be necessary to

    save these for each h tested.

  5. (e)  Solve the initial value problem by hand, remember to determine the value of constant C in the solution. The find the value of y(1) rounded to four decimal places. It is not necessary to type this portion of the assignment but you should show you work for it.
  6. (f)  Find the relative errors for all five h′s above:
    y(1) − yapprox(1)

    (That is, subtract the approximation given by each h from the value y(1) you computed above and then divide the result by the value y(1) you computed above and then find its absolute value. This is a measure of how close our approximation is to the computed answer of y(1).

  7. (g)  Discuss your findings:
    (a) What happens to relative error as h gets smaller?
    (b) Is this a good method to approximate solutions to first order differential equations? (c) Is this method more practical than computing by hand?
    (d) How do the graphs change for each h?

error = y(1)

Note: When testing prpograms, it is common practice to test its efficacy on a problem with a known outcome, to see how accurate the program is. Therefor, yes it is true we could just solve this O.D.E by hand, however we are using information we know to determine how effective this program is. Further note that there are some first order O.D.E.s whose solution cannot be computed by hand, in which case this approximation method-as well as other more sophisticated techniques- is the best we can do. One such O.D.E. is

dy =ex2 , y(1)=1 dx

because there is no closed-form solution to the integral of the right hand side of the differential equation(meaning we cannot come up an anti-derivative that can be expressed).

Page 2