examplehw - Math 5620 Assignment #1 Name: Due: January 14,...

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

View Full Document Right Arrow Icon
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

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

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5

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

View Full DocumentRight Arrow Icon
Background image of page 6
Background image of page 7

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

View Full DocumentRight Arrow Icon
Background image of page 8
Background image of page 9

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

View Full DocumentRight Arrow Icon
Background image of page 10
Background image of page 11

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

View Full DocumentRight Arrow Icon
Background image of page 12
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Math 5620 Assignment #1 Name: Due: January 14, 2010 ID# Directions: Complete all problems using the instructions in the course syllabus as a guideline. Also1 your solutions should be written up in detail as per the partial example solution provided on the course web page. The assignment sheet(s) must appear first in your solutions. Start your solutions on the next page after the assignment sheet(s). Staple all assignments together in the upper left hand corner. If your solutions include hand written work, leave room in the solution between typed work or coding files to include the work. Make sure your hand written work is legible. See the partial example solution for an example of hand written work included in a solution. Problem 1: Compute the general solutions of the following ordinary differential equations. (3. y” + 7y 2 sinflr) Show all steps in the calculations associated with the solution methods. Hint: You will need to use a method like undetermined coefficients or variation of parameters in part c. of this problem. Problem 2: For a spring—mass system the position of the mass as a function of time is of interest. Suppose that we are given the following ODE as a means of modeling the motion of an object in a spring mas‘s system. W” + 621’ + ky = f (t) where m is the mass of the object moving around in the system, c is a damping factor, and k is the linear spring constant. The function f (t) can be thought of as a input or forcing function on the system. Show that the homogeneous solution of this general equation is W) = 616“ + 626” where —c + r1 = and i _c _ m 2m You do not need to solve the problem. You should plug the proposed solution(s) into the differential equation. Problem 3: For the differential equation given in Problem 2, set m 2 11 c = 0, k = 1, and f (t) = 0. Determine the general solution of the differential equation in this case. If the boundary conditions, y(0) = 0 and y(1) = O are given, use these to determine possible particular solutions for the differential equation that satisfy the two auxiliary boundary conditions. Is there only one solution for the problem? Explain your answer. Problem 4: Implement the explicit Euler method for the approximate solution of initial value problems of the form 9’ = fits) with initial condition Mtg) = yo where t is the independent variable problem and y = y(t) is an unknown function. Test the code you have written on the following initial value problem y’ : ~1Oy with initial condition y(0) = 3.8 on [0,1] and compute the absolute and relative error in the approximate solution for the step size :5. where h = 1/32. Problem 5: Test the implementation of the explicit euler method used for Problem 4 on the following problems. a. y’ = W43} on the interval [1, 4] with y(1) : 2. b. y’ = 7r 3; on the interval [0, 5] with y(0) = —1. Graph each solution against the solution you would get using the results from Problem 1. Use it = 0.1 in each of the problems cases. Problem 6: Find a web site on the internet that discusses the definitions of norms and the equiv— alence of norms. Write a short discussion related to the equivalence of norms in finite dimensional ' vector spaces. Be sure to reference any web sites you use in this discussion. 1 Problem 1: Compute Analytic Solution of Differential Equations Problem Description: Compute the general solutions of the following ordinary differential equa— tions. I a. y = —4y h fi=ry c. y” + 7y 2 side) Hint: You will need to use a method like undetermined coefficients or variation of parameters in part c of this problem. Problem Solution: The solution for this problem is to produce functions that satisfy of the ordinary differential equations given in the three parts This work will be done by hand as follows. a. For if = #4:; separation of variables will be used as follows: b. For y’=7ry separation of variables will be used as follows: ......and so on for the problems ...... .. 2 Problem 2: Implementation of the Explicit Euler Method ......Solution for this problem . ......... .. .... ..Solution must start at the top of a page .... ..The space for the next problem is omitted. You will need to include all solutions ' and start each problem solution at the top of a page. .......... .. 4 Problem 4: Implementation of the Explicit Euler Method Problem Description Implement the explicit Euler method for the approximate solution of initial value problems of the form y’ = ray) with initial condition 9(0) 2 yo where t is the independent variable problem and y I y(t) is an unknown function. Test the code you have written on the following initial value problem 11’ = —10y with initial condition y(0) = 3.8 on [0,1] and compute the absolute and relative error in the approximate solution for the step size h where h = 1/32. Problem Solution: The solution of this problem involves the implementation of the Explicit Euler Method for the solution of the general Initial Value Problem (IVP), y’ =f(t,y) with y(0) 2 yo. The code used to implement the method will be tested on the example lVP. The initial value problem used in this example will be if = -10y with ya = 3.8 The code used in the solution of the problem is presented in the next section, followed by results obtained. The last section of this solution presents conclusions and a summary of the solution. Computer Code Used to Implement the Method In this section the code that was developed to solve this problem is presented. The first section presents the driver code written in Fortran to run the subroutines and do all of the calculations. Programming Language and Compiler Used The code used to write up a solution for this problem was Fortran 77 based using the Sun Microsystems Inc. Fortran Compiler Suite. The code could be compiled using F90 compilers and other fortran compilers. No special code or compiler options were used in testing the code. Main Driver for the Implementation of the Explicit Euler Method Author: Joe Koebbe Date: December 21, 2010 Class: Math 5620 Numerical Methods for Differential Equations Assignment: This program was written to complete Problem 1 on the first assignment that asked for an implementation of the Explicit Euler method for the solution of an initial value problem 00000000 c involving a single first order equation and initial value c specified by an unknown user. program main real t(1025), y(1025), yexact(1025), yabserr(1025), yrelerr(1025) real t0, tf, dt, yO inmgM‘Ln$mpm n external f1, flSolution this subroutine provides an initialization of any parameters needed by the main subroutine implementing the explicit euler method. 0000 nsteps = 8 print *, ’Input the number of steps: (e.g, nsteps=8)’ read(5,*) nsteps if(nsteps .lt. 8) nsteps = 8 t0 = 0.0 tf = 1.0 dt : ( tf “ t0 ) / float(nsteps) call init(t0, tf, dt, nsteps) this call will produce two arrays defining a set of ordered pairs that approximate the solution of the initial value problem. 0000 y0 = 3.8 call explicitEuler(fl, t0, ti, yO, dt, t, y) c compute an array containing exact values for the initial value problem call exactSolution(fisolution, t, yexact, nsteps) c compute an array of values that contains the absolute error at each point call abserr(y, yexact, nsteps, yabserr) call relerr(y, yexact, nsteps, yrelerr) c c we will want to output the results of the calculations c call outputResults(t, y, yexact, yabserr, yrelerr, nsteps) c stop and Initialization and Setup Code 000000 0000 The code in this section presents how the parameters in the initial value problem were initialized and stored. 'In addition, a routine that computes values of the exact solution for the initial value problem used to test the code is presented. subroutines used by the main program subrOutine: init purpose: the ivp initialize the data for the approximate solution of the initial value problem (IVP) subroutine init(t0, tf, dt, us) ns=(tf—t0)/dt return end following subrOutine will provide the user with the exact solution of given a solution exists. function flsolutionCX'val, yval) flSolution = 3.8 * exp(-10.0*xval) print *,xval return end Subroutine used to Implement the Explicit Euler Method C The code presented here includes the explicit Euler solution code along with an example of how the fercing function f (t, y) in the difierential equation yf : is implemented so that the algorithm will work. c subroutine: explicitEulerO C 000000000 purpose: to compute an approximate solution of an initial value problem (IVP) using an implementation of the explicit euler method. input: f — this is the right hand side function in the initial value value problem defined by y’ = f(t,y) YCtO) = y0 to ~ the initial value of the independent variable, t. tf - the final value of the independent variable, t. yO — the initial value of the dependent variable, y. dt — the initial step size to take in the explicit euler method output: t — an array containing the values of the independent variables produced in the explicit euler method. y — an array containing the values of the dependent variable approximations produced by the explicit euler method. assumptions: 1. For this implementation, the step size is assumed to be constant. This means the subroutine will take a fixed number of steps in the computation of the approximation. 2. The function, f, must be provided by the calling routine and is assumed to be a continuous function on the specified interval. OOOOOOODOOOOOUDOO subroutine explicitEuler(f, t0, tf, yO, dt, t, y) real*8 t(101), yClOl) external f nsteps ( tf - t0 ) / dt t(1) = t0 y(1) = y0 do.10 i=2,nsteps+1 tCi) = t(i—1) + dt y(i) = y(i-1) - dt * 10.0 * yCi-l) 10 continue return end C c external function that can be used to test the method 0 function f1(xval,yval) f1 = ~10.0 * yval return end Error Computation Routines for the Absolute and Relative Errors The absolute error and relative error were computed by the following two routines. C c routine for computing the pointwise absolute error in the approximation C subroutine abserr(ya, ye, ns, yabserr) real ya(1025), ye(1025), yabserr(1025) do 10 i=1,ns+l yabserr(i) = abs( ya(i) -ye(i) ) 10 continue return end c c routine for computing the pointwise relative error in the approximation C subroutine relerr(ya, ye, ns, yrelerr) real ya(1025), ye(1025), yrelerr(1025) integer ns do 10 i=1,ns+1 yrelerrCi) = abs( ya(i) - ye(i) ) / ye(i) 10 continue return end I/O and Other Subroutines in the Problem The following simple routine was used to output results including the exact solution, the approxi— mate solution and the absolute and relative errors in the approximate solution relative to the exact solution. To get the output into a file, the following command was used at a Unix prompt. Zavater a.-out > out ut.out P where the aout file was created by the compilation of the code created for the problem. c c routine for outputting the results from the approximation method. c subroutine outputResults(t, y, yexact, yae, yre, ns) real t(1025), y(1025), yexact(1025), yae(1025), yre(1025) do 10 i=1,ns+1 print *, i, tCi), y(i), yexact(i), yae(i), yre(i) 10 continue return end Results The results for one run of the code as requested in the problem with h 2 1/32 are presented in this section. rI‘he following table shows the results of the approximation of the solution of the solution of the test initial value problem for various constant step sizes. 0. 3.12500E—02 6.25000E—02 9.37500E—02 0.125000 0.156250 0.187500 0.218750 0.250000 0.281250 0.312500 0.343750 0.375000 0.406250 0.437500 0.468750 0.500000 0.531250 0.562500 0.593750 0.625000 0.656250 0.687500 0.718750 0.750000 0.781250 0.812500 0.843750 0.875000 0.906250 0.937500 0.968750 1.000000 Conclusions 3.80000 2.61250 1.79609 1.23481 0.848935 0.583643 0.401254 0.275862 0.189655 0.130388 8.96418E—02 6.16287E—02 4.23698E—02 2.91292E—02 2.00263E—02 1.37681E—02 9.46557E—03 6.50758E—03 4.47396E—03 3.07585E—03 2.11465E—03 1.45382E~03 9.99501E-04 6.87157E—04 4.72420E—04 3.24789E—04 2.23292E—04 1.53513E—04 1.05541E—04 7.25591E—05 498844305 3.42955E—05 2.35782E—05 3.80000 2.78014 2.03399 1.48810 1.08872 0.796523 0.582749 0.426348 0.311923 0.228208 0.166960 0.122151 8.93674E—02 6.53826E—02 4.78349E—02 3.49968E—02 2.56042E—02 1.87324E—02 1.37049E—02 1.00267E—02 7.33573E—03 5.36693E—03 3.92653E—03 2.87271E-03 2.10172E—03 1.53765E—03 1.12497E—03 8.23046E—04 6.02153E-04 4.40545E—04 3.22309E—04 2.35806E—04 1.72520E-04 0 — 0 0.167639 6.02989E—02 0.237900 0.253287 0.239783 0.212881 0.181495 0.150486 0.122268 9.78197E—02 7.73185E—02 6.05221E—02 4.69977E—02 3.62534E-02 2.78086E—02 2.12287E—02 1.61386E—02 1.22249E—02 9.23098E—03 6.95090E—03 5.22108E—03 3.91311E—03 2.9270313—03 2.18555E—03 1.62930E—03 1.21286E—03 9.01678E—04 6.69532E-04 4.96613E—04 3.67985E—04 2.72425E—04 2.01511E—04 1.48942E—04 0.116962 0.170208 0.220244 0.267262 0.311446 0.352965 0.391980 0.428643 0.463095 0.495470 0.525893 0.554481 0.581345 0.606589 0.630312 0.652604 0.673551 0.693236 0.711733 0.729115 0.745449 0.760799 0.775222 0.788776 0.801513 0.813481 0.824728 0.835297 0.845228 0.854561 0.863331 In this problem, the Explicit Euler method was implemented and tested on a simple initial value problem. The exact solution was known which allowed for the comparison of the approximation with the exact solution. The graphics and the values generated were used to show that on a finite interval1 the approximate solution seemed to converge to the exact solution and the results also indicated that the error converged linearly with the size of the steps taken in the generation of the approximate solution. .... ..and so on for the problems ...
View Full Document

This note was uploaded on 01/11/2011 for the course MATH 5620 taught by Professor Koebbe,j during the Spring '08 term at Utah State University.

Page1 / 12

examplehw - Math 5620 Assignment #1 Name: Due: January 14,...

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

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