• Keine Ergebnisse gefunden

Exercise Numerical Analysis of Differential Equations

N/A
N/A
Protected

Academic year: 2021

Aktie "Exercise Numerical Analysis of Differential Equations"

Copied!
31
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Exercise

Numerical Analysis of Differential Equations

Fakult¨ at f¨ ur Mathematik und Informatik TU Bergakademie Freiberg

Dr. M. Helm / Dipl.-Math. St. Pacholak

August 13, 2015

(2)

Contents

1 Initial Value Problems - Repetition 3

1.1 Comprehension Questions . . . 3

1.2 Mixing Tank. . . 4

1.3 Interconnected Tanks . . . 5

1.4 Even more Tanks . . . 6

1.5 Higher Order IVP . . . 7

2 Initial Value Problems - Single-step Methods 8 2.1 Comprehension Questions . . . 8

2.2 EULER Methods . . . 9

2.3 BUTCHER Arrays . . . 10

2.4 RUNGE-KUTTA Method . . . 11

2.5 Consistency . . . 12

2.6 Self study . . . 13

3 Initial Value Problems - Multi-step Methods 14 3.1 Comprehension Questions . . . 14

3.2 Characteristic Polynoms . . . 15

3.3 Order of Concistency . . . 16

3.4 Concistency, Zero-Stability & Convergence . . . 17

4 Initial Value Problems - MATLAB Training 18 4.1 Figures und Functions . . . 18

4.2 Subplots and Function Handles . . . 19

5 Boundary Value Problems - Elliptic BVP 20 5.1 Comprehension Questions . . . 20

5.2 DIRICHLET Boundaries . . . 21

5.3 Von NEUMANN Boundaries . . . 22

5.4 Universal Grid Size . . . 23

5.5 DIRICHLET & von NEUMANN Boundaries . . . 24

5.6 Self Study . . . 25

1

(3)

6 Boundary Value Problems - 1D & 2D 26 6.1 Square Grid Cells . . . 26 6.2 Rectangular Grid Cells . . . 27 6.3 Discretization in Space and Time . . . 28

7 Assignment - Restricted 3-Body Problem 29

(4)

1 Initial Value Problems - Repetition

1.1 Comprehension Questions

I) The initial value problem y0(x) = f(x, y(x)) with y(a) = ya has a unique solution on [a,b], if:

A f is continuous.

B f is continuous and Lipschitz continous in its second argument.

C f is differentiable.

D f is Lipschitz continous in its first argument.

II) Which of the following are NOT first order initial value problems?

A dydx = 2(x+y) ,y(0) =y0

B y00−2y0+y=tett , y(0) = 0 C y0 = 12y2 , y(1) = 1

D y01(t) y02(t)

!

= 3 0

0 −2

! y1(t) y2(t)

!

, y 0 0

!

= 4

7

!

III) Which of the following statements are correct?

A y0 = 3 0

0 −2

!

has the Eigenvalues λ1 = 3 andλ2 =−2.

B The initial value problem dQdt = r4100r Q with Q(0) = Q0 has no solution in [0, te].

C dQdt = r4100r Q describes a predator-prey-interaction.

3

(5)

1.2 Mixing Tank

At time t = 0 a tank contains Q0 kg of salt dissolved in 100 m3 of water. Assume that water containing 0.25 kg/m3 of salt is entering and leaving the tank at a rate ofrm3/min.

a) What’s the according differential equation for this initial value problem (IVP)?

b) Show that the IVP has a unique solution using the Picard-Lindel¨of theorem!

c) Determine the general and exact solution of the IVP!

d) Take MATLAB or your pocket calculator to draw some pictures of the solution for several initial values Q0 and r= 3.

(6)

1.3 Interconnected Tanks

Remembering the Mixing Tank, we extend our experiment by adding another tank and two connecting pipes between them, as shown in the figure.

a) Create the according system of differential equation for this initial value problem (IVP)?

b) Solve the IVP with the given values using eigenvalues and their according vectors to diagonalize the matrix A!

5

(7)

1.4 Even more Tanks

Considering the shown experimental setup as an extension of the Interconnected Tanks, we added flow inlets for each tank and an outlet to get a non discharging system.

a) Determine the exact solution of the linear problem with the initial valuesQ1(0) = 55 and Q2(0) = 26!

b) According to the laboratories resources we can’t use these tank sizes and have to work with two tanks with only 10 m3but same concentrations of salt in it. Rearrange and solve your IVP using half filled tanks as starting point!

c) Create the equation system for determining the concentration of salt in both tanks in setup b) after 30 min, when the outlet plugged up after 20 min. What do you recognize when trying to solve it?

(8)

1.5 Higher Order IVP

Rewrite the following higher order initial value problems from science and technical application as first order systems!

a)y00−2y0+y=tett 0≤t ≤1 y(0) = 0, y0(0) = 0

b)y000 = 12y2 t≥1 y(1) = 1, y0(1) =−1, y00(1) = 2 c)t2y00(t)−2ty0(t) + 2y(t) =t3lnt t≥1 y(1) = 1, y0(1) = 0

7

(9)

2 Initial Value Problems - Single-step Methods

2.1 Comprehension Questions

I) Which of the following BUTCHER arrays describe an explicit method?

A) 0 B) 1 1

1/2 1/2 1/2 1/4 1/4

1/2 1/4 1/4 1 1/4 1/4 1/2

1 0 -1 2 1 0 -2 2 1

1/6 0 2/3 1/6 1/6 0 2/3 1/6

C) 0 -1 2 0 D) A

1/2 1/4 1/4 B

1/2 1/2 1/3 5/12 -1/12 C

1 1 3/4 1/4 D

1/6 0 2/3 1/6 3/4 1/4

II) Which of the following methods are consistent?

A) 0 B) 0

1/2 1/2 1/2 1/2

1/2 1/6 1/2 1/2 -1/4 1/4

1 0 -1 2 1 0 -1 2

1/6 0 2/3 1/6 1/6 0 2/3 1/6

C) 0

1/2 1/2 A

1/2 1/4 1/4 B

1 0 -1 2 C

1/6 0 2/3 1/6

III) Which method is described through the Butcher array 0

1 ? A Euler modified

B Euler explicit

C Euler improved

D Euler implicit

(10)

2.2 EULER Methods

Determine an approximated solution for the initial value problem y0 =−(y+ 1)(y+ 3), 0≤t ≤2 y(0) = -2

applying

a) the explicit EULER scheme, b) the modified EULER method, c) the improved EULER method

with step sizeh= 0.5 andh= 0.2. Compare your approximations with the corresponding values of the exact solution y(t) =−3 + 2(1 +e−2t)−1.

Hint: For the improved EULER method take yn+1 = yn + h2[f(tn, yn) + f(tn +h, yn + hf(tn, yn))]

9

(11)

2.3 BUTCHER Arrays

Rewrite each of the following BUTCHER/RUNGE-KUTTA arrays as a set of explicit formulae for the calculation of yj+1. Do they describe explicit or implicit methods?

a) four-stage ENGLAND formula 0

1/2 1/2 1/2 1/4 1/4

1 0 -1 2

1/6 0 2/3 1/6 b) BUTCHER’s formula

0

1/8 1/8

1/4 0 1/4

1/2 1/2 -1 1

3/4 3/16 0 0 9/16

1 -5/7 4/7 12/7 -12/7 8/7

7/90 0 32/90 12/90 32/90 7/90 c) (one) RADAU IIA method

1/3 5/12 -1/12

1 3/4 1/4

3/4 1/4

(12)

2.4 RUNGE-KUTTA Method

For the solution y(x) of the initial value problem

y0 =−(y+ 1)(y+ 3), 0≤t ≤2 y(0) = -2

find an approximation of y(1) using the classical RUNGE-KUTTA method with step size h = 0.5. Compare with the solutions in 2.2.

11

(13)

2.5 Consistency

Check the concistency order of HEUN’s method by verification of the order conditions (for explicit RUNGE-KUTTA methods up to order three) known from the lecture.

0

1/3 1/3

2/3 0 2/3 0

1/4 0 3/4

(14)

2.6 Self study

Determine an approximated solution to the following system of ODEs.

˙y(t) = 6 −3 2 1

!

y(t), y(0) = 5 3

!

, 0≤t≤1.

Therefore apply

a) the explicit EULER method with step sizeh = 0.25, b) HEUN’s method with step sizeh = 0.5.

Compare the approximations with the exact solution y(t) = exp(3t) 3exp(4t)

exp(3t) 2exp(4t)

! −1 2

!

Hint: You have to use vector versions of both methods, for instance yn+1 = yn+hf(tn,yn) and y0 =y(0) in the EULER case.

13

(15)

3 Initial Value Problems - Multi-step Methods

3.1 Comprehension Questions

I) Which of the following statements are correct? A multi-step method is:

A convergent, if it’s consistent and zero-stable.

B consistent, if it’s convergent and zero-stable.

C zero-stable, if it’s convergent and consistent.

II) Determine the non-consistent methods!

A yn+1 =yn

B yn+3 =−yn+2+yn+1+yn+ 2h(f(yn+2) +f(yn+1)) C yn+1yn−1 = 2hf(tn, yn)

D yn+2 =yn+h3(fn+ 4fn+1+fn+2)

III) Which of the following methods are no real multi-step methods?

A yn+1 =yn

B yn+3 =−yn+2+yn+1+yn+ 2h(f(yn+2) +f(yn+1)) C yn+1yn−1 = 2hf(tn, yn)

D yn+2 =yn+h3(fn+ 4fn+1+fn+2)

(16)

3.2 Characteristic Polynoms

Determine the characteristic polynomialsρ(ζ) andσ(ζ) for the following linear multistep methods. Verify the conditions

Pr j=0

αj = 0 und Pr

j=0

j = Pr

j=0

βj

for

a) the 3-step ADAMS-BASHFORTH method, b) the 3-step ADAMS-MOULTON method, c) 2-step SIMPSON method.

15

(17)

3.3 Order of Concistency

Determine the order of consistency for

a) the explicit NYSTR ¨OM method withr = 2 (midpoint rule) yn+1yn−1 = 2hf(tn, yn),

b) the implicit NYSTR ¨OM method with r = 2 (SIMPSON rule)

yn+2yn= h3{f(tn, yn) + 4f(tn+1, yn+1) +f(tn+2, yn+2)}.

(18)

3.4 Concistency, Zero-Stability & Convergence

Which of the following linear multistep methods are convergent? If a method is not con- vergent: is it consistent, not zero-stable, or both?

a) yn+2 = 12yn+1+ 12yn+ 2hf(yn+1) b) yn+1 = yn

c) yn+4 = yn+ 43h{f(yn+3) +f(yn+2) +f(yn+1)}

d) yn+3 =−yn+2+ yn+1+ yn+ 2h{f(yn+2) +f(yn+1)}.

17

(19)

4 Initial Value Problems - MATLAB Training

Hint: This exercises should be done during the problem session in the PC-Lab MIB 2.10.

Label the axes, titles and legend of the subplots comprehensibly.

4.1 Figures und Functions

Consider the initial value problem

y0(t) = tsin(2y), y(0) = π4. a) Approximate the exact solution

y(t) = arctan(et2)

on the time interval [0,3] with the modified EULER and HEUN‘s third-order method using self-defined functions. Draw figures of the exact and the numerical solutions for three different step sizes h<1.

b) Approximate the solutions with the explicit fourth-order ADAMS-BASHFORTH method. Take the first values of HEUN‘s method in a) as a startup and add the curve into the 3 figures.

c) Draw a figure with logarithmic axes of the error maxi|yiy(ti)| of the numerical solutions for step sizes between 1 and 10−4.

(20)

4.2 Subplots and Function Handles

The ODE

y0(t) =λ(y(t)g(t)) +g0(t) has the general solution

y(t) = Ceλt+g(t), C ∈R

which, for Re λ < 0, consists on a decaying transientCeλt and a steady state component g(t). We consider the case g(t) = arctan t, λ = -10.

a) Draw a subplot of the general solution, i.e. plot the graph ofy(t) for several choices of C ∈[-5,5].

b) Find the exact solution for the initial conditiony(0) = 0.

c) Try to approximate the solution of this IVP with the explicit EULER method using function handles. Plot the numerical solutions on the time interval [0,5] forh= 0.5, h = 0.25 and h = 0.1 in different subplots.

d) Repeat the experiment from (c) with the implicit EULER method using function handles and symbolic functions. Comment your observation.

19

(21)

5 Boundary Value Problems - Elliptic BVP

5.1 Comprehension Questions

I) Which of the following matrices describes the BVP -u00(x) = 2, x ∈ Ω := (0,1), u(0) = 0, u0(1) = 0?

A 2 −1

−1 2

! u1

u2

!

= −2− 2435

−1− 24340

!

B

2 −1 0

−1 2 −1

1 −1 1

u1 u2 u3

=

−2− 2435

−1− 24340

1 3

C

2 −1 0

−1 2 −1

0 −1 1

u1 u2 u3

=

−2− 2435

−1− 24340

2 3

II) Which of the following statements are wrong for the BVP -u00(x) = 2, x ∈ Ω := (0,1), u(0) = 0, u0(1) = 0?

A The BVP has two DIRICHLET boundary conditions!

B The BVP has a von NEUMANN boundary condition!

C The BVP is two-dimensional!

D The BVP is one-dimensional!

III) When discretizing a two-dimensional BVP the 5-point stencil is used.

Which statement is NOT correct?

A It’s also called 5-point discrete Laplacian!

B It can be derived from TAYLOR expansion forumula!

C It contains the 6 neighbors of each discretized point!

D This equation is not valid for boundary points!

(22)

5.2 DIRICHLET Boundaries

Consider the following elliptic boundary value problem of second order in the one dimen- sional space

-u00(x) = -5x3 x ∈ Ω = (0,1) u(0) = -2;

u(1) = -1

a) Check that u(x) = 14x5+34x - 2 is the solution to the above boundary value problem.

b) Discretize the boundary value problem with central finite differences on a uniform grid with mesh width ∆x = h = 13.

Write down the associated linear system and determine a numerical approximation to the solution of the boundary value problem by solving this linear system.

c) Compare your numerical solution with the exact one.

21

(23)

5.3 Von NEUMANN Boundaries

Modify the boundary value problem from Exercise 5.2 to -u00(x) = -5x3 x ∈ Ω = (0,1) u(0) = -2;

u0(1) = 2

a) Show, that u(x) = 14 x5 + 34 x - 2 is still a solution of this boundary value problem.

b) Discretize the boundary value problem with central finite differences on a uniform grid with mesh width ∆x = h = 13.

Write down the associated linear system and determine a numerical approximation to the solution of the boundary value problem by solving this linear system.

c) Compare your numerical solution with the exact one.

(24)

5.4 Universal Grid Size

Generate the matrices and right hand sides of Ax = b, when an arbitrary number of grid points is used. Try to simplify these matrices through (n+1) block structures?

23

(25)

5.5 DIRICHLET & von NEUMANN Boundaries

Consider the following second order elliptic boundary value problem in the one dimen- sional space

-u00(x) = 2; x∈Ω := (0,1), u(0) = 0;

u0(1) = 0;

a) Verify that the solution of the boundary value problem is given byu(x) =x(2x).

b) Discretize the boundary value problem using central differences on a uniform grid with mesh width ∆x = 13. Write down the associated linear system and determine a numerical approximation to the solution of the boundary value problem by solving this linear system.

c) Compare your numerical solution with the exact one. What happens if the NEU- MANN boundary condition is replaced by u(1) = 0? Explain your observations.

(26)

5.6 Self Study

Determine the approximate stationary temperatur distribution in a thin quadratic metal plate with a side length of 0.5 m. Two adjacent are hold on a temperature of 0C. On the other boundaries are hold on a temperature of 0C to 100C.

(Hint: Ifxandyare the space coordinates, the problem can be describe by the stationary heat equation ∆u(x,y) = 0 together with appropriate boundary value conditions. for the solution of the linear system you should use software like MATLAB. for purposes of comparison notice, that the exact solution is given by u(x, y) = 400xy if the boundaries with zero boundary condition are placed along the coordinate axes.)

25

(27)

6 Boundary Value Problems - 1D & 2D

6.1 Square Grid Cells

Discretize the stationary heat equation

-∆u(x, y) = -3 ((x,y) ∈Ω) on the following mesh:

a) Use u = 0 as DIRICHLET boundary values on the open circles and u = 1 on the open squares.

b) Replace the Dirichlet boundary condition on the left and on the bottom-right by

δu

δn = 0 on the lines 1 3 and 17 19.

(28)

6.2 Rectangular Grid Cells

A rectangular silver plate of 6 cm x 5 cm is heated uniformly at each point with a constant energy rateq= 6.2802 W/cm3. Assume that the temperature along the boundaries is hold at

u(x,0) =x(6x), u(x,5) = 0 (0< x <6), u(0, y) = y(5y), u(6, y) = 0 (0< y <5).

Then, the stationary temperature distribution can be described by the POISSON equation

∆u(x, y) =−Kq for (x, y)∈Ω := (0,6) × (0,5),

together with the above boundary conditions. The constant K = 4.3543 W/(cm· K) is the thermal conductivity.

Approximate the temperature distribution by using the finite difference method with mesh widths ∆x = 0.4 and ∆y = 13. Try also some other mesh widths.

27

(29)

6.3 Discretization in Space and Time

Consider the initial-boundary value problem

ut(x, y)− 12uxx(x, t) = 0 in Ω = (0,1) x (0,T), u(x,=) =x(1x) f¨urx∈ (0,1),

u(0, t) =u(1, t) = 0 f¨urt ∈(0,T) for an unknown function u = u(x;t).

a) Approximate u= u(x;t) at time t = 0.1 with an explicit difference scheme. Take a step size of ∆x = 0.25 in space and ∆t = 0.1 in time.

b) Approximate u = u(x, t) at time t = 0.1 with a purley implicit difference scheme.

Take the same step size as in a).

c) For which step sizes ∆t in time is the explicit and the purely implicit difference scheme numerically stable, if a step size ∆x = 0.25 in space is provided?

(30)

7 Assignment - Restricted 3-Body Problem

We consider a satellite in the gravity field of earth and moon. We assume that the move- ment of the three bodies takes place within a fixed plane, and that the two heavy bodies are rotating around their barycenter with constant distance and with constant angular velocity. This means, the influence of the satellite on the orbits of earth and moon can be omitted - that’s why this is called a restricted 3-body problem.

With respect to a coordinate system which is coupled to this rotation (i.e. earth and moon have fixed positions in this system), the satellite’s orbit (x, y) = (x(t), y(t)) can be described by a system of second order differential equations:

x00 =x+ 2y0µ[(x+y)x+µ2+y2]3/2µ[(x−µ)x−µ2+y2]3/2

y00 =y−2x0µ[(x+µ)2y+y2]3/2µ[(x−µ)2y+y2]3/2

Hereµ= 1/82.45 is the ration between the mass of the moon and the cumulative mass of earth and moon, andµ= 1 - µ. The length unit is the distance between earth and moon.

The earth is placed in the origin and the moon on the positive real axis. The time unit is chosen in a way, that the angular velocity of the rotation is one, i.e. the moon needs 2π time units for one orbit.

a) Rewrite the second order differential equation system as a first order system. Apply the substitutions y1(t) =x(t), y2(t) = y(t) and y3(t) =x0(t), y4(t) =y0(t).

b) Solve the first order ODE system using the MATLAB routine [t,y] = ode45(@f,y0,[0 tend],options)

with the following initial values y0 in t = 0:

y1(0) = 1.2, y2(0) = 0, y3(0) = 0, y4(0) = -1.04935750983031990726 Therefore chosen and appropriate end tend for the integration interval.

29

(31)

c) Specify or control via the fourth input parameter options:

- the tolerances RelTol and AbsTol for the stepsize control ofode45, - the plot function for the phase plot (y1, y2) (corresponds to (x(t), y(t))), - the detection of local minima and maxima of the orbit/trajectory (points with

horizontal or vertical tangent) by use of an event function.

Hint: Analyze the additional output parameters in the statement [t,y,te,ye,ie] = ode45(@f,y0,[0 tend],options).

d) Observe what happens if

- tend will be enlarged or reduced,

- the fourth component in the initial condition y4(0) is rounded (for instance) to -1.05

e) Modify the event function so that ode45 terminates after the calculation of a closed trajectory.

f) Solve the 3-body problem with a classical RUNGE-KUTTA method of fourth order an constant stepsize h= (tendt0)/n. How many integration steps n are needed to get a similar trajectory as withode45?

Use the plot statement to generate a picture of the orbital trajectory.

g) Solve the 3-body problem a second time with ode45 using the following data µ= 0.012277471,

y1(0) = 0.994, y2(0) = 0, y3(0) = 0, y4(0) = -2.00158510637908252240537862224.

Determine a value for tend resulting in a closed trajectory. How many integration steps are needed for the associated integration interval?

Hint: The number of integration steps in ode45 depends on the chosen tolerances RelTol and AbsTol.

h) Try to reproduce the second orbit with the classical RUNGE-KUTTA method with fixed stepsize.

Referenzen

ÄHNLICHE DOKUMENTE

(6) Terminology: the explicit Euler method for solving the heat equation is consistent of first order in time and of second order in space.... Besides the asymptotic statement (6)

(6) Terminology: the explicit Euler method for solving the heat equation is consistent of first order in time and of second order in space.. Parabolic Problems TU Bergakademie

For purposes of comparison notice, that the exact solution is given by u(x, y) = 400xy if the boundaries with zero boundary condition are placed along the

Bereanu, The continuity of the optimum in parametric programming and applications to stochastic programming, J.Optim.Theory Applic. Robinson, A characterization of stability

One of the main disadvantages of the semi-Lagrangian approach is the fact that the semi-discretization of the standard minimum time problem leads to a piecewise constant optimal

Given a Hamilton-Jacobi equation, a general result due to Barles-Souganidis [3] says that any \reasonable&#34; approximation scheme (based f.e. on nite dierences, nite elements,

[r]

In order to develop an accurate model and to investigate it rigorously from an analytical point of view, we describe the spin-coating process as a one-phase free boundary value