



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




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.
Here we use Newton's law of motion with two forces: one from gravity, mg, and a second from the viscous medium, -ku^2 (or, some quadratic function of u). The speed of the mass is denoted by u, and the k is a constant, which reflects the mass and the viscosity of the medium. Newton's law of motion then gives the differential equation m ut = -mg + k u^2. As time evolves, the speed will approach u = (mg/k)1/2. More generally, the resistive force will be c abs(u) + ku^2 where the constants c and k are determined from physical experiments.
The general problem of solving or approximating the solution of the differential equation y' = g(t,y) can be approached via a variation of Euler method.
Euler's Numerical Method for Approximating y' = g(t,y) and y(0) given. Let Y(i) be an approximation for y(idt) given by Y(i + 1) = Y(i) + dtg(i*dt,Y(i)).
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 = (i+1)dt
y((i 1 )dt) y(idt) g(t,y(t))dt. (i 1 )*dt
Next approximate the integral by the trapezoid method and use the Euler method to approximate y((i+1)dt). This gives the following where Y(i+1) is over written by the second line, and Y(i) is the approximation of y(idt).
Improved Euler's Numerical Method for Approximating y' = g(t,y) and y(0) given. Y(i+1) = Y(i) + dtg(idt,Y(i)) Y(i+1) = Y(i) + dt/2(g(idt,Y(i)) + g((i+1)*dt,Y(i+1))).
The following Matlab code is stored in the m-file eulerr.m, 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 ≡ Y(i) – y(i*dt).
Table: Discretization Errors KK erreul errimerr 8 3.1152 0. 16 1.5347 0. 32 0.7571 0. 64 0.3761 0.
The following two lines are in the function file fmass.m. This is for the falling mass problem where the mass m = 1, the gravitation constant g = 32, and the resistive force is .1*abs(y) where y represents the speed of the mass.
function fmass= fmass(t,y) fmass = -32 + .1abs(y);* The improved Euler method is implemented in the m-file imeuler.m. The initial speed is stored in y(1), and the initial time is stored in t(1). The number of time steps is given by KK, the final time is given by T, and the step size is h = T/KK. The first 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; y(1) = 0.; % initial speed stored in first entry of T = 50.; % final time^ array y KK = 200 h = T/KK; % number of time steps% time step size t(1)= 0.; % initial time stored in first entry of array t
for k = 1:KK y(k+1) = y(k) + hfmass(t(k),y(k)); t(k+1) = t(k) + h; y(k+1) = y(k) + .5h(fmass(t(k),y(k)) + fmass(t(k+1),y(k+1))); end plot(t,y) title('your name, your student number, lesson number') xlabel('time') ylabel('speed')*
The first numerical experiment is with the resistive force equal to .1u 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.
-350 0 10 20 30 40 50 60 70 80 90 100
0 your nam e, your s tudent num ber, lesson num ber
tim e
speed
Consider the falling mass problem where m = 1, g = 32, u(0) = 0, and variable resistive forces .1abs(u) + k u^2 where k changes. (a). Consider the resistive force .1abs(u) + (.001(1+.S)0.5)u^2. Modify the function file fmass.m 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. (b). Consider the resistive force .1abs(u) + (.001(1+.S)1.0)u^2. Modify the function file fmass.m and execute the code file imeuler. (c). Consider the resistive force .1abs(u) + (.001(1+.S)`.5)u^2. Modify the function file fmass.m and execute the code file imeuler. (d). Compare the three curves. What happens when k is increased. (e). 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.