Numerical Applications to Differential Equations
Numerical Applications to Differential Equations MA 302
Popular in Course
Popular in Mathematics (M)
This 7 page Class Notes was uploaded by Braeden Lind on Thursday October 15, 2015. The Class Notes belongs to MA 302 at North Carolina State University taught by Staff in Fall. Since its upload, it has received 8 views. For similar materials see /class/223720/ma-302-north-carolina-state-university in Mathematics (M) at North Carolina State University.
Reviews for Numerical Applications to Differential Equations
Report this Material
What is Karma?
Karma is the currency of StudySoup.
Date Created: 10/15/15
Lesson 2 Falling Mass and Euler Methods 21 Applied Problem Consider a mass which is falling through a viscous medium One example is a falling rock and a second example is a person in parachute These two masses will have different speeds because of different air resistance We would like to quantify these air resistances and use them to predict the speed of the falling object 22 Differential Equation Model Here we use Newton39s law of motion with two forces one from gravity mg and a second from the viscous medium ku2 or some quadratic function of u The speed of the mass is denoted by u and the k is a constant which re ects the mass and the viscosity of the medium Newton39s law of motion then gives the differential equation mutmgku2 As time evolves the speed will approach u mgk12 More generally the resistive force will be c absu ku2 where the constants c and k are determined from physical experiments 23 Method of Solution The general problem of solving or approximating the solution of the differential equation y gm can be approached via a variation of Euler method Euler39s Numerical Method for Approximating y39 gty and y0 given Let Yi be an approximation for yidt given by Yi 1 Yi dtgidtYi In order to formulate an improved variation of Euler s method consider the integral form of the differential equation by integrating both sides from t idt to t i1 dt i1dt yltlti1 dt ya dt I go yam idt Next approximate the integral by the trapezoid method and use the Euler method to approximate yildt This gives the following where Yil is over written by the second line and Yi is the approximation of yidt Improved Euler39s Numerical Method for Approximating y39 gty and y0 given Yi1 Yi dt gidtYi Yi1 Yi dt2gidtYi gi1dtYi1 The following Matlab code is stored in the mfile eulerrm and it illustrates the errors in the Euler and improved Euler methods for the cooling cup of coffee problem that was discussed in the previous two lessons The error is the difference in the numerical solution and the exact solution Error E Yi 7 yidt The table of errors indicates that the error for the Euler method is proportional to the step size while the error for the improved Euler method is proportional to the square of the step size Matlab Code eulerrm Euler Improved Euler and Exact This code compares the discretization errors The Euler and improved Euler methods are used clear maxk 8 number of time steps T 10 final time dt Tmaxk time1 0 u0 200 initial temperature c 1 insulation factor usur 70 surrounding temperature uexact1 u0 ueul1 u0 uieul1 uO for k lzmaxk timek1 kdt exact solution uexactk1 usur u0 usurexp ckdt Euler numerical approximation ueulk1 ueulk dtcusur ueulk improved Euler numerical approximation utemp uieulk dtcusur uieulk uieulk1 uieulk dt2cusur uieulk cusur utemp erreulk1 absueulk1 uexactk1 errimeulk1 absuieulk1 uexactk1 end plottime ueultime uexact time uieul maxk erreulatT erreulmaxk1 errimeulatT errimeulmaxk1 Table Discretization Errors KK erreul errimerr 8 31152 01370 16 15347 00326 32 07571 00080 64 03761 00020 24 Matlab Implementation The following two lines are in the function le fmassm This is for the falling mass problem where the mass m 1 the gravitation constant g 32 and the resistive force is 1absy where y represents the speed of the mass function fmass fmassty fmass 32 1absy The improved Euler method is implemented in the m le imeulerm The initial speed is stored in y1 and the initial time is stored in t1 The number of time steps is given by KK the nal time is given by T and the step size is h TKK The rst line in the for loop is just the Euler substep and the third line in the for loop is the improved Euler calculation your name your student number lesson number clear y1 0 initial speed stored in first entry of array y T 50 final time KK 200 number of time steps h TKK time step size t1 0 initial time stored in first entry of array t for k 1KK yk1 yk hfmasstkyk tk1 tk h yk1 yk 5hfmasstkyk fmasstk1 yk1 end plotty title your name your student number lesson number xlabel time ylabel speed 25 Numerical Experiments The rst numerical experiment is with the resistive force equal to lu as indicated in the above Matlab files Here the speed is negative because the mass is falling down and it increases from 0 to 320 It requires about 50 units of time to approach this speed your name your student number lesson number 0 100 150 speed 200 250 300 350 0 The second numerical experiment is with the resistive force equal to labsu 001u2 So the second line in the fmassm must be changed to fmass 32 labsy 001yy Here the speed is still negative because the mass is falling down but now it only increases from 0 to a little less than 140 Furthermore it only takes about 20 units of time is approach this speed your name your student number lesson number 0 100 120 140 I I I I I I I I I 26 a b c d e Additional Calculations Consider the falling mass problem where m 1 g 32 u0 0 and variable resistive forces 1absu k u2 where k changes Consider the resistive force 1absu 0011S05u2 Modify the function file fmassm and execute the code file imeuler Note the curve for the speed on the vertical axis and time on the horizontal axis Use the hold on command so that the following two curves will appear on the same graph Consider the resistive force 1absu 0011S10u2 Modify the function file fmassm and execute the code file imeuler Consider the resistive force 1absu 0011S 5u2 Modify the function file fmassm and execute the code file imeuler Compare the three curves What happens when k is increased Find k so that the steady state speed is 12 There are two ways to do this Either set the right side of the differential equation equal to zero and solve for k or do a number of numerical experiments with different k