• Keine Ergebnisse gefunden

Scientific computing | Week 9 Linear algebra and dynamical systems

N/A
N/A
Protected

Academic year: 2022

Aktie "Scientific computing | Week 9 Linear algebra and dynamical systems"

Copied!
60
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Scientific computing | Week 9

Linear algebra and dynamical systems

Volker Roth, Ivan Dokmanić

(2)

Why study differential equations?

Finance Engineering

Life sciences Physics Environment

But differential equations are so 20th century :-(

{Epi, Pan}demics

Neuroscience

Planetary dynamics

Turbulence

concentration CO2

Ice melting

Heat transfer

Trajectory design

Black–Scholes

Market crashes

2

(3)

Recap: linear ODEs with linear algebra

du

dt = Au

u′ (t) = αu(t) u(t) = e

αt

u(0) u(t) = e

At

u

0

A system of first-order linear ODEs (homogeneous, constant-coefficient)

Entries of model positions, velocities,

u

CO2 concentrations, …

u(t) ∈ ℝ

n

A ∈ ℝ

n×n

Scalar case (

n = 1

) Vector case

(4)

The meaning of e At

Defined via the Taylor (power) series

e

At

:= ∑

k=0

(At)

k

k !

(e

At

)′ := ∑

k=1

kt

k−1

A

k

k ! = A

k=1

t

k−1

A

k−1

(k − 1)! = A

k=0

t

k

A

k

k ! = Ae

At

Use to check the solution

4

For diagonalizable matrices, we get a very simple rule

A = V

λ

1

0 ⋯ 0

0 λ

2

⋱ 0

0 ⋱ ⋱ 0

0 ⋯ 0 λ

n

V

−1

e

At

= V

e

λ1t

0 ⋯ 0 0 e

λ2t

⋱ 0

0 ⋱ ⋱ 0

0 ⋯ 0 e

λnt

V

−1

(5)

Behavior of first-order equations for n = 1

u′ (t) = αu(t)

When is a real number,

α

u(t) = e

αt

u(0)

In this case the possible dynamics are quite boring… (but they can also be dangerous!)

(6)

Not so boring: second-order differential equations

mx′ ′ + bx′ + kx = 0

0

∆x x

kx

θ

mg

+

i u

6

(7)

Mass on a spring

F

G

= mg F

S

= − k(s + x)

ACME ACME

ACME

ACME

Equilibrium

mg = ks

Natural spring position

(8)

Mass on a spring

x′ ′ = − ω

2

x

u := [ x

x′ ] du

dt := [ x′

x′ ′ ] = [ 0 1

ω

2

0 ]

A

[ x x′ ]

u

F

G

= mg F

S

= − k(s + x)

F

tot

= F

S

+ F

G

mx′ ′ + kx = 0

Gravitational force Restoring force in the spring

k = ω

2

8

Newton says

F

tot

= ma = mx′

A second-order linear ODE! Converting to first order lets us use linear algebra:

(9)

Writing down the solution

u(t) = c

1

e

jωt

v

1

+ c

2

e

−jωt

v

2

By solving

det(λI − A) = 0

we get the eigenvalues of as

A λ

1

= jω λ

2

= −

Solving

Av

1,2

= λ

1,2

v

1,2 we further get the eigenvectors

v

1

= [ 1

λ

1

] = [ 1

] v

2

= [ 1

λ

2

] = [ 1

]

u(0) = c

1

v

1

+ c

2

v

2

Any solution can thus be written as (for some constants and )

c

1

c

2

The constants and can be determined from two initial conditions (on and )

c

1

c

2

x x′

(10)

We get the familiar harmonic oscillations

x(t) = c

1

e

jωt

+ c

2

e

−jωt

ℑ(x(t)) = 0 |

t=0

⟹ ℑ(c

1

) = − ℑ(c

2

) ℑ(x(t)) = 0 |

t= π2

⟹ ℜ(c

1

) = ℜ(c

2

)

c

1

= c

2

x(t) = A cos(ωt) + B sin(ωt) = α sin(ωt + ϕ)

10

So finally, for some real and (or and )

A B α ϕ

(11)

du

dt := [ x′

x′ ′ ] = [ 0 1

k / mb / m ]

A

[ x x′ ]

u

mx′ ′ + bx′ + kx = 0

now gives the full second-order equaton

F

S

+ F

G

+ F

D

= mx′

The force

F

D

= − bx′

describes damping, friction, proportional to velocity

Damped oscillations with F D = − bx′

Rewrite again as a first-order system

(12)

General solution

λ

1

= − b + b

2

− 4mk

2m λ

2

= − bb

2

− 4mk 2m

x(t) = c

1

e

λ1t

+ c

2

e

λ2t

Solving

det(λI − A) = 0

gives

General solution

Behavior depends on the sign of the discriminant

b

2

− 4mk ≶ 0

12

(13)

Different kinds of solutions

Overdamped Underdamped

b

2

> 4mk b

2

< 4mk

x(t) = c

1

e

λ1t

+ c

2

e

λ2t

λ

1,2

< 0

ℜ(λ

1

) = ℜ(λ

2

) < 0

x(t) = e

−αt

(A cos(ωt) + B sin(ωt))

(14)

Forced oscillations

mx′ ′ (t) + bx′ (t) + kx(t) = f (t)

So far: the right-hand side of the ODE is zero: natural modes of the spring-mass system In most practical applications there is an external forcing

• A voltage source in a circuit

• Uneven road hits the wheels

• Greenhouse gas emissions

In our second-order linear case this is modeled as a right-hand side

f (t)

14

(15)

General solution to the non-homogeneous equation

x(t) = c

1

x

1

(t) + c

2

x

2

(t) + x

p

(t)

In a damped system, dictates the long-term behavior—steady-state solution

x

p

Solution to the homogeneous equation

mx′ ′ + bx′ + kx = 0

A particular solution

A general solution to

mx′ ′ (t) + bx′ (t) + kx(t) = f (t)

can be written as

(16)

Forced oscillations: example

x′ ′ + 8x′ + 16x = 8 sin(4t)

A = [ 0 1

− 16 − 8 ] e

At

=

[ e

−4t

(4t + 1) te

−4t

− 16te

−4t

e

−4t

(4t − 1) ] x

h

(t) = c

1

e

−4t

+ c

2

te

−4t

16

Homogeneous

x(0) = x′ (0) = 0

(17)

Forced oscillations: total solution

Method of undetermined

coefficients suggests to try

x

p

(t) = A cos(4t) + B sin(4t) x

p

(t) = −

14

cos(4t)

Particular

(From Wikipedia)

Total

14

e

−4t

+ te

−4t

14

cos(4t)

(18)

Resonance

Systems that are not overdamped have their own natural modes or resonant frequencies

https://sites.lsa.umich.edu/ksmoore/research/tacoma-narrows-bridge/

x′ ′ (t) + x(t) = 5 cos(t)

x(t) = x

h

(t) + x

p

(t)

= A sin(t + φ)+

12

t sin(1t) x

p

(t) =

12

t sin(1t)

18

• Homogeneous solution is

x

h

(t) = A sin(t + φ)

Example

• Method of undetermined coefficients gives

• The total solution is then

(19)

It happens even in real systems with damping!

(20)

Application 1: Predicting the CO 2 concentration in the atmosphere

20

(21)

The DICE model

(Therina Groenewald/Shutterstock) (https://www.unenvironment.org/)

The Dynamic Integrated Climate-Economy model

Economics Carbon cycle Climate science Policy William Nordhaus, 2018 Nobel Prize in Economics

Subject of quite a bit of controversy (likely a gross underestimate of the adverse effects)

(22)

Coupling between the CO 2 containers

22

k

a

k

a

k

d

k

d

Atmosphere

Upper ocean

Lower ocean

• An example of a box model: split the total CO2 into boxes (atmosphere, upper and lower ocean)

• The boxes exchange CO2 with certain rates (often determined via experimental fitting)

(23)

Coupling between the CO 2 containers

dMAT

dt = E(t) ka (MAT A B MUP) dMUP

dt = ka (MAT A B MUP) kd (MUP MLO δ ) dMLO

dt = kd (MUP MLO δ )

MAT, MUP, MLO model CO2 mass in atmosphere, upper, and lower ocean (in gigaton)

E(t) is the emission rate (gigaton / year)

AB is the equilibrium ratio of CO2 between the atmosphere and the upper ocean

• is the volume ratio between upper and lower oceanδ

ka, are kd CO2 exchange rates between atmosphere/upper ocean and upper/lower ocean

ka ka

kd kd

(24)

A linear algebra problem?

24

dm

dt = Km + e(t) K =

k

a

k

a

AB 0 k

a

k

a

ABk

d

k

d

/ δ

0 k

d

k

d

/ δ

e(t) = E(t) 0 0

• Now we have an inhomogeneous system of ODEs

• Is there a “principled” way to integrate (solve) such systems?

m =

M

AT

M

UP

M

LO

(25)

Solving the inhomogeneous equation

We now know that when is constant in time, the solution to

K dm

is

dt = Km m(t) = e

Kt

m(0)

dm

dt = Km + e(t)

Duhamel’s principle

Massage the inhomogeneous equation into a homogeneous form

e

tK

d

dt ( e

−tK

m(t) ) = e(t) m(t) = e

tK

m(0) +

t

0

e

(t−s)K

e(s)ds

It follows that

(26)

CO emission scenarios 2

26

Representative concentration pathways

(RCPs): Emission scenarios from pre-industrial period to year 2050

RCP4.5 = intermediate emission; emissions peak in 2040 and then decline

RCP8.5 = business-as-usual emissions;

worst case

• Consolidated by the Intergovernmental Panel on Climate Change (IPCC)

(27)

Approximating the integral by the trapezoidal rule

t

0

e

(t−s)K

ds ≃ ∑

N

j=0

Δt

2 ( e

(t−jΔt)K

+ e

(t−( j+1)Δt)K

)

(Wikipedia)

(28)

CO2 concentration and the surface temperature

28

• The temperature change with respect to a pre-industrial reference is estimated as

ΔT = α

λ log2

(

MAT

MAT,ref )

α = 3.8 W/m2

λ = 1.3 W/m2/C

MAT,ref = 596.4 GtC

(29)

Limitations of the model

• A major limitation of the model is that is a constant matrix independent of time and the current concentrations

• In reality the carbonate chemistry dictates that the absorption capacity of the ocean drops after initial absorption, resulting in huge errors over longer timescales

• One remedy is to allow the coefficients to depend on time and the current concentrations

K

k

a

, k

d

, AB, … M

AT

, M

UP

, M

LO

• NB: Nordhaus’s work and models have been even more heavily criticized for how they

measure economic utility, in that they “overemphasize growth as the ultimate measure of economic success” (https://www.sciencemag.org/news/2018/10/roles-ideas-and-climate-growth-earn-duo-economics-nobel-prize)

(30)

Limitations of the model

29

• A major limitation of the model is that is a constant matrix independent of time and the current concentrations

• In reality the carbonate chemistry dictates that the absorption capacity of the ocean drops after initial absorption, resulting in huge errors over longer timescales

• One remedy is to allow the coefficients to depend on time and the current concentrations

K

k

a

, k

d

, AB, … M

AT

, M

UP

, M

LO

• NB: Nordhaus’s work and models have been even more heavily criticized for how they

measure economic utility, in that they “overemphasize growth as the ultimate measure of economic success” (https://www.sciencemag.org/news/2018/10/roles-ideas-and-climate-growth-earn-duo-economics-nobel-prize)

(31)

Application 2: Modeling the COVID-19 pandemic

(32)

The simplest useful model: SIR

31

(From Wikipedia)

(33)

The MSEIR (…) family of models

Idea: divide population into groups according to their status relative to the disease

(34)

The simplest useful model: SIR

S λS I γI R

dS

dt = − β I

N S dI

dt = β I

N SγI dR

dt = γI

33

λ = β I

Infection rate

N

Recovery rate

γ

(35)

Is this a linear algebra problem?

• Letting , can we write for some matrix that does not depend on

?

u(t) = S(t) R(t) I(t)

du(t)

dt = Au(t) A

S, I, R

• Sadly, no… the expressions contain multiplications between and

S I dS

dt = − β I(t)

N S(t) dI

dt = β I(t)

N S(t)γI(t)

• A superposition of two solutions is in general not a solution

• Perhaps not everything is lost…

(36)

SIR curves

35

(37)

(

36

(38)

Stability of dynamical systems / ODEs

f (t) = f (t

0

) + f ′ (t

0

)(t − t

0

) + O( | tt

0

|

2

)

37

Key principle When things are non-linear, linearize them!

Taylor series (first two terms)

Key question Linearize about which point? How to choose ?

t

0

(39)

Equilibria of dynamical systems

du(t)

dt = F(t, u(t))

du

dt = 0F(t, u(t)) = 0

Good choice: equilibria of

In an equilibrium, does not change:

u

What happens when we tap a system in equilibrium?

(40)

Stable and unstable equilibria

Unstable Stable

du

dt = 0 du

dt = 0

39

(41)

A stability criterion

du

dt = αu

• Let us look at a simple first-order ODE

• Equilibria are at

du

which is solved by

dt = 0 u = u

0

= 0

• We know that a general solution is given as

u(t) = ce

αt

When we perturb the system around an equilibrium, do we come back to the equilibrium or we go away from it?

• Thus starting from a point , do we go back to or not?

We already know this!

u(0) = u

0

+ ϵ = ϵ 0

α < 0

stable

α > 0

unstable

(42)

A stability criterion

41

du

dt

u=u

0

= f (u

0

+ ϵ)f (u

0

) + f ′ (u

0

)ϵ = f ′ (u

0

• The key parameter in a linear first-order ODE is ;

we would like to generalize to with a nonlinear .

du α

dt = f (u) f (u)

• For the linear , the key parameter equals .

Coincidence?

f (u) = αu α f ′ (u)

• What happens when we move very slightly out of an equilibrium?

(43)

A stability criterion

du

dt

u=u

0

= f (u

0

+ ϵ)f (u

0

) + f ′ (u

0

)ϵ = f ′ (u

0

A constant scalar

• For small (close to ) the above approximation is accurate:

ϵ U f ′ (U )

plays the role of !

α

• Since

du

, we effectively linearized our nonlinear equation around

dt

u=U+ϵ

=

dt U

(44)

Example 1: Simple 1D systems

43

du

dt = αu du

dt = uu

2

du

dt = uu

3

du

dt = 0 u

0

= 0 u

0

= 0, 1 u

0

= 0, ± 1

Stable?

α < 0 U = 0

U = 1

U = 0 U = 1

U = − 1

✓ ✘

df

du

u=U

α f ′ (0) = 1

f ′ (1) = − 1

f ′ (0) = 1

f ′ (±1) = − 2

✘ ✓

α > 0 ✓

(45)

A quick numerical check…

u

0

= 0.001

u

0

= − 0.001

u

0

= 3

u

0

= 0

(46)

Example 2: FitzHugh—Nagumo model of a spiking neuron

45

dv

dt = I

app

+ vv

3

3 − w dw

dt = ϵ(vα w + β)

u = [ v

w ] du

dt = F(u)

= membrane potential

v w

= recovery variable

(47)

Example 2: FitzHugh—Nagumo model of a spiking neuron

(Not necessarily a realistic choice of parameters)

I

app

= 0.01 A ϵ = 0.01

α = 5.00 β = 2.00

I

app

+ vv

3

3 − w = 0 ϵ(vα w + β) = 0

-roots

v

Equilibria

(48)

Stable or unstable equilibria?

47

F(u) = F(u

0

) + ∇

u

F(u

0

)(u − u

0

) + O(∥uu

u

2

)

Multivariate Taylor (linear term)

u

F =

dF1 dv

dF1 dF2 dw

dv

dF2 dw

= [ 1 − v

2

− 1

ϵϵα ]

is the Jacobian

u

F

(49)

Phase portrait: FitzHugh—Nagumo

• Start the evolution of the system at many points and track where it goes

(50)

OK, back to COVID…

(

49

(51)

Application to the SIR model

d

dt [ S

I ] = F(S, I ) = [ F

1

(S, I ) F

2

(S, I ) ] dS

dt = − β I(t)

N S(t) dI

dt = β I(t)

N S(t)γI(t)

Since

R = NSI S(t)

, if and

I(t)

don’t change, neither does

R dS

dt = 0 dI

dt = 0 ⟹ (S, I ) = (N,0) (S, I ) = (0,0)

Epidemic equilibria

(52)

Linearize around the (N,0) equilibrium

d

dt [ S

I ] = − β

NI

S β

NI

SγI

≈ − β

NI

S β

NI

SγI

S=N,I=0

+

dSd

( − β

NI

S )

dId

( − β

NI

S )

dSd

( β

NI

SγI )

dId

( β

NI

SγI )

S=N,I=0

( [ S

I ] − [ N

0 ] ) F(u) = F(u

0

) + ∇

u

F(u

0

)(u − u

0

) + O(∥uu

u

2

)

51

Taylor series (first two terms)

(53)

Finally…

d

dt [ S

I ] ≈ [ 0 − β

0 βγ ] ( [ S

I ] − [ N

0 ] )

Eigenvalues of the Jacobian matrix

λ

1

= 0 λ

2

= βγ

epidemic

β > γ

no epidemic

β < γ

key parameter

R

0

:= β

γ

(54)

Phase portraits

53

R

0

= 0.8

R

0

= 3

(55)

Extending the model

S λS I γI R

dS

dt = − β I

N S dI

dt = β I

N SγI dR

dt = γI

• We can first improve the model by adding a 4th compartment, E

• This models exposed individuals who will become infected after an incubation period

E σE

dE

dt = βS I

N SσE

(56)

Extending the model

55

• Next, we normalize everything by the total population,

s = S / N, i = I / N, e = E / N, r = R / N

• Reparameterize the equations in terms of ; here it is defined as

R

0

R

0

= β γ s · = − γR

0

s i

e · = γR

0

s iσe i · = σeγi

r · = γi

s + e + i + r = 1

(57)

Mitigation

• The idea is that can be influenced by policy—a lockdown hopefully makes it smaller

R

0

R

0 does not change instantaneously

dR

0

dt = η(R

target

R

0

)

• It will be interesting to track the cumulative caseload

c = i + r

and the number of deaths

dc

dr = σe dd

dt = δγi

(58)

Modeling in python

57

(59)

Introducing lockdown

(60)

Lifting lockdown

59

Referenzen

ÄHNLICHE DOKUMENTE

Maintaining a persistent objection to Russia’s illegal actions is of major importance for Ukraine, but it is also crucial to ensuring the stability of international order and avoiding

The relative higher impact of government spending and public investment on non-aid government budget is explained by the fact that these variables (government spending and

This instrument continuously measures the salinity and temperature profile over depth and collects water samples from preselected depths for further analysis.. The trend of

As the southern Indian Ocean is currently fundamentally underrepresented in paleoceanographic reconstructions, it is the aim of this project to reconstruct the

These findings, in combination with previous studies from the Atlantic and Pacific Oceans will for the first time allow a comprehensive reconstruction of CO 2

Several over-constrained studies (i.e. measurement of more than two carbonate sys- tem parameters) revealed discrepancies between measured and calculated carbonate chemistry

This paper finds the modified Hotelling model to be a useful heuristic for understanding the time dimension of absorption capacity; specific recommendations cannot be

Sedimentation velocity measurements with the analytical ultracentrifuge (AUC) OPTIMA XL-I with absorption optics yield not only the size but also the complete