Runge - Kutta Methods for first and second order models

Size: px
Start display at page:

Download "Runge - Kutta Methods for first and second order models"

Transcription

1 Runge - Kutta Methods for first and second order models James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University October 3, 2013

2 Outline 1 Runge - Kutte Methods 2 RK Methods: One Variable 3 RK Methods: Two Variables

3 Abstract This lecture discusses the Runge - Kutta Method for first and second order models.

4 Runge - Kutte Methods Runge - Kutta methods are based on more sophisticated ways of approximating the solution to y = f (t, y). These methods use multiple function evaluations at different time points around a given t to approximate y(t ). In more advanced classes, we can show this technique generates a sequence {ŷ n } starting at y 0 using the following recursion equation: ŷ n+1 = ŷ n + h F o (t n, ŷ n, h, f ) ŷ 0 = y 0 where h is the step size we use and F o is a fairly complicated function of the previous approximate solution, the step size and the right hand side function f. The Runge - Kutta methods are available for various choices of the superscript o which is called the order of the method.

5 Runge - Kutte Methods We will not discuss F o here, as it is best to do that in a more advanced class. We know that for Order One: Local error is h 2 and this method is the Euler Method. The global error then goes down linearly with h. Order Two: Local error is h 3, global is h 2. If the global error for a given stepsize h is E, halving the stepsize to h/2 gives a new global error E/4. The global error goes down quadratically. Order Three: Local error is h 4, global is h 3. If the global error for a given stepsize h is E, then halving the stepsize to h/2 gives a new global error E/8. The global error goes down as a cubic power. Order Four: Local error is h 5, global is h 4. If the global error for a given stepsize h is E, then halving the stepsize to h/2 gives a new global error of E/16.

6 Runge - Kutte Methods The basic code to implement the Runge-Kutta methods is broken into two pieces. The first one, RKstep.m implements the evaluation of the next approximation solution at point (t n, ŷ n ) given the old approximation at (t n 1, ŷ n 1 ). We then loop through all the steps to get to the chosen final time using the code in FixedRK.m. The details of these algorithms are beyond the scope of this text; however, they arise from carefully combined multiple tangent line approximations at each step. In the RK code, we want the dynamic functions to depend on time also. Previously, we used dynamics like f 3*x and we expected the dynamics functions to have that form in DoEuler. However, we want more complicated dynamics now so we will define our dynamics as if they depend on time. So from now on, we write f=@(t,x) 3*x even if there is no time dependence.

7 Runge - Kutte Methods DoEulerTwo.m: the functions are now time dependent. We have to change euler also. f u n c t i o n [ xhat, x, e ] = DoEulerTwo ( f, t r u e, N, x0, h ) % N = number of approximations to f i n d % f = t h e model dynamics f u n c t i o n o f ( t, x ) % t r u e = t h e t r u e s o l u t i o n % x0 = t h e i n i t i a l c o n d i t i o n % h = t h e s t e p s i z e % e u l e r t, x, h ) x + f ( t, x ) h ; x h a t ( 1 ) = x0 ; % i n i t i a l i z e x, x h a t and e x ( 1 ) = x0 ; e ( 1 ) = 0 ; f o r i =1:N x h a t ( i +1) = e u l e r ( i h, x h a t ( i ), h ) ; x ( i +1) = t r u e ( i h ) ; e ( i +1) = abs ( x ( i +1) x h a t ( i +1) ) ; end end

8 Runge - Kutte Methods RKstep.m uses the new dynamics functions. In it you see the lines like feval(fname,t,x) which means take the function fname passed in as an argument and evaluate it as the pair (t,x). Hence, fname(t,x) is the same as f(t,x). RKstep.m does all the heavy lifting. It manages all of the multiple tangent line calculations that Runge - Kutta needs at each step. We loop through all the steps to get to the chosen final time using the code in FixedRK.m.

9 Runge - Kutte Methods f u n c t i o n [ tnew, ynew, fnew ] = RKstep ( fname, tc, yc, fc, h, k ) % fname t h e name o f t h e r i g h t hand s i d e f u n c t i o n f ( t, y ) % yc a p p r o x i m a t e s o l u t i o n to y ( t ) = f ( t, y ( t ) ) a t t=t c % f c f ( tc, yc ) % h The time step, k i s RK order 1<= k <=4 % tnew i s t c+h, ynew i s a p p r o x s o l n a t tnew, fnew i s f ( tnew, ynew ) i f k==1 k1 = h f c ; ynew = yc+k1 ; e l s e i f k==2 k1 = h f c ; k2 = h f e v a l ( fname, t c +(h /2), yc+(k1 /2) ) ; ynew = yc + k2 ; e l s e i f k==3 k1 = h f c ; k2 = h f e v a l ( fname, t c +(h /2), yc+(k1 /2) ) ; k3 = h f e v a l ( fname, t c+h, yc k1+2 k2 ) ; ynew = yc+(k1+4 k2+k3 ) / 6 ; e l s e i f k==4 k1 = h f c ; k2 = h f e v a l ( fname, t c +(h /2), yc+(k1 /2) ) ; k3 = h f e v a l ( fname, t c +(h /2), yc+(k2 /2) ) ; k4 = h f e v a l ( fname, t c+h, yc+k3 ) ; ynew = yc+(k1+2 k2+2 k3+k4 ) / 6 ; e l s e d i s p ( s p r i n t f ( The RK method %2d o r d e r i s not a l l o w e d!, k ) ) ; end tnew = tc+h ; fnew = f e v a l ( fname, tnew, ynew ) ; end

10 Runge - Kutte Methods f u n c t i o n [ t v a l s, y v a l s ] = FixedRK ( fname, t0, y0, h, k, n ) % G i v e s a p p r o x i m a t e s o l u t i o n to % y ( t ) = f ( t, y ( t ) ) % y ( t0 ) = y0 % u s i n g a kth o r d e r RK method % t0 i n i t i a l time % y0 i n i t i a l s t a t e % h s t e p s i z e % k RK order 1<= k <= 4 % n Number o f s t e p s to t a k e % t v a l s time v a l u e s o f form % t v a l s ( j ) = t0 + ( j 1) h, 1 <= j <= n % y v a l s a p p r o x i m a t e s o l u t i o n % y v a l s ( : j ) = a p p r o x i m a t e s o l u t i o n a t % t v a l s ( j ), 1 <= j <= n tc = t0 ; yc = y0 ; t v a l s = t c ; y v a l s = yc ; f c = f e v a l ( fname, tc, yc ) ; f o r j =1:n 1 [ tc, yc, f c ] = RKstep ( fname, tc, yc, fc, h, k ) ; y v a l s = [ y v a l s yc ] ; t v a l s = [ t v a l s t c ] ; end end

11 RK Methods: One Variable Example: solve a model using all four RK orders and do a plot >> f t, x ).5 x. (60 x ) ; >> t r u e t ) 6 0. / ( 1 + (60/20 1) exp (.5 60 t ) ) ; >> T =. 6 ; >> time = l i n s p a c e ( 0,T, 3 1 ) ; >> h1 =. 0 6 ; >> N1 = c e i l (T/ h1 ) ; >> [ htime1, x h a t 1 ] = FixedRK ( f, 0, 2 0,. 0 6, 1, N1) ; >> [ htime2, x h a t 2 ] = FixedRK ( f, 0, 2 0,. 0 6, 2, N1) ; >> [ htime3, x h a t 3 ] = FixedRK ( f, 0, 2 0,. 0 6, 3, N1) ; >> [ htime4, x h a t 4 ] = FixedRK ( f, 0, 2 0,. 0 6, 4, N1) ; % t h e... a t t h e end o f t h e l i n e a l l o w s us to c o n t i n u e % a l o n g l i n e to t h e s t a r t o f t h e n e x t l i n e >> p l o t ( time, t r u e ( time ), htime1, xhat1,, htime2, xhat2, o,... htime3, xhat3, +, htime4, xhat4,. ) ; >> x l a b e l ( Time ) ; >> y l a b e l ( x ) ; % We want to use t h e d e r i v a t i v e symbol x so % s i n c e Matlab t r e a t as t h e s t a r t and s t o p o f the l a b e l % we w r i t e. That way Matlab w i l l t r e a t s as a s i n g l e quote % t h a t i s our d i f f e r e n t i a t i o n symbol >> t i t l e ( RK A p p r o x i m a t i o n s to x =. 5 x(60 x ), x ( 0 ) 2 0 ) ; % N o t i c e we c o n t i n u e t h i s l i n e too >> l e g e n d ( True, RK 1, h =. 0 6, RK 2, h =. 0 6, RK 3, h =. 0 6,... RK 4, h =. 0 6, L o c a t i o n, Best ) ; This generates the figure in the next slide: note RK Order 4 does a great job even with a large h.

12 RK Methods: One Variable

13 RK Methods: One Variable Homework 45 You are now ready to solve a few on your own. For these problems, (i): Write the dynamics function code as f etc. (ii): Write the true function code as usual true etc. (iii): Solve the problem with all four Runga - Kutte Methods for the given step size h and appropriate time interval. Plot all four Runga - Kutte approximate solutions and the true solution on the same plot. (iv): Do all of this in a word doc as usual.

14 RK Methods: One Variable Homework 45 Continued 45.1 h =.05 and the model is y =.07 y (75 y), y(0) = h =.06 and the model is u (t) =.13 u(t) (30 u(t)), u(0) = h =.4 and the model is x = 1.9x, x(0) = h =.5 and the model is x = 1.95x + 30, x(0) = 16.

15 RK Methods: Two Variables We can convert a second order linear model to a system easily. Here is an example. Example Convert to a matrix - vector system u (t) u (t) 5.0 u(t) = 0; u(0) = 1.0; u (0) = +1.0 Solution Let x be given by x(t) = [ ] x1 (t) x 2 (t) = [ ] u(t) u (t)

16 RK Methods: Two Variables Solution Solution continued: x 1(t) = u (t) = x 2 (t), x 2(t) = u (t) = 5u(t) (4)u (t) = 5x 1 (t) 4x 2 (t). Thus x (t) = [ ] x 1 (t) x 2 (t) = [ ] [ ] 0 1 x1 (t) 5 4 x 2 (t) Also, note that x(0) = [ ] x1 (0) x 2 (0) = [ ] u(0) u (0) = [ ] 1 1 = x(0).

17 RK Methods: Two Variables The conversion process also tells us the dynamics of the new systems model. We can convert a second order linear model to a system easily. Example Find the systems dynamics for the model u (t) u (t) 5.0 u(t) = 0; u(0) = 1.0; u (0) = +1.0 Solution Let x be given by x(t) = [ ] x1 (t) x 2 (t) = [ ] u(t) u (t)

18 RK Methods: Two Variables Solution Solution continued: x 1(t) = u (t) = x 2 (t), x 2(t) = u (t) = 5u(t) (4)u (t) = 5x 1 (t) 4x 2 (t). Thus, the new dynamics is f given by [ ] x f(x 1, x 2 ) = 2 5x 1 4x 2

19 RK Methods: Two Variables Note we can code the dynamics in Matlab as follows: The model u (t) u (t) 5.0 u(t) = 0; u(0) = 1.0; u (0) = +1.0 in Matlab becomes >> f x ) [ x ( 2 ) ; 5 x ( 1 ) 4 x ( 2 ) ] ; Note, x can be a number or a vector as the function has been coded to accept either. We can now apply Runge - Kutta methods to solve second order models.

20 RK Methods: Two Variables Consider the problem ay + by + cy = g, y(0) = y 0, y (0) = y 1 y + (b/a)y + (c/a)y = (1/a)g, y(0) = y 0, y (0) = y 1 This converts to the system x 1 x 2 = x 2 = (c/a)x 1 (b/a)x 2 + (1/a)g And letting A = (c/a), B = (b/a) and C = (1/a) we have x 1 x 2 = x 2 = Ax 1 + Bx 2 + Cg. We ll use this in the code below.

21 RK Methods: Two Variables Consider the problem y (t) y (t) 5.0 y(t) = 0; y(0) = 1.0; y (0) = +1.0 This has characteristic equation r 2 + 4r 5 = 0 with roots r 1 = 5 and r 2 = 1. Hence, the general solution is x(t) = Ae 5t + Be t. The initial conditions give A + B = 1 5A + B = 1 It is straightforward to see that A = 1/3 and B = 2/3. Then we solve the system using MatLab with this session:

22 RK Methods: Two Variables % d e f i n e t h e dynamics f o r y + 4 y 5 y = 0 >> a = 1 ; b = 4 ; c = 5; >> B = (b/a ) ; A = (c /a ) ; C = 1/ a ; >> g t ) 0. 0 ; >> f t, y ) [ y ( 2 ) ; A y ( 1 ) + B y ( 2 ) + C g ( t ) ] ; % d e f i n e t h e t r u e s o l u t i o n >> t r u t ) [ ( 1. 0 / 3. 0 ) exp( 5 t ) (2.0/3.0) exp ( t ) ;... ( 5. 0 / 3. 0 ) exp( 5 t ) (2.0/3.0) exp ( t ) ] ; >> y0 = [ 1 ; 1 ] ; >> h =. 2 ; >> T = 3 ; >> time = l i n s p a c e ( 0,T, ) ; >> N = c e i l (T/h ) ; >> [ htime1, r k a p p r o x 1 ] = FixedRK ( f, 0, y0, h, 1,N) ; >> y h a t 1 = r k a p p r o x 1 ( 1, : ) ; >> [ htime2, r k a p p r o x 2 ] = FixedRK ( f, 0, y0, h, 2,N) ; >> y h a t 2 = r k a p p r o x 2 ( 1, : ) ; >> [ htime3, r k a p p r o x 3 ] = FixedRK ( f, 0, y0, h, 3,N) ; >> y h a t 3 = r k a p p r o x 3 ( 1, : ) ; >> [ htime4, r k a p p r o x 4 ] = FixedRK ( f, 0, y0, h, 4,N) ; >> y h a t 4 = r k a p p r o x 4 ( 1, : ) ; >> p l o t ( time, t r u e ( time ), htime1, yhat1, o, htime2, yhat2,,... htime3, yhat3, +, htime4, yhat4, ) ; >> x l a b e l ( Time ) ; >> y l a b e l ( y ) ; >> t i t l e ( S o l u t i o n to x + 4x 5 x = 0, x ( 0 ) = 1, x ( 0 ) = 1 on [ 0, 3 ] ) ; >> l e g e n d ( True, RK1, RK2, RK3, RK4, L o c a t i o n, Best ) ;

23 RK Methods: Two Variables This generates the plot

24 RK Methods: Two Variables Now add an external input. We don t know true solution anymore. % d e f i n e t h e dynamics f o r y + 4 y 5 y = 10 s i n (5 t ) eˆ{.03 t } >> a = 1 ; b = 4 ; c = 5; >> B = (b/a ) ; A = (c /a ) ; C = 1/ a ; >> g t ) 10 s i n (5 t ). exp (.03 t ) ; >> f t, y ) [ y ( 2 ) ; A y ( 1 ) + B y ( 2 ) + C g ( t ) ] ; >> y0 = [ 1 ; 1 ] ; >> h =. 2 ; >> T = 3 ; >> N = c e i l (T/h ) ; >> [ htime1, r k a p p r o x 1 ] = FixedRK ( f, 0, y0, h, 1,N) ; >> y h a t 1 = r k a p p r o x 1 ( 1, : ) ; >> [ htime2, r k a p p r o x 2 ] = FixedRK ( f, 0, y0, h, 2,N) ; >> y h a t 2 = r k a p p r o x 2 ( 1, : ) ; >> [ htime3, r k a p p r o x 3 ] = FixedRK ( f, 0, y0, h, 3,N) ; >> y h a t 3 = r k a p p r o x 3 ( 1, : ) ; >> [ htime4, r k a p p r o x 4 ] = FixedRK ( f, 0, y0, h, 4,N) ; >> y h a t 4 = r k a p p r o x 4 ( 1, : ) ; >> p l o t ( htime1, yhat1, o, htime2, yhat2,,... htime3, yhat3, +, htime4, yhat4, ) ; >> x l a b e l ( Time ) ; >> y l a b e l ( Approx y ) ; >> t i t l e ( S o l u t i o n to x + 4x 5 x = 10 s i n (5 t ) eˆ{.03 t }, x ( 0 ) = 1, x ( 0 ) = 1 on [ 0, 3 ] ) ; >> l e g e n d ( RK1, RK2, RK3, RK4, L o c a t i o n, Best ) ;

25 RK Methods: Two Variables Note the plot is not quite smooth enough because of the coarseness of h. Big question is are we getting closer to the true solution?

26 RK Methods: Two Variables Homework 46 On all of these problems, for the given h and final time T, find the true solution generate the plot of the true solution and all four RK order plots as we have done in the example. Write this up with attached plots in word For h =.3 and T = 4. u (t) + u (t) 2 u(t) = 0; u(0) = 1; u (0) = For h =.4 and T = 3. x (t) + 6 x (t) + 9 x(t) = 0; x(0) = 1; x (0) = For h =.2 and T = 5. y (t) + 4 y (t) + 13 y(t) = 0; y(0) = 1; y (0) = 2

27 RK Methods: Two Variables Homework 47 On all of these problems, for the given stepsize h and final time T, generate all four RK order plots as we have done in the example. Write this up with attached plots in word For h =.4 and T = 3. 2 u (t) + 4 u (t) 3 u(t) = exp( 2t) cos(3t + 5) 47.2 For h =.2 and T = 4. u(0) = 2 u (0) = 3 u (t) 2 u (t) + 13 u(t) = exp( 5t) sin(3t 2 + 5) u(0) = 12 u (0) = 6

Runge - Kutta Methods for first order models

Runge - Kutta Methods for first order models Runge - Kutta Methods for first order models James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University October 30, 2013 Outline 1 Runge - Kutte Methods

More information

Runge - Kutta Methods for first order models

Runge - Kutta Methods for first order models Runge - Kutta Methods for first order models James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University October 30, 2013 Outline Runge - Kutte Methods

More information

Solving systems of ODEs with Matlab

Solving systems of ODEs with Matlab Solving systems of ODEs with Matlab James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University October 20, 2013 Outline 1 Systems of ODEs 2 Setting Up

More information

Solving Linear Systems of ODEs with Matlab

Solving Linear Systems of ODEs with Matlab Solving Linear Systems of ODEs with Matlab James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University October 27, 2013 Outline Linear Systems Numerically

More information

Taylor Polynomials. James K. Peterson. Department of Biological Sciences and Department of Mathematical Sciences Clemson University

Taylor Polynomials. James K. Peterson. Department of Biological Sciences and Department of Mathematical Sciences Clemson University James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University September 24, 2013 Outline 1 First Order Approximation s Second Order Approximations 2 Approximation

More information

Uniform Convergence Examples

Uniform Convergence Examples Uniform Convergence Examples James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University October 13, 2017 Outline 1 Example Let (x n ) be the sequence

More information

Uniform Convergence Examples

Uniform Convergence Examples Uniform Convergence Examples James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University October 13, 2017 Outline More Uniform Convergence Examples Example

More information

Advanced Protein Models again: adding regulation

Advanced Protein Models again: adding regulation Advanced Protein Models again: adding regulation James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University April 1, 2014 Outline 1 Simple Regulations

More information

Linear Systems of ODE: Nullclines, Eigenvector lines and trajectories

Linear Systems of ODE: Nullclines, Eigenvector lines and trajectories Linear Systems of ODE: Nullclines, Eigenvector lines and trajectories James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University October 6, 2013 Outline

More information

Predator - Prey Model Trajectories and the nonlinear conservation law

Predator - Prey Model Trajectories and the nonlinear conservation law Predator - Prey Model Trajectories and the nonlinear conservation law James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University October 28, 2013 Outline

More information

Extreme Values and Positive/ Negative Definite Matrix Conditions

Extreme Values and Positive/ Negative Definite Matrix Conditions Extreme Values and Positive/ Negative Definite Matrix Conditions James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University November 8, 016 Outline 1

More information

Getting Started With The Predator - Prey Model: Nullclines

Getting Started With The Predator - Prey Model: Nullclines Getting Started With The Predator - Prey Model: Nullclines James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University October 28, 2013 Outline The Predator

More information

Section 7.4 Runge-Kutta Methods

Section 7.4 Runge-Kutta Methods Section 7.4 Runge-Kutta Methods Key terms: Taylor methods Taylor series Runge-Kutta; methods linear combinations of function values at intermediate points Alternatives to second order Taylor methods Fourth

More information

Derivatives and the Product Rule

Derivatives and the Product Rule Derivatives and the Product Rule James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University January 28, 2014 Outline 1 Differentiability 2 Simple Derivatives

More information

Outline. Additional Nonlinear Systems. Abstract. Finding Equilibrium Points Numerically. Newton s Method

Outline. Additional Nonlinear Systems. Abstract. Finding Equilibrium Points Numerically. Newton s Method Outline Finding Equilibrium Points Numerically Additional Nonlinear Systems James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University June 13, 2017

More information

Linear Systems of ODE: Nullclines, Eigenvector lines and trajectories

Linear Systems of ODE: Nullclines, Eigenvector lines and trajectories Linear Systems of ODE: Nullclines, Eigenvector lines and trajectories James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University October 6, 203 Outline

More information

The Method of Undetermined Coefficients.

The Method of Undetermined Coefficients. The Method of Undetermined Coefficients. James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University May 24, 2017 Outline 1 Annihilators 2 Finding The

More information

Project One: C Bump functions

Project One: C Bump functions Project One: C Bump functions James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University November 2, 2018 Outline 1 2 The Project Let s recall what the

More information

Predator - Prey Model Trajectories are periodic

Predator - Prey Model Trajectories are periodic Predator - Prey Model Trajectories are periodic James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University November 4, 2013 Outline 1 Showing The PP

More information

Outline Calculus for the Life Sciences II. Pollution in a Lake 1. Introduction. Lecture Notes Numerical Methods for Differential Equations

Outline Calculus for the Life Sciences II. Pollution in a Lake 1. Introduction. Lecture Notes Numerical Methods for Differential Equations Improved Improved Outline Calculus for the Life Sciences II tial Equations Joseph M. Mahaffy, mahaffy@math.sdsu.edu Department of Mathematics and Statistics Dynamical Systems Group Computational Sciences

More information

Newton s Cooling Model in Matlab and the Cooling Project!

Newton s Cooling Model in Matlab and the Cooling Project! Newton s Cooling Model in Matlab and the Cooling Project! James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University March 10, 2014 Outline Your Newton

More information

ODE Homework 1. Due Wed. 19 August 2009; At the beginning of the class

ODE Homework 1. Due Wed. 19 August 2009; At the beginning of the class ODE Homework Due Wed. 9 August 2009; At the beginning of the class. (a) Solve Lẏ + Ry = E sin(ωt) with y(0) = k () L, R, E, ω are positive constants. (b) What is the limit of the solution as ω 0? (c) Is

More information

Predator - Prey Model Trajectories are periodic

Predator - Prey Model Trajectories are periodic Predator - Prey Model Trajectories are periodic James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University November 4, 2013 Outline Showing The PP Trajectories

More information

Variation of Parameters

Variation of Parameters Variation of Parameters James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University April 13, 218 Outline Variation of Parameters Example One We eventually

More information

Lecture 5b: Starting Matlab

Lecture 5b: Starting Matlab Lecture 5b: Starting Matlab James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University August 7, 2013 Outline 1 Resources 2 Starting Matlab 3 Homework

More information

Calculus for the Life Sciences

Calculus for the Life Sciences Improved Calculus for the Life Sciences ntial Equations Joseph M. Mahaffy, jmahaffy@mail.sdsu.edu Department of Mathematics and Statistics Dynamical Systems Group Computational Sciences Research Center

More information

Complex Numbers. Outline. James K. Peterson. September 19, Complex Numbers. Complex Number Calculations. Complex Functions

Complex Numbers. Outline. James K. Peterson. September 19, Complex Numbers. Complex Number Calculations. Complex Functions Complex Numbers James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University September 19, 2013 Outline Complex Numbers Complex Number Calculations Complex

More information

Complex Numbers. James K. Peterson. September 19, Department of Biological Sciences and Department of Mathematical Sciences Clemson University

Complex Numbers. James K. Peterson. September 19, Department of Biological Sciences and Department of Mathematical Sciences Clemson University Complex Numbers James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University September 19, 2013 Outline 1 Complex Numbers 2 Complex Number Calculations

More information

Linear algebra and differential equations (Math 54): Lecture 20

Linear algebra and differential equations (Math 54): Lecture 20 Linear algebra and differential equations (Math 54): Lecture 20 Vivek Shende April 7, 2016 Hello and welcome to class! Last time We started discussing differential equations. We found a complete set of

More information

Riemann Sums. Outline. James K. Peterson. September 15, Riemann Sums. Riemann Sums In MatLab

Riemann Sums. Outline. James K. Peterson. September 15, Riemann Sums. Riemann Sums In MatLab Riemann Sums James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University September 15, 2013 Outline Riemann Sums Riemann Sums In MatLab Abstract This

More information

Lecture 10: Powers of Matrices, Difference Equations

Lecture 10: Powers of Matrices, Difference Equations Lecture 10: Powers of Matrices, Difference Equations Difference Equations A difference equation, also sometimes called a recurrence equation is an equation that defines a sequence recursively, i.e. each

More information

Numerical Methods for ODEs. Lectures for PSU Summer Programs Xiantao Li

Numerical Methods for ODEs. Lectures for PSU Summer Programs Xiantao Li Numerical Methods for ODEs Lectures for PSU Summer Programs Xiantao Li Outline Introduction Some Challenges Numerical methods for ODEs Stiff ODEs Accuracy Constrained dynamics Stability Coarse-graining

More information

Physics 299: Computational Physics II Project II

Physics 299: Computational Physics II Project II Physics 99: Computational Physics II Project II Due: Feb 01 Handed out: 6 Jan 01 This project begins with a description of the Runge-Kutta numerical integration method, and then describes a project to

More information

Solutions to Homework 3

Solutions to Homework 3 Solutions to Homework 3 Section 3.4, Repeated Roots; Reduction of Order Q 1). Find the general solution to 2y + y = 0. Answer: The charactertic equation : r 2 2r + 1 = 0, solving it we get r = 1 as a repeated

More information

Worksheet # 2: Higher Order Linear ODEs (SOLUTIONS)

Worksheet # 2: Higher Order Linear ODEs (SOLUTIONS) Name: November 8, 011 Worksheet # : Higher Order Linear ODEs (SOLUTIONS) 1. A set of n-functions f 1, f,..., f n are linearly independent on an interval I if the only way that c 1 f 1 (t) + c f (t) +...

More information

Integration by Parts Logarithms and More Riemann Sums!

Integration by Parts Logarithms and More Riemann Sums! Integration by Parts Logarithms and More Riemann Sums! James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University September 16, 2013 Outline 1 IbyP with

More information

Defining Exponential Functions and Exponential Derivatives and Integrals

Defining Exponential Functions and Exponential Derivatives and Integrals Defining Exponential Functions and Exponential Derivatives and Integrals James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University February 19, 2014

More information

Consequences of Continuity

Consequences of Continuity Consequences of Continuity James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University October 4, 2017 Outline 1 Domains of Continuous Functions 2 The

More information

EXAMPLE OF ONE-STEP METHOD

EXAMPLE OF ONE-STEP METHOD EXAMPLE OF ONE-STEP METHOD Consider solving y = y cos x, y(0) = 1 Imagine writing a Taylor series for the solution Y (x), say initially about x = 0. Then Y (h) = Y (0) + hy (0) + h2 2 Y (0) + h3 6 Y (0)

More information

Why This Class? James K. Peterson. August 22, Department of Biological Sciences and Department of Mathematical Sciences Clemson University

Why This Class? James K. Peterson. August 22, Department of Biological Sciences and Department of Mathematical Sciences Clemson University Why This Class? James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University August 22, 2013 Outline 1 Our Point of View Mathematics, Science and Computer

More information

Lösning: Tenta Numerical Analysis för D, L. FMN011,

Lösning: Tenta Numerical Analysis för D, L. FMN011, Lösning: Tenta Numerical Analysis för D, L. FMN011, 090527 This exam starts at 8:00 and ends at 12:00. To get a passing grade for the course you need 35 points in this exam and an accumulated total (this

More information

Math 308 Week 8 Solutions

Math 308 Week 8 Solutions Math 38 Week 8 Solutions There is a solution manual to Chapter 4 online: www.pearsoncustom.com/tamu math/. This online solutions manual contains solutions to some of the suggested problems. Here are solutions

More information

Ordinary Differential Equations. Monday, October 10, 11

Ordinary Differential Equations. Monday, October 10, 11 Ordinary Differential Equations Monday, October 10, 11 Problems involving ODEs can always be reduced to a set of first order differential equations. For example, By introducing a new variable z, this can

More information

2. Determine whether the following pair of functions are linearly dependent, or linearly independent:

2. Determine whether the following pair of functions are linearly dependent, or linearly independent: Topics to be covered on the exam include: Recognizing, and verifying solutions to homogeneous second-order linear differential equations, and their corresponding Initial Value Problems Recognizing and

More information

Numerical Methods for Ordinary Differential Equations

Numerical Methods for Ordinary Differential Equations CHAPTER 1 Numerical Methods for Ordinary Differential Equations In this chapter we discuss numerical method for ODE. We will discuss the two basic methods, Euler s Method and Runge-Kutta Method. 1. Numerical

More information

An Overly Simplified and Brief Review of Differential Equation Solution Methods. 1. Some Common Exact Solution Methods for Differential Equations

An Overly Simplified and Brief Review of Differential Equation Solution Methods. 1. Some Common Exact Solution Methods for Differential Equations An Overly Simplified and Brief Review of Differential Equation Solution Methods We will be dealing with initial or boundary value problems. A typical initial value problem has the form y y 0 y(0) 1 A typical

More information

The First Derivative and Second Derivative Test

The First Derivative and Second Derivative Test The First Derivative and Second Derivative Test James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University November 8, 2017 Outline Extremal Values The

More information

Fourier Sin and Cos Series and Least Squares Convergence

Fourier Sin and Cos Series and Least Squares Convergence Fourier and east Squares Convergence James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University May 7, 28 Outline et s look at the original Fourier sin

More information

The First Derivative and Second Derivative Test

The First Derivative and Second Derivative Test The First Derivative and Second Derivative Test James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University April 9, 2018 Outline 1 Extremal Values 2

More information

Numerical Optimization

Numerical Optimization Numerical Optimization Unit 2: Multivariable optimization problems Che-Rung Lee Scribe: February 28, 2011 (UNIT 2) Numerical Optimization February 28, 2011 1 / 17 Partial derivative of a two variable function

More information

What if the characteristic equation has a double root?

What if the characteristic equation has a double root? MA 360 Lecture 17 - Summary of Recurrence Relations Friday, November 30, 018. Objectives: Prove basic facts about basic recurrence relations. Last time, we looked at the relational formula for a sequence

More information

Riemann Integration. James K. Peterson. February 2, Department of Biological Sciences and Department of Mathematical Sciences Clemson University

Riemann Integration. James K. Peterson. February 2, Department of Biological Sciences and Department of Mathematical Sciences Clemson University Riemann Integration James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University February 2, 2017 Outline 1 Riemann Sums 2 Riemann Sums In MatLab 3 Graphing

More information

More On Exponential Functions, Inverse Functions and Derivative Consequences

More On Exponential Functions, Inverse Functions and Derivative Consequences More On Exponential Functions, Inverse Functions and Derivative Consequences James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University January 10, 2019

More information

Ordinary Differential Equations (ODEs)

Ordinary Differential Equations (ODEs) Ordinary Differential Equations (ODEs) NRiC Chapter 16. ODEs involve derivatives wrt one independent variable, e.g. time t. ODEs can always be reduced to a set of firstorder equations (involving only first

More information

Derivatives in 2D. Outline. James K. Peterson. November 9, Derivatives in 2D! Chain Rule

Derivatives in 2D. Outline. James K. Peterson. November 9, Derivatives in 2D! Chain Rule Derivatives in 2D James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University November 9, 2016 Outline Derivatives in 2D! Chain Rule Let s go back to

More information

Riemann Integration. Outline. James K. Peterson. February 2, Riemann Sums. Riemann Sums In MatLab. Graphing Riemann Sums

Riemann Integration. Outline. James K. Peterson. February 2, Riemann Sums. Riemann Sums In MatLab. Graphing Riemann Sums Riemann Integration James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University February 2, 2017 Outline Riemann Sums Riemann Sums In MatLab Graphing

More information

Numerical method for approximating the solution of an IVP. Euler Algorithm (the simplest approximation method)

Numerical method for approximating the solution of an IVP. Euler Algorithm (the simplest approximation method) Section 2.7 Euler s Method (Computer Approximation) Key Terms/ Ideas: Numerical method for approximating the solution of an IVP Linear Approximation; Tangent Line Euler Algorithm (the simplest approximation

More information

Geometric Series and the Ratio and Root Test

Geometric Series and the Ratio and Root Test Geometric Series and the Ratio and Root Test James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University September 5, 2018 Outline 1 Geometric Series

More information

Hölder s and Minkowski s Inequality

Hölder s and Minkowski s Inequality Hölder s and Minkowski s Inequality James K. Peterson Deartment of Biological Sciences and Deartment of Mathematical Sciences Clemson University Setember 10, 2018 Outline 1 Conjugate Exonents 2 Hölder

More information

Consequences of Continuity

Consequences of Continuity Consequences of Continuity James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University October 4, 2017 Outline Domains of Continuous Functions The Intermediate

More information

Modeling and Experimentation: Compound Pendulum

Modeling and Experimentation: Compound Pendulum Modeling and Experimentation: Compound Pendulum Prof. R.G. Longoria Department of Mechanical Engineering The University of Texas at Austin Fall 2014 Overview This lab focuses on developing a mathematical

More information

Matrix Solutions to Linear Systems of ODEs

Matrix Solutions to Linear Systems of ODEs Matrix Solutions to Linear Systems of ODEs James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University November 3, 216 Outline 1 Symmetric Systems of

More information

Project Two. James K. Peterson. March 26, Department of Biological Sciences and Department of Mathematical Sciences Clemson University

Project Two. James K. Peterson. March 26, Department of Biological Sciences and Department of Mathematical Sciences Clemson University Project Two James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University March 26, 2019 Outline 1 Cooling Models 2 Estimating the Cooling Rate k 3 Typical

More information

Multistep Methods for IVPs. t 0 < t < T

Multistep Methods for IVPs. t 0 < t < T Multistep Methods for IVPs We are still considering the IVP dy dt = f(t,y) t 0 < t < T y(t 0 ) = y 0 So far we have looked at Euler s method, which was a first order method and Runge Kutta (RK) methods

More information

Hölder s and Minkowski s Inequality

Hölder s and Minkowski s Inequality Hölder s and Minkowski s Inequality James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University September 1, 218 Outline Conjugate Exponents Hölder s

More information

Project Two. Outline. James K. Peterson. March 27, Cooling Models. Estimating the Cooling Rate k. Typical Cooling Project Matlab Session

Project Two. Outline. James K. Peterson. March 27, Cooling Models. Estimating the Cooling Rate k. Typical Cooling Project Matlab Session Project Two James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University March 27, 2018 Outline Cooling Models Estimating the Cooling Rate k Typical Cooling

More information

Convergence of Sequences

Convergence of Sequences James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University September 5, 2018 Outline 1 2 Homework Definition Let (a n ) n k be a sequence of real numbers.

More information

The Existence of the Riemann Integral

The Existence of the Riemann Integral The Existence of the Riemann Integral James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University September 18, 2018 Outline The Darboux Integral Upper

More information

Solution: (a) Before opening the parachute, the differential equation is given by: dv dt. = v. v(0) = 0

Solution: (a) Before opening the parachute, the differential equation is given by: dv dt. = v. v(0) = 0 Math 2250 Lab 4 Name/Unid: 1. (35 points) Leslie Leroy Irvin bails out of an airplane at the altitude of 16,000 ft, falls freely for 20 s, then opens his parachute. Assuming linear air resistance ρv ft/s

More information

Dirchlet s Function and Limit and Continuity Arguments

Dirchlet s Function and Limit and Continuity Arguments Dirchlet s Function and Limit and Continuity Arguments James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University February 23, 2018 Outline 1 Dirichlet

More information

Sin, Cos and All That

Sin, Cos and All That Sin, Cos and All That James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University March 9, 2017 Outline 1 Sin, Cos and all that! 2 A New Power Rule 3

More information

The SIR Disease Model Trajectories and MatLab

The SIR Disease Model Trajectories and MatLab The SIR Disease Model Trajectories and MatLab James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University November 17, 2013 Outline Reviewing the SIR

More information

Physics 584 Computational Methods

Physics 584 Computational Methods Physics 584 Computational Methods Introduction to Matlab and Numerical Solutions to Ordinary Differential Equations Ryan Ogliore April 18 th, 2016 Lecture Outline Introduction to Matlab Numerical Solutions

More information

Unit 2: Solving Scalar Equations. Notes prepared by: Amos Ron, Yunpeng Li, Mark Cowlishaw, Steve Wright Instructor: Steve Wright

Unit 2: Solving Scalar Equations. Notes prepared by: Amos Ron, Yunpeng Li, Mark Cowlishaw, Steve Wright Instructor: Steve Wright cs416: introduction to scientific computing 01/9/07 Unit : Solving Scalar Equations Notes prepared by: Amos Ron, Yunpeng Li, Mark Cowlishaw, Steve Wright Instructor: Steve Wright 1 Introduction We now

More information

INTRODUCTION TO COMPUTER METHODS FOR O.D.E.

INTRODUCTION TO COMPUTER METHODS FOR O.D.E. INTRODUCTION TO COMPUTER METHODS FOR O.D.E. 0. Introduction. The goal of this handout is to introduce some of the ideas behind the basic computer algorithms to approximate solutions to differential equations.

More information

Differentiating Series of Functions

Differentiating Series of Functions Differentiating Series of Functions James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University October 30, 017 Outline 1 Differentiating Series Differentiating

More information

Power Series Solutions for Ordinary Differential Equations

Power Series Solutions for Ordinary Differential Equations Power Series Solutions for Ordinary Differential Equations James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University December 4, 2017 Outline 1 Power

More information

MATH10001 Mathematical Workshop Difference Equations part 2 Non-linear difference equations

MATH10001 Mathematical Workshop Difference Equations part 2 Non-linear difference equations MATH10001 Mathematical Workshop Difference Equations part 2 Non-linear difference equations In a linear difference equation, the equation contains a sum of multiples of the elements in the sequence {y

More information

MATH10001 Mathematical Workshop Graph Fitting Project part 2

MATH10001 Mathematical Workshop Graph Fitting Project part 2 MATH10001 Mathematical Workshop Graph Fitting Project part 2 Polynomial models Modelling a set of data with a polynomial curve can be convenient because polynomial functions are particularly easy to differentiate

More information

Power Series Solutions of Ordinary Differential Equations

Power Series Solutions of Ordinary Differential Equations Power Series Solutions for Ordinary Differential Equations James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University December 4, 2017 Outline Power

More information

Regression and Covariance

Regression and Covariance Regression and Covariance James K. Peterson Department of Biological ciences and Department of Mathematical ciences Clemson University April 16, 2014 Outline A Review of Regression Regression and Covariance

More information

Mathematical Induction Again

Mathematical Induction Again Mathematical Induction Again James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University January 12, 2017 Outline Mathematical Induction Simple POMI Examples

More information

Mathematical Induction Again

Mathematical Induction Again Mathematical Induction Again James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University January 2, 207 Outline Mathematical Induction 2 Simple POMI Examples

More information

An Introduction to Numerical Methods for Differential Equations. Janet Peterson

An Introduction to Numerical Methods for Differential Equations. Janet Peterson An Introduction to Numerical Methods for Differential Equations Janet Peterson Fall 2015 2 Chapter 1 Introduction Differential equations arise in many disciplines such as engineering, mathematics, sciences

More information

Lecture 10 Polynomial interpolation

Lecture 10 Polynomial interpolation Lecture 10 Polynomial interpolation Weinan E 1,2 and Tiejun Li 2 1 Department of Mathematics, Princeton University, weinan@princeton.edu 2 School of Mathematical Sciences, Peking University, tieli@pku.edu.cn

More information

24, B = 59 24, A = 55

24, B = 59 24, A = 55 Math 128a - Homework 8 - Due May 2 1) Problem 8.4.4 (Page 555) Solution: As discussed in the text, the fourth-order Adams-Bashforth formula is a formula of the type x n+1 = x n + h[af n + Bf n 1 + Cf n

More information

First Derivative Test

First Derivative Test MA 2231 Lecture 22 - Concavity and Relative Extrema Wednesday, November 1, 2017 Objectives: Introduce the Second Derivative Test and its limitations. First Derivative Test When looking for relative extrema

More information

δ Substituting into the differential equation gives: x i+1 x i δ f(t i,x i ) (3)

δ Substituting into the differential equation gives: x i+1 x i δ f(t i,x i ) (3) Solving Differential Equations Numerically Differential equations are ubiquitous in Physics since the laws of nature often take on a simple form when expressed in terms of infinitesimal changes of the

More information

Function Composition and Chain Rules

Function Composition and Chain Rules Function Composition and s James K. Peterson Department of Biological Sciences and Department of Matematical Sciences Clemson University Marc 8, 2017 Outline 1 Function Composition and Continuity 2 Function

More information

Sin, Cos and All That

Sin, Cos and All That Sin, Cos and All That James K Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University September 9, 2014 Outline Sin, Cos and all that! A New Power Rule Derivatives

More information

Upper and Lower Bounds

Upper and Lower Bounds James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University August 30, 2017 Outline 1 2 s 3 Basic Results 4 Homework Let S be a set of real numbers. We

More information

CPSC 540: Machine Learning

CPSC 540: Machine Learning CPSC 540: Machine Learning Matrix Notation Mark Schmidt University of British Columbia Winter 2017 Admin Auditting/registration forms: Submit them at end of class, pick them up end of next class. I need

More information

CS1210 Lecture 23 March 8, 2019

CS1210 Lecture 23 March 8, 2019 CS1210 Lecture 23 March 8, 2019 HW5 due today In-discussion exams next week Optional homework assignment next week can be used to replace a score from among HW 1 3. Will be posted some time before Monday

More information

Objectives: Review open, closed, and mixed intervals, and begin discussion of graphing points in the xyplane. Interval notation

Objectives: Review open, closed, and mixed intervals, and begin discussion of graphing points in the xyplane. Interval notation MA 0090 Section 18 - Interval Notation and Graphing Points Objectives: Review open, closed, and mixed intervals, and begin discussion of graphing points in the xyplane. Interval notation Last time, we

More information

Notes on numerical solution of differential equations

Notes on numerical solution of differential equations Notes on numerical solution of differential equations Some definitions, for those who don t know: A differential equation is any equation that relates a thing to its derivatives. For instance, Newton s

More information

Conjugate Gradient (CG) Method

Conjugate Gradient (CG) Method Conjugate Gradient (CG) Method by K. Ozawa 1 Introduction In the series of this lecture, I will introduce the conjugate gradient method, which solves efficiently large scale sparse linear simultaneous

More information

Convergence of Sequences

Convergence of Sequences Convergence of Sequences James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University February 12, 2018 Outline Convergence of Sequences Definition Let

More information

Simple ODE Solvers - Derivation

Simple ODE Solvers - Derivation Simple ODE Solvers - Derivation These notes provide derivations of some simple algorithms for generating, numerically, approximate solutions to the initial value problem y (t =f ( t, y(t y(t 0 =y 0 Here

More information

Geometric Series and the Ratio and Root Test

Geometric Series and the Ratio and Root Test Geometric Series and the Ratio and Root Test James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University September 5, 2017 Outline Geometric Series The

More information

x = x y and y = x + y.

x = x y and y = x + y. 8. Conic sections We can use Legendre s theorem, (7.1), to characterise all rational solutions of the general quadratic equation in two variables ax 2 + bxy + cy 2 + dx + ey + ef 0, where a, b, c, d, e

More information