29 views

Uploaded by babackbm

save

- The Lattice Boltzmann Equation
- Matlab Tutorial for Slopefield
- matlab
- 1-s2.0-S0096300302001741-main
- numericals-report_superfinal.pptx
- Numerical Analysis Using MATLAB
- Zingg_CFD_Ch6
- lab1
- Improvement of the Resolution of an Instrument by Numerical Solution of an Integral Equation
- 36726 - Mathematical Methods in Engineering
- BOOK_Numerical Analysis Using MATLAB and Excel - 3rdEd - ST.karris - Orchard 2007
- Application of Modified EP Method in Steady Seepage Analysis
- Green_Function_Notes
- 2nd Order Autonomous ODE
- BSET
- Linear Differential Equations
- Choice of Numerical Integration Method for Wind Time History Analysis of Tall Buildings
- Numerical Methods -En
- Btech Mme 2011
- 1_136_147_89_1258
- Lecture 8 Homogeneous Linear ODE With Constant Coefficients
- Implicit method
- jitkumar
- CompactNumerical Methods for ComputersLinearAlgebra_muya
- How to Study Physics
- Chapter 5 - Collection and Analysis of Rate Data
- Vssut ETC-NEW Syllabus From 2015
- FEA types
- Na Notes
- CV Shradha
- Dispatches from Pluto: Lost and Found in the Mississippi Delta
- Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
- The Innovators: How a Group of Hackers, Geniuses, and Geeks Created the Digital Revolution
- Sapiens: A Brief History of Humankind
- The Unwinding: An Inner History of the New America
- Yes Please
- A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
- Grand Pursuit: The Story of Economic Genius
- This Changes Everything: Capitalism vs. The Climate
- The Emperor of All Maladies: A Biography of Cancer
- The Prize: The Epic Quest for Oil, Money & Power
- John Adams
- Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
- The World Is Flat 3.0: A Brief History of the Twenty-first Century
- Rise of ISIS: A Threat We Can't Ignore
- Smart People Should Build Things: How to Restore Our Culture of Achievement, Build a Path for Entrepreneurs, and Create New Jobs in America
- The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
- Team of Rivals: The Political Genius of Abraham Lincoln
- The New Confessions of an Economic Hit Man
- How To Win Friends and Influence People
- Angela's Ashes: A Memoir
- Steve Jobs
- Bad Feminist: Essays
- You Too Can Have a Body Like Mine: A Novel
- The Incarnations: A Novel
- The Light Between Oceans: A Novel
- The Silver Linings Playbook: A Novel
- Leaving Berlin: A Novel
- Extremely Loud and Incredibly Close: A Novel
- The Sympathizer: A Novel (Pulitzer Prize for Fiction)
- A Man Called Ove: A Novel
- Bel Canto
- The Master
- The Blazing World: A Novel
- The Rosie Project: A Novel
- The First Bad Man: A Novel
- We Are Not Ourselves: A Novel
- Brooklyn: A Novel
- The Flamethrowers: A Novel
- Life of Pi
- The Love Affairs of Nathaniel P.: A Novel
- The Perks of Being a Wallflower
- Lovers at the Chameleon Club, Paris 1932: A Novel
- The Bonfire of the Vanities: A Novel
- A Prayer for Owen Meany: A Novel
- My Sister's Keeper: A Novel
- The Cider House Rules
- The Art of Racing in the Rain: A Novel
- Wolf Hall: A Novel
- The Wallcreeper
- Interpreter of Maladies
- Beautiful Ruins: A Novel
- The Kitchen House: A Novel
- Carta de Lucifer
- Engine
- Siemens BS-240 / BS-241 Brochure
- Unidad 5
- Chapter Pressure Sensors
- Dossier Maquinas e Instalaciones Electricas - Electronicas
- El Índice de Trabajo WI
- 3046_Marpol_Anx_III
- RTOS_QP_MR
- 2.-Parámetros Del Reservorio de sección cuadrada
- Jaundice Remedies _ Herbal
- Help Your Clients Calculate True Lifestyle Costs of a Home
- Igd-m3 Aircraft Maintenance Organization Approval _private Category Only_1
- Cutaneous Larva Migrans
- Fórmula de Stokes
- Lanchonete
- Psicologia Da Aprendizagem
- TEMA-12-Defectos-en-la-madera-rolliza.pdf
- Blanket.htm
- As Bruxas de Salem
- Redecard Manual Movimentos Financeiros Desenvolvedores
- The Chi-squared Distribution
- Interaccion Portico - Muro
- Common Questions on Silage Management
- Pupi y El Club de Los Dinosaurios
- Curriculum - Prothetik Band I.pdf
- Posdata Te Amo
- Manual de Galvanotecnia
- 1._FARMACOCINÉTICA
- 20110203100116moptc

You are on page 1of 7

**MATLAB has a number of tools for numerically solving ordinary differential equations. We
**

will focus on one of its most rudimentary solvers, ode45, which implements a version of the

Runge–Kutta 4th order algorithm. (This is essentially the Taylor method of order 4, though

implemented in an extremely clever way that avoids partial derivatives.) For a complete list

of MATLAB’s solvers, type helpdesk and then search for nonlinear numerical methods.

**First Order Equations
**

Example 1. Numerically approximate the solution of the first order differential equation

dy

= xy 2 + y; y(0) = 1,

dx

on the interval x ∈ [0, .5].

For any differential equation in the form y ′ = f (x, y), we begin by defining the function

f (x, y). For single equations, we can define f (x, y) as an inline function. Here,

**>>f=inline(’x*yˆ2+y’)
**

f=

Inline function:

f(x,y) = x*yˆ2+y

The basic usage for MATLAB’s solver ode45 is

ode45(function,domain,initial condition).

That is, we use

>>[x,y]=ode45(f,[0 .5],1)

and MATLAB returns two column vectors, the first with values of x and the second with

values of y. (The MATLAB output is fairly long, so I’ve omitted it here.) Since x and y are

vectors with corresponding components, we can plot the values with

>>plot(x,y)

**which creates Figure 1.
**

Choosing the partition. In approximating this solution, the algorithm ode45 has

selected a certain partition of the interval [0, .5], and MATLAB has returned a value of y at

each point in this partition. It is often the case in practice that we would like to specify the

partition of values on which MATLAB returns an approximation. For example, we might

only want to approximate y(.1), y(.2), ..., y(.5). We can specify this by entering the vector

of values [0, .1, .2, .3, .4, .5] as the domain in ode45. That is, we use

1

1 0.3 0.7 Figure 1: Plot of the solution to y ′ = xy 2 + y.3000 0.3000 0.1000 0.4 1.5 0.1000 0. no accuracy is lost.6 1.0000 1. the only thing that has changed is the values at which it is printing a solution.4 0.0000 It is important to point out here that MATLAB continues to use roughly the same partition of values that it originally chose. >>xvalues=0:.4000 0.2 0.1:.2000 0. Several options are available for MATLAB’s ode45 solver.7 1.5000 >>[x.6 0.2000 0.1111 1.2500 1. giving the user lim- ited control over the algorithm. Two important options are relative and absolute tolerance.1) x= 0 0.1 1 0 0.9 1.5 1.5 xvalues = 0 0.5000 y= 1.xvalues.8 1. 2 1.4000 0. with y(0) = 1.6667 2. respecively RelTol and AbsTol in MATLAB. Options. In this way.2 1. an error 2 .y]=ode45(f.3 1. At each step of the ode45 algorithm.4286 1.

c = . dt with a = . y20 = 4. b = . 3 .y) %LV: Contains Lotka-Volterra equations a = . we increase the value of RelTol.1]. >>options=odeset(’RelTol’. y2 (0) = y20.001 and AbsTol = .) In order to fix this problem.r = .[0.is approximated for that step.1).1e-10).y]=ode45(f. (These values correspond with data collected by the Hudson Bay Company between 1900 and 1920. yprime = [a*y(1)-b*y(1)*y(2). I’ve computed the maximum value of y(x) to show that it is indeed quite large.0266. >>max(y) ans = 2. >>[x. then the error ek will be allowed to grow quite large. we must define it as an M-file. △ Systems of ODE Solving a system of ODE in MATLAB is quite similar to solving a single equation. If yk is the approximation of y(xk ) at step k.8439.options).0266.425060345544448e+07 In addition to employing the option command. where the default values are RelTol = .[0. we find that the command >>[x. leads to an error message. with the default error tolerances.1.000001.5471.) In this case.m: function yprime = lv(t.y]=ode45(f. though since a system of equations cannot be defined as an inline function.b = . though not as large as suggested by the previous calculation. (Note at the top of the column vector for y that it is multipled by 1014 . y1 (0) = y10 dt dy2 = − ry2 + cy1 y2 .5471. r = . caused by the fact that the values of y are getting too large as x nears 1. In fact. Solve the Lotka–Volterra predator–prey system dy1 = ay1 − by1 y2 . we choose a smaller value for RelTol.1]. with y(0) = 1.-r*y(2)+c*y(1)*y(2)]. c = . observe that if yk becomes large. As an example for when we might want to change these values. and y10 = 30.0281.0281. then MATLAB chooses its partition to insure ek ≤ max(RelTol ∗ yk . the values of y get quite large as x nears 1. In this case.8439. and ek is the approximate error at this step. AbsTol). Example 2. we begin by writing the right hand side of this equation as the MATLAB M-file lv. For the equation y ′ = xy 2 + y.

y(:.[30.y(:. In this way.y]=ode45(@lv. Figure 2 can be created with the command >>plot(t.1). the integral curve is closed. we often want to experiment with parameter values.t. In this case. so we can refer to the entire first column of y with y(:. In fact. we would often like a computer program 4 .2)) which creates Figure 4. For example. In general.[0 20]. and r. c. we can plot the predator population along with the prey population with >>plot(t. m) corresponds with the entry of y at the intersection of row n and column m. y(n.2).y(:.4]) The output from this command consists of a column of times and a matrix of populations. 1). (Such an integral curve is called a cycle. Similarly. we might want to solve the Lotka–Volterra system with different values of a.’–’) where the predator population has been dashed (see Figure 3). In analyzing systems of differential equations. where the colon means all entries.) Passing parameters. we can plot an integral curve in the phase plane with >>plot(y(:. b. Finally. and we see that the populations are cyclic. Suppose we would like to plot the prey population as a function of time.y(:.We can now solve the equations over a 20 year period as follows: >>[t. The first column of the matrix corresponds with y1 (prey in this case) and the second corresponds with y2 (predators).1).1)) 80 70 60 50 40 30 20 10 0 0 2 4 6 8 10 12 14 16 18 20 Figure 2: Prey populations as a function of time.

b. so I have simply placed an empty set here.5471 .params).-r*y(2)+c*y(1)*y(2)]. we will alter lv. We have function yprime = lvparams(t.[0 20].[]. designated by two square brackets pushed together. In order to see how this works. to try different values of these parameters (typically while searching for a set that correspond with certain behavior). Example 3. r=params(4). △ Higher Order Equations In order to solve a higher order equation numerically in MATLAB we proceed by first writing the equation as a first order system and then proceeding as in the previous section. >>[t. y ′(0) = 3 5 .8439]. MATLAB requires a statement in the position for options. >>params = [.y]=ode45(@lvparams. and r are taken as input. 80 70 60 50 40 30 20 10 0 0 2 4 6 8 10 12 14 16 18 20 Figure 3: Plot of predator and prey populations for the Lotka–Volterra model.0281 . c=params(3). Solve the second order equation y ′′ + x2 y ′ − y = sin x. We can now send the parameters with ode45. yprime = [a*y(1)-b*y(1)*y(2). c. and so we require a method that doesn’t involve manually altering our file ODE file every time we want to change parameter values.params) %LVPARAMS: Contains Lotka-Volterra equations a=params(1).[30. b=params(2). We can accomplish this by passing the parameters through the function statement.4].m so that the values a.0266 . y(0) = 1.y.

1]. which is stored in the MATLAB M-file secondode. ′ y1′ = y2 .1)) Assignments 1. y(0) = 1. Turn in a plot of your approximation. dx y on the interval x ∈ [0. y(1)-xˆ2*y(2)+sin(x)].y(:. 6 . on the interval x ∈ [0. y1 (0) = 1 y2′ = y1 − x2 y2 + sin x. %SECONDODE: Computes the derivatives of y 1 and y 2.5]. >>plot(x. In this way. function yprime = secondode(x. which produces Figure . 60 50 40 30 20 10 0 0 10 20 30 40 50 60 70 80 Figure 4: Integral curve for the Lotka–Volterra equation.. %as a colum vector yprime = [y(2).m.[0. Numerically approximate the solution of the first order differential equation dy x = + y.y).. we set y1 (x) = y(x) and y2 (x) = y (x). 5]. y2 (0) = 3. We can now proceed with the following MATLAB code.3]). In order to write this equation as a first order system.[1. >>[x.y]=ode45(@secondode.

p0 + (K − p0 )e−rt For parameter values r = .7498 (consistent with the U. proceeding so that MATLAB only returns values for x0 = 0. x2 = . t=1 4. 2. Numerically approximate the solution of the SIR epidemic model dy1 = − by1 y2 . Repeat Problem 3 with RelTol = 10−10 . y(0) = 1.0022 and initial values y10 = 762 and y20 = 1. y1 (0) = y10 dt dy2 = by1 y2 − ay2 . p(0) = p0 . S.2. Check that the maximum of this last plot is at ab . solve the logistic equation numerically for t ∈ [0.5 5 Figure 5: Plot of the solution to y ′′ + x2 y ′ − y = sin x.5 2 2. and discuss how this plot corresponds with our stability analysis for this equation.4362 and b = . Repeat Problem 1. and for initial value p0 = 7. Turn in a list of values y(x1 ). Also.. x1 = . 20].0215. and give values for Sf and SR as defined in class. y(x2) etc. . dt with parameter values a = . y ′(0) = 3. 3.1825. dt K is solved by p0 K pexact (t) = . 7 . Turn in a plot of susceptibles and infectives as a function of time for t ∈ [0.5 4 4. x10 = 1.5 3 3. population in millions).5 1 1... 200]. y2 (0) = y20. 14 12 10 8 6 4 2 0 0 0. K = 446. and compute the error X200 E= (p(t) − pexact (t))2 . The logistic equation dp p = rp(1 − ). plot y2 as a function of y1 . 5.1.

- The Lattice Boltzmann EquationUploaded byjvleon
- Matlab Tutorial for SlopefieldUploaded byJA55EE
- matlabUploaded byPujara Manish
- 1-s2.0-S0096300302001741-mainUploaded byKanthavel Thillai
- numericals-report_superfinal.pptxUploaded byAdelle Lyn Carlos
- Numerical Analysis Using MATLABUploaded byMehmet Ocak
- Zingg_CFD_Ch6Uploaded bytomekzawistowski
- lab1Uploaded bywhyun1994
- Improvement of the Resolution of an Instrument by Numerical Solution of an Integral EquationUploaded byNarinder Singh Johal
- 36726 - Mathematical Methods in EngineeringUploaded byJagermeist
- BOOK_Numerical Analysis Using MATLAB and Excel - 3rdEd - ST.karris - Orchard 2007Uploaded byminicarbon6
- Application of Modified EP Method in Steady Seepage AnalysisUploaded byEndless Love
- Green_Function_NotesUploaded bySeongsoo Choi
- 2nd Order Autonomous ODEUploaded byHumbertoCeara
- BSETUploaded bybalaji817150
- Linear Differential EquationsUploaded bySajob Karakatil
- Choice of Numerical Integration Method for Wind Time History Analysis of Tall BuildingsUploaded byinventy
- Numerical Methods -EnUploaded byKhasan Mustofa
- Btech Mme 2011Uploaded byVigneshShankar
- 1_136_147_89_1258Uploaded byPaola Andrea Mejia Rodriguez
- Lecture 8 Homogeneous Linear ODE With Constant CoefficientsUploaded byRajSarkar
- Implicit methodUploaded byshekhadaa
- jitkumarUploaded byVarun Sogani
- CompactNumerical Methods for ComputersLinearAlgebra_muyaUploaded byAbdallah Neily
- How to Study PhysicsUploaded byJames Bateman
- Chapter 5 - Collection and Analysis of Rate DataUploaded byHasrul Hisham
- Vssut ETC-NEW Syllabus From 2015Uploaded byManoj Mohanty
- FEA typesUploaded byViraj Baraskar
- Na NotesUploaded byAnonymous Yc54u9
- CV ShradhaUploaded byShreyas Gupta

- Carta de LuciferUploaded bySabonim Rogelio Buenrostro
- EngineUploaded byAndre Jose Fragoso
- Siemens BS-240 / BS-241 BrochureUploaded byNick Wencil
- Unidad 5Uploaded byWilliam Hernandez
- Chapter Pressure SensorsUploaded byPiotr Prokulski
- Dossier Maquinas e Instalaciones Electricas - ElectronicasUploaded byNiel Barchi
- El Índice de Trabajo WIUploaded byjos18net
- 3046_Marpol_Anx_IIIUploaded byBharat Sharma
- RTOS_QP_MRUploaded bySandeepSharma
- 2.-Parámetros Del Reservorio de sección cuadradaUploaded byBericht Frexs Vasquez Onzueta
- Jaundice Remedies _ HerbalUploaded byherat16
- Help Your Clients Calculate True Lifestyle Costs of a HomeUploaded bymlsli
- Igd-m3 Aircraft Maintenance Organization Approval _private Category Only_1Uploaded byPaul Watkins
- Cutaneous Larva MigransUploaded byanissabilfaqih
- Fórmula de StokesUploaded byIlse Gomez
- LanchoneteUploaded byJefersonSantos
- Psicologia Da AprendizagemUploaded byAllan Kardec Pereira
- TEMA-12-Defectos-en-la-madera-rolliza.pdfUploaded bycristianquispecc
- Blanket.htmUploaded byvinoohm
- As Bruxas de SalemUploaded byRaquel Parras
- Redecard Manual Movimentos Financeiros DesenvolvedoresUploaded byStefanoSouza39
- The Chi-squared DistributionUploaded bySyahrul Munir
- Interaccion Portico - MuroUploaded bySantiago Cuellar
- Common Questions on Silage ManagementUploaded byJesse James
- Pupi y El Club de Los DinosauriosUploaded byEnoc Esau Santander Bravo
- Curriculum - Prothetik Band I.pdfUploaded byAnu
- Posdata Te AmoUploaded byAugusto Vazquez
- Manual de GalvanotecniaUploaded byCarlos R. Romaní Santillán
- 1._FARMACOCINÉTICAUploaded byAmadeu Vinicius Carvalho
- 20110203100116moptcUploaded byEntimologist