calculus - florida institute of technologymy.fit.edu/~rvw/lectures/calculus 2005.pdfcalculus dn/dt =...

29
Calculus Calculus

Upload: others

Post on 10-Aug-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of

CalculusCalculus

Page 2: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of

CalculusCalculus

dN/dtdN/dt = (= (bb--dd).N).NRate of change in population size with respect Rate of change in population size with respect to time.to time.Right side of equation is the product of the Right side of equation is the product of the population size N, multiplied by the difference population size N, multiplied by the difference between instantaneous births and deathsbetween instantaneous births and deaths

Page 3: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of

r = (r = (bb--dd), is the intrinsic rate of increase (or ), is the intrinsic rate of increase (or instantaneous growth rate. instantaneous growth rate.

dN/dtdN/dt = r. N,= r. N,

When r = 0, births and deaths are When r = 0, births and deaths are balanced, individuals merely replace balanced, individuals merely replace themselves.themselves.

Page 4: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of

LongLong--versionversionIntegrate Integrate dN/dtdN/dt = r. N,= r. N,First First dNdN = = r.Nr.N dtdt,,Then Then dNdN/N = r. /N = r. dtdtThen integrate, summing changes in population size over the inteThen integrate, summing changes in population size over the interval from rval from ttoo to t, to t, ln.N(t) – ln.N(to) = rt – rto

Rearrange againRearrange againexp exp ln.N(tln.N(t) ) –– ln.N(toln.N(to)) = = expexprtrt--rtorto

N(t)/N(toN(t)/N(to) = exp ) = exp rtrt--rtorto

If to = 0, then If to = 0, then N(tN(t) = ) = N(tN(too).).eertrt

or or

lnln N(tN(t) = ) = lnln N(tN(too) + ) + r.tr.t

Page 5: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of

CalculusCalculus

function ndot=expgrow(t,n);global r;ndot=r*n;

global r;r=0.5;[t,n]=ode23('expgrow',0:10,2);plot(t,n)

Page 6: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of

function dx= calculus(r,N)function dx= calculus(r,N)dx = r*N;dx = r*N;

Page 7: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of

fodesol('calculusfodesol('calculus', 0, 2, 0 , 10)', 0, 2, 0 , 10)

Page 8: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of

help fodesolhelp fodesol

function function fodesol(F,tmin,tmax,xmin,xmaxfodesol(F,tmin,tmax,xmin,xmax))

fodesol obtains an approximate solution to the ODEfodesol obtains an approximate solution to the ODEdx/dx/dtdt = = f(x,tf(x,t) by the ) by the RungeRunge--KuttaKutta--FehlbergFehlbergmethod ODE23 supplied with MATLAB (2nd/3rdmethod ODE23 supplied with MATLAB (2nd/3rdorder version) and compares the solutionsorder version) and compares the solutionswith a "grain" (or field) plot.with a "grain" (or field) plot.

F is a string containing the name of a realF is a string containing the name of a realfunction function f(x,tf(x,t), supplied in an M), supplied in an M--file.file.e.g. e.g. fnxt.mfnxt.m

tmin,tmaxtmin,tmax andandxmin,xmaxxmin,xmax are limits for the plotare limits for the plot

usage e.g.usage e.g.fodesol('fnxt',0, 2.5, fodesol('fnxt',0, 2.5, --3 , 3)3 , 3)

Page 9: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of
Page 10: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of

Pick initial tPick initial t--value: 0 value: 0 Pick initial xPick initial x--value: 2value: 2please wait...please wait...

Page 11: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of
Page 12: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of

Initial and final points (Initial and final points (t,xt,x) of solution were) of solution wereInitial FinalInitial Final0 20 2

2.0000 14.76392.0000 14.7639

Page 13: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of

function dx= calculus(r,N)function dx= calculus(r,N)global kglobal kdx = r*N*(kdx = r*N*(k--N/k);N/k);

Page 14: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of

The solution isThe solution is

X(tX(t) = K/(1) = K/(1--(1(1--K/xK/xoo).exp).exp--r.tr.t))

Page 15: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of

>> k= 2;>> k= 2;>> fodesol('calculus2',0,2,0,10)>> fodesol('calculus2',0,2,0,10)

Page 16: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of

The solution isThe solution is

X(tX(t) = K/(1) = K/(1--(1(1--K/xK/xoo).exp).exp--r.tr.t))

Page 17: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of
Page 18: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of

Pick initial tPick initial t--value: 0value: 0Pick initial xPick initial x--value: 1value: 1please wait...please wait...

Page 19: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of
Page 20: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of

Initial and final points (Initial and final points (t,xt,x) of solution were) of solution wereInitial FinalInitial Final0 20 2

1.0000 15.92181.0000 15.9218

Page 21: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of
Page 22: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of
Page 23: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of

ODE23 Solve nonODE23 Solve non--stiff differential stiff differential equations, low order method.equations, low order method.

[T,Y] = ODE23(ODEFUN,TSPAN,Y0) [T,Y] = ODE23(ODEFUN,TSPAN,Y0) with TSPAN = [T0 TFINAL] integrates thewith TSPAN = [T0 TFINAL] integrates the

system of differential equations y' = system of differential equations y' = f(t,yf(t,y) from time T0 to TFINAL with) from time T0 to TFINAL with

initial conditions Y0.initial conditions Y0.

Page 24: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of

Example Example [[t,yt,y]=]=ode23ode23(@vdp1,[0 20],[2 0]); (@vdp1,[0 20],[2 0]); plot(t,y(:,1));plot(t,y(:,1));

solves the system y' = vdp1(t,y), using the solves the system y' = vdp1(t,y), using the default relative errordefault relative error

tolerance 1etolerance 1e--3 and the default absolute 3 and the default absolute tolerance of 1etolerance of 1e--6 for each6 for each

component, and plots the first component of component, and plots the first component of the solution. the solution.

Page 25: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of

global r c D a k1 k2 k3global r c D a k1 k2 k3%copy above into command window%copy above into command windowr=0.4; c=0.05; D=0.05;r=0.4; c=0.05; D=0.05;k1=0.01; k2=0.01; k3 = 0.01;k1=0.01; k2=0.01; k3 = 0.01;a=0.1;a=0.1;%copy above into command window%copy above into command window[t a]=ode45('recruits', 0:0.1:50,[r;c;D]);[t a]=ode45('recruits', 0:0.1:50,[r;c;D]);h=figure; hold onh=figure; hold onplot(t,a(:,1),':')plot(t,a(:,1),':')plot(t,a(:,2),'plot(t,a(:,2),'--')')plot(t,a(:,3),'plot(t,a(:,3),'----')')axis([0 50 0 2])axis([0 50 0 2])xlabel('Timexlabel('Time (years)')(years)')ylabel('Instantaneousylabel('Instantaneous rate of change')rate of change')

Page 26: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of
Page 27: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of

function function ndotndot ==recruits(t,nrecruits(t,n))global r c D a k1 k2 k3;global r c D a k1 k2 k3;ndot(1,1) = ndot(1,1) = --k1*r + k2*D; k1*r + k2*D; ndot(2,1) = k1*r ndot(2,1) = k1*r -- k3*c/(1+a*c);k3*c/(1+a*c);ndot(3,1) = k3*c/(1+a*c) ndot(3,1) = k3*c/(1+a*c) -- k2*D;k2*D;

Page 28: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of
Page 29: Calculus - Florida Institute of Technologymy.fit.edu/~rvw/Lectures/Calculus 2005.pdfCalculus dN/dt = (b-d).N Rate of change in population size with respect . to time. Right side of

pdepepdepe

Partial differential equations…Partial differential equations…

Maybe another day…Maybe another day…