Differential Equations, Boundary Value Problems
Total Page:16
File Type:pdf, Size:1020Kb
Computational Astrophysics I: Introduction and basic concepts Helge Todt Astrophysics Institute of Physics and Astronomy University of Potsdam SoSe 2021, 17.6.2021 H. Todt (UP) Computational Astrophysics SoSe 2021, 17.6.2021 1 / 26 Differential equations H. Todt (UP) Computational Astrophysics SoSe 2021, 17.6.2021 2 / 26 Types of differential equationsI One can classify differential equations regarding their order, so the degree of the highest derivative. General form of a first-order differential equation: dy = f (y; t) (1) dt dy 8 5 for any arbitrary function f , e.g., dt = 2ty − t + sin(y). A second-order differential equation has the form: d 2y dy dy + λ = f (t; ; y) (2) dt2 dt dt and so on. H. Todt (UP) Computational Astrophysics SoSe 2021, 17.6.2021 3 / 26 Types of differential equationsII Reduction By introducing auxillary variables/functions, every higher order differential equation can be reduced to a set of first-order differential equations y (m)(x) = f (x; y(x); y (1)(x);:::; y (m−1)(x)) (3) ! z1(x) := y(x) (4) (1) z2(x) := y (x) (5) . (6) (m−1) zm(x) := y (x) (7) 2 0 3 2 3 z1 z2 0 6 . 7 6 . 7 ! z = 4 . 5 = 4 . 5 (8) 0 zm f (x; z1; z2;:::; zm) H. Todt (UP) Computational Astrophysics SoSe 2021, 17.6.2021 4 / 26 Types of differential equations III One can distinguish ordinary diffential equations (ODE), where only one independent variable is explicitly involved (typically time or location), e.g.: dP = −ρ(r) g(r) (9) dr partial differential equations (PDE), where the solution depends at least on two variables, e.g.: @2 @2 @2 ∆ρ = + + ρ(x; y; z) = f (x; y; z) (10) @x2 @y 2 @z2 The theory and (numerical) solution of PDEs is more complicated than for ODE. H. Todt (UP) Computational Astrophysics SoSe 2021, 17.6.2021 5 / 26 Types of differential equationsIV Moreover, there are the classes of linear differential equations: only the first power of y or d ny=dtn occurs, e.g. wave equation: 1 @ − ∆ u = 0 (11) c2 @t ! special property: law of linear superposition, linear combinations of solutions are also solutions: u2(x; y; z; t) = au0(x; y; z; t) + bu1(x; y; z; t) (12) ! unperturbed superposition of waves H. Todt (UP) Computational Astrophysics SoSe 2021, 17.6.2021 6 / 26 Types of differential equationsV nonlinear differential equations: contain higher powers or other functions of y or d ny=dtn, e.g.: dθ2 l = sin θ (13) dt2 g ! clear: linear combinations of solutions are not automatically solutions too, e.g. dy = λy(t) − λ2y 2(t) (14) dt a y(t) = one solution (15) 1 + be−λt a c y (t) = + not a solution (16) 1 1 + be−λt 1 − de−λt nonlinear equations in general became feasible with the rise of computers H. Todt (UP) Computational Astrophysics SoSe 2021, 17.6.2021 7 / 26 Boundary valuesI As general solution of (ordinary) differential equation contains arbitrary constant per order, problems involving differential equations can be characterized by the type of conditions: 1 initial values/conditions must be given: constant for 1st order differential equation (usually time-dependent) fixed by giving y(t) for some time t0, so giving y0 = y(t0); for 2nd order 0 by giving additionaly y (t0) and so on (Note, that we solve usually for t > t0, but this is not a requirement), e.g., Kepler problem _ _ ~ ~v(t) = ~r(t)& ~a(t) = ~v(t) = FG(r)=m (17) x(t0) = x0; y(t0) = 0; vx (t0) = 0; vy (t0) = vy;0 (18) For the initial value problem (Cauchy problem), the theorem by Picard-Lindelöf guarantees a unique solution: H. Todt (UP) Computational Astrophysics SoSe 2021, 17.6.2021 8 / 26 Boundary valuesII Existence and uniqueness of the solution for the initial value problem 0 y = f (y; x); y(x0) = y0 (19) n If f is continuous on the stripe S := f(x; y)ja ≤ x ≤ b; y 2 R g with finite a; b and a constant L, such that jjf (x; y1) − f (x; y2)jj ≤ Ljjy1 − y2jj (20) n for all x 2 [a; b] and for all y1; y2 2 R (Lipschitz continuous), then exists for all x0 2 [a; b] and n for all y0 2 R a unique function y(x) for x 2 [a; b] with 1 y(x) is continuous and continuously differentiable for x 2 [a; b] ; 0 2 y (x) = f (x; y(x)) for x 2 [a; b] ; 3 y(x0) = y0 H. Todt (UP) Computational Astrophysics SoSe 2021, 17.6.2021 9 / 26 Boundary values III Note that the Lipschitz condition (bounded slope) of f (y; x) is required for uniqueness, 0 p x2 e.g., y (x) = jxj with y(0) = 0 is fulfilled by y1(x) ≡ 0 and also by y2(x) = 4 , that is 0 1 0 because f (y; x) = p and hence limx! 0 f = 1. Without Lipschitz condition the jxj Peano existence theorem guarantees the existence of a solution. Proof idea Integrating Eq. (19) gives a fixed point equation: Z x y(x) − y(x0) = f (s; y(s))ds (21) x0 with Picard-Lindelöf iteration Z x φ0(x) = y0 and φk+1 = y0 + f (s; φk (s))ds (22) x0 H. Todt (UP) Computational Astrophysics SoSe 2021, 17.6.2021 10 / 26 Boundary valuesIV Example: Picard iteration For the Cauchy problem 0 2 y (x) = 1 + y(x) ; y(x0) = y(0) = 0 (23) φ0(x) = 0 (24) Z x 2 φ1(x) = 0 + (1 + 0 )ds = x (25) 0 Z x 2 1 3 φ2(x) = 0 + (1 + s )ds = x + x (26) 0 3 ! Taylor series expansion of y(x) = tan(x) so following Banach fixed point theorem φk converges uniquely to the solution y(x). The existence of y(x) (Peano) is proven by constructing a piecewise continuous function with help of the Euler method (polygonal curve) that converges uniformly for ∆x ! 0. H. Todt (UP) Computational Astrophysics SoSe 2021, 17.6.2021 11 / 26 Boundary valuesV 2 boundary values/conditions can be given, (additionally to initial conditions) to restrict further the solutions, i.e., constrain it to fixed values at the boundaries of the solution space, usually for 2nd order differential equation u00(x) = f (u; u0; x) (27) where u or u0 is given at boundaries, by transformation, e.g., 0 x = (x − x1)=(x2 − x1) (28) at x = 0 and x = 1. Then ! 4 possible types of boundary conditions 1 u(0) = u0 and u(1) = u1 0 2 u(0) = u0 and u (1) = v1 0 3 u (0) = v0 and u(1) = u1 0 0 4 u (0) = v0 and u (1) = v1 H. Todt (UP) Computational Astrophysics SoSe 2021, 17.6.2021 12 / 26 Boundary valuesVI Usually: reduce to set of 1st order differential equations and start integration with given u(0) and u0(0). But for boundary-value problem: only u(0) or u0(0) given, ! not sufficient for any algorithm Example: Boundary values First two equations of stellar structure (e.g., for white dwarf) @r 1 = mass continuity (29) @m 4πr 2ρ @P GM = − hydrostatic equilibrium (30) @m 4πr 4 + equation of state P(ρ) (e.g., ideal gas P = RT ρ/µ), and boundary values center m = 0 : r = 0 (31) surface m = M : ρ = 0 ! P = 0 (32) ! solve for r(m), specifically for R∗ = r(m = M∗) H. Todt (UP) Computational Astrophysics SoSe 2021, 17.6.2021 13 / 26 Boundary values VII 3 eigenvalue problems: solution for selected parameters (λ) in the equations; usually even more complicated and solution not always exist, sometimes trial-and-error search necessary. E.g., u00 = f (u; u0; x; λ) (33) for eigenvalue λ plus a set of boundary conditions. Eigenvalue λ can only have some selected values for valid solution. E.g., Schrödinger equation for particle confined in a potential: eigenfunctions ! wavefunction φk ; ^ eigenvalues ! discrete energies Ek ! Hφk = Ek φk H. Todt (UP) Computational Astrophysics SoSe 2021, 17.6.2021 14 / 26 Boundary values VIII Eigenvalue problem: Stationary elastic waves Displacement u(x) by u00 = −k2u (34) Allowed values of wavevector k = !=c ! eigenvalues of the problem both ends fixed: u(0) = u(1) = 0 or one end fixed, other end free: u(0) = 0 and u0(1) = 0. Fortunately, analytical solutions: p un(x) = 2 sin kn x & kn = nπ n = ±1; ±2;::: (35) Moreover, complete solution of longitudinal waves along elastic rod: linear combination of all eigenfunctions with their initial solutions (fixing cn) 1 X inπct u(x; t) = cnun(x)e (36) n=−∞ H. Todt (UP) Computational Astrophysics SoSe 2021, 17.6.2021 15 / 26 The shooting methodI Simple method for boundary-value and eigenvalue problems: shooting method (origin from artillery), cf. Pang (1997) 00 0 0 e.g., for boundary-value problem u = f (u; u ; x) with y1 ≡ u and y2 ≡ u dy 1 = y (37) dx 2 dy 2 = f (y ; y ; x) (38) dx 1 2 plus boundary conditions, e.g., u(0) = y1(0) = u0 and u(1) = y1(1) = u1. Idea: introduce adjustable parameter δ, so that we have an initial value problem. E.g., 0 u (0) = δ ! together with given u(0) = u0; integrate for given intial values up to x = 1 with result u(1) = uδ(1), so that ! F (δ) = uδ(1) − u1 = 0 (39) ! use root search algorithm to determine (approximative) δ H. Todt (UP) Computational Astrophysics SoSe 2021, 17.6.2021 16 / 26 The shooting methodII Shooting method for boundary value problem (Stoer & Bulirsch 2005) 3 u00(x) = u2; u(0) = 4; u(1) = 1 (40) 2 0 set y1 ≡ u and y2 ≡ u y1(0) = 4; y2(0) = δ = −1;::: − 70 (41) ! y1;k+1 = y1;k + ∆x · y2;k (42) 2 y2;k+1 = y2;k + ∆x · 3:=2: ∗ y1;k (43) 50 40 30 ) plot F (δ) = y1;n − u(1), roots give δ 20 0 F( missing initial values u (0) 10 0 -10 -70 -60 -50 -40 -30 -20 -10 0 δ H.