Numerical solution of the Lane-Emden equation

57
M840 Dissertation in mathematics Numerical solution of the Lane-Emden equation Mark Cannon P0114977 Submitted for the MSc in Mathematics The Open University Milton Keynes UK 15 November 2015

Transcript of Numerical solution of the Lane-Emden equation

M840 Dissertation in mathematics

Numerical solution of theLane-Emden equation

Mark Cannon

P0114977

Submitted for the MSc in Mathematics

The Open University

Milton Keynes UK

15 November 2015

Abstract

This dissertation describes the results of an investigation into the numerical

solution of the Lane-Emden equation which is a singular non-linear boundary

value problem. The approach used is the Newton iteration method on a linearised

form of the differential equation. The piecewise polynomial representation is

obtained using B-splines by collocation at Gaussian points.

The mathematical background which is the theoretical basis for the numerical

solution is described. In particular the paper “Collocation at Gaussian points” by

de Boor and Swartz is discussed and how the main theorems show how to solve

non-linear problems efficiently [1].

The Lane-Emden equation can be used as a simple model of the structure of stars.

The numerical solution is compared against those analytic solutions which exist to

investigate the accuracy of the solution. A solution is then obtained for the model

of our sun for which no analytic solution exists and this is used to estimate some

key physical parameters at the core of the sun.

P0114977 2 Mark Cannon

Contents

1 Introduction 5

2 Mathematical background 8

2.1 Piecewise polynomial interpolation . . . . . . . . . . . . . . . . . . . 8

2.2 B-splines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

2.3 B-spline interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

2.4 Collocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

2.5 Collocation at Gaussian points . . . . . . . . . . . . . . . . . . . . . . 18

2.5.1 Theorem 3.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

2.5.2 Theorem 4.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

2.5.3 Finite Element Method . . . . . . . . . . . . . . . . . . . . . . 22

3 Description of problem 24

3.1 Derivation of the Lane-Emden equation . . . . . . . . . . . . . . . . . 25

3.2 Discussion of the Lane-Emden equation . . . . . . . . . . . . . . . . . 27

3.2.1 Analytic solutions . . . . . . . . . . . . . . . . . . . . . . . . . 28

3.2.2 A singular non-linear boundary problem . . . . . . . . . . . . 28

P0114977 3 Mark Cannon

CONTENTS 4

4 Maple investigations 30

4.1 Linearisation of the Lane-Emden equation . . . . . . . . . . . . . . . 30

4.2 Description of the Maple code . . . . . . . . . . . . . . . . . . . . . . 31

4.3 Results of the investigation . . . . . . . . . . . . . . . . . . . . . . . . 34

4.3.1 Accuracy of the method . . . . . . . . . . . . . . . . . . . . . 34

4.3.2 Results for n = 3 . . . . . . . . . . . . . . . . . . . . . . . . . 38

4.3.3 Application of the results to our sun . . . . . . . . . . . . . . 41

5 Conclusion 43

5.1 Summary and discussion of results . . . . . . . . . . . . . . . . . . . 43

5.2 Further areas of study . . . . . . . . . . . . . . . . . . . . . . . . . . 44

A Maple Code 47

B Maple Output 55

Bibliography 57

P0114977 Mark Cannon

Chapter 1

Introduction

This dissertation consists of an investigation into the numerical solution of the

Lane-Emden equation. This is a second order ordinary differential equation

representing a singular non-linear boundary value problem. It is of considerable

historical significance since it has been used to model the internal structure of

stars and remains a topic of active research today.

The approach used to solve the equation is the Newton iteration method on a

linearised form of the differential equation. The piecewise polynomial

representation will be obtained using B-splines by collocation at Gaussian points.

The first part of the investigation in chapter 2 is a review of some of the

mathematical background which is the theoretical basis for the method used to

solve the equation. There is a description of piecewise polynomial interpolation,

B-splines and B-spline interpolation, and the collocation method for solving

differential equations. The Finite Element Method is briefly described and how

there is an analogy with collocation in the way that the error function is minimised

by making it orthogonal. Also some of the results in the seminal paper

“Collocation at Gaussian points” by de Boor and Swartz are described [1]. The

two most important theorems from this paper are Theorem 3.1 which describes

how non-linear problems can be solved efficiently by using Newton’s method and

Theorem 4.1 which shows that Gaussian points are a good choice for the

collocation points. The latter theorem also gives limits on the global errors and at

the knots. At the knots there is also the phenomenon of superconvergence.

In chapter 3 there is a detailed description of the problem that has to be solved. A

P0114977 5 Mark Cannon

1 Introduction 6

brief history of the Lane-Emden equation and its significance to the field of

astrophysics is outlined. The solutions to the equation are known as polytropes

and for a long period these were the only models of stars that were available. The

solution to the Lane-Emden equation shows how the relative density θ varies as a

function of the dimensionless radius ξ.

A derivation of the equation is given using the following three equations: pressure

and density related by a power law; gravitational equilibrium of the fluid and the

equation of mass continuity. The boundary conditions are also discussed and how

they arise from physical considerations. The power law parameter n that relates

the density and pressure corresponds to different states of matter and there is a

description of how different values of n can be used to model different types of

stars. This parameter n is also called the polytropic index. There are also a few

special values of n for which there are analytic solutions and these solutions are

given. The equation has Cauchy boundary conditions making it in effect an initial

value problem. There is an analysis showing that the equation also has a regular

singular point at the boundary and it is also non-linear.

The aim of the investigation however is not just to get a piecewise polynomial

representation of the solution for a particular value of n. The zero of the solution,

that is where θ goes to zero represents the surface of the star where the density

goes to zero. The aim is to calculate this value and also the derivative at the zero

for the model which corresponds to our own sun. These parameters are useful

because they can be used to calculate other internal physical properties of the star

such as the pressure, density and temperature at the core.

In chapter 4 the Maple investigation of the equation is described. First the

equation is linearised using the method in de Boor’s book “A practical guide to

splines” [2] and a general linearised equation for all n is obtained. The Maple

investigation is split into two main parts. The first part obtains numerical

solutions for those values of n where there is an analytic solution. Thus the

accuracy of the method can be determined and this indicates what collocation

parameters are needed to accurately solve the problem for those values of n where

P0114977 Mark Cannon

1 Introduction 7

there is no analytic solution. The second part is to solve the equation for the case

n = 3 which is the model of our sun. All the main changes to the supplied Maple

code are summarised and the new procedures are described. The results of the

Maple investigation are presented in tables and graphs. Finally the values that

have been calculated for n = 3 are used to calculate physical properties at the

centre of the sun and these values are compared to the values predicted by the

modern Standard Solar Model. The values are reasonable agreement considering

how simple the Lane-Emden model is.

In the conclusion in chapter 5 the results are summarised and the efficiency of the

collocation method is considered. An alternative method to collocation is

described which uses numerical integration. The complications that are created by

the singular point on the boundary for this alternative method are also considered

and how they may be avoided by using a power series expansion.

Possible further areas of study are then outlined. Some of these are improvements

in the method itself and others are new areas of investigation. One interesting

possibility is to investigate why the collocation method (or the implementation of

it) failed for non-integer values of the polytropic index n when these were tried.

These correspond to models of neutron stars, red gas giants and giant gaseous

planets like Jupiter. It should also be possible to get an estimate of the

Chandrasekhar limit which is the maximum mass of a dense white dwarf, above

which it collapses into either a neutron star or a black hole.

P0114977 Mark Cannon

Chapter 2

Mathematical background

Many practical problems in applied mathematics do not have an exact or analytic

solution and so it is necessary to calculate approximate solutions. The theory and

the numerical methods which are used to make these approximations are part of a

branch of mathematics called numerical analysis. An evaluation of a numerical

method needs to take into account its efficiency, accuracy, what type of problems it

can solve and its limitations.

2.1 Piecewise polynomial interpolation

Polynomials are useful for the purposes of approximation because they can be

differentiated and integrated easily using basic arithmetic operations. A

polynomial of order n is defined as:

p(x) = a1 + a2x+ · · ·+ anxn−1 =

n∑

j=1

ajxj−1 (2.1)

and the set of all polynomials of order n forms a linear space denoted as Π<n.

Consider an arbitrary function g with a set of n distinct points τi, i = 1, . . . , n on

an interval [a . . b] and the values of g are known at these points. Then there is a

unique polynomial p ∈ Π<n which satisfies the data at all the points. The

polynomial p can therefore be considered to be an approximation to g and

approximates it over the whole interval. The polynomial can be written in

Lagrange form [2] I equations (2), (4) or in Newton form [2] I (7). The Newton

P0114977 8 Mark Cannon

2.1 Piecewise polynomial interpolation 9

form is particularly convenient since it is possible to use divided differences to

build up the polynomial by adding the data sites one at a time.

One important property is Leibniz’ formula which states that if f(x) = g(x)h(x)

for all x then:

[τi, . . . , τi+k]f =i+k∑

r=i

([τi, . . . , τr]g)([τr, . . . , τi+k]h) (2.2)

where the kth divided difference of g at the sites τi, . . . , τi+k is denoted by

[τi, . . . , τi+k]g and a proof is in [2] chapter I.

If the sites τi are not distinct then there is a repeated interpolation called

osculatory interpolation where there is higher order contact between p and g. This

means that for every site ζ that occurs m times then the m-fold derivatives at ζ

must agree, i.e.

pi−1(ζ) = gi−1(ζ) for i = 1, . . . ,m (2.3)

Another important result in which the sites are not necessarily ordered or distinct

is the Osculatory Interpolation Theorem [2] I (14). This gives both the Newton

form for the unique polynomial and also approximates g(x) with an error function

e(x) = g(x)p(x).

When there are repeated sites then in computations it is possible to calculate the

divided difference from g if it has k continuous derivatives. For g ∈ C(k), then the

kth divided difference is:

[τi, . . . , τi+k]g =g(i)(τi)

k!if τi = · · · = τi+k (2.4)

One of the disadvantages of polynomial approximation is Runge’s phenomenon

where there are oscillations near the edge of an interval, especially when using

polynomials of a high order. The interpolation error can actually increase as the

order increases instead of decreasing as might be expected. This problem is

P0114977 Mark Cannon

2.1 Piecewise polynomial interpolation 10

especially bad if equally spaced (or uniform) interpolation sites are used. The

sensitivity of the approximation to the choice of the interpolation sites is a key

limitation of polynomial approximation. It is possible to improve the

approximation by using the zeros of orthogonal polynomials. Orthogonal

polynomials are classes of polynomials defined over an interval [a . . b] such that

any two non-equal polynomials satisfy the orthogonality condition defined as an

inner product:

(φi, φj) = 0, i 6= j (2.5)

The orthogonality condition for many families can be defined using a weighting

function w(x) as follows:

∫ b

a

w(x)φi(x)φj(x) dx = 0 (2.6)

An equivalent definition is to define a sequence of polynomials satisfying a

three-term recurrence:

P−1(x) := 0, P0(x) := 1,

Pi+1(x) := Ai(x−Bi)Pi(x)− CiPi−1(x), i = 0, 1, 2, . . . (2.7)

for certain coefficients Ai, Bi, Ci. For example the Chebyshev polynomials are

defined on [−1 . .1] and use the weighting function w(x) = (1− x2)−1/2.

Equivalently they are defined using the recurrence relation above with the

coefficients:

A0 = 1, B0 = 0

Aj = 2, Bj = 0, Cj = 1, j = 1, 2, 3, . . .

If the zeros of the Chebyshev polynomials are used as interpolation sites then it

can be shown that this interpolation is nearly optimal [2] I (15). However there are

still some functions which are not well approximated. For example the error may

P0114977 Mark Cannon

2.1 Piecewise polynomial interpolation 11

now decrease as n is increased but this may occur far too slowly in order to achieve

the accuracy required.

Approximation theory can be used to determine the rate at which the error goes to

zero for different classes of functions g. The classification used is based on the

number of continuous derivatives r that a function has. The modulus of continuity

of g in a strip of width h is w(g;h) where:

w(g;h) := sup{ |g(x)− g(y)| : x, y ∈ [a . . b], |x− y| ≤ h } (2.8)

and the value of the rth derivative of w(g;h) can be used to put a bound on the

error.

If w(g;h) ≤ Kh for some constant K and all (positive) h then g is said to be

Lipschitz continuous. It is in effect a smoothness condition which is stronger than

normal continuity and so limits how fast a function can change. Piecewise

continuously differentiable functions in C[a . . b] belong to this class of functions

and they are a much larger class than the continuously differentiable functions. If

g has only r derivatives then there is a limit on how well g can be approximated by

polynomials as shown by Jackson’s Theorem [2] II (22). The error decreases with

the order n and increases with the size of the interval [a . . b]. So one way of

increasing the accuracy is to partition [a . . b] into smaller intervals, that is to use

piecewise polynomials. The other way is to increase n although the use of

polynomials of order 20 or higher is problematic and it is necessary to switch the

representation of the polynomials to a better conditioned form such as the

Chebyshev form. Also the high order problem is far more difficult to solve whereas

solving using a large number of lower order pieces is simply solving an easier

problem many times. Hence it is more efficient to use piecewise polynomials for

approximation than to increase n. The use of piecewise polynomials also reduces

the global dependence on local properties. If the function is badly behaved

anywhere in an interval then the approximation is poor everywhere. This

disadvantage can be limited by using many intervals.

P0114977 Mark Cannon

2.2 B-splines 12

A convenient way of representing piecewise polynomials which is suitable for

computation is called piecewise polynomial form. It is worth specifying this in

detail since some of the definitions and notation will be used later when discussing

B-splines and collocation. The space of piecewise polynomials of degree less than k

is Π<k,ξ with l + 1 breakpoints ξ = (ξ1, . . . , ξl+1), with ξ1 = a and ξl+1 = b. The

ppform definition of f is then given by [2] II (6) and consists of:

• the integers k and l giving the order and number of pieces

• the strictly increasing sequence of breakpoints ξ1, . . . , ξl+1

• the k× l matrix C containing the values of f and its right derivatives at each

of the breakpoints. Using the array C it is possible to represent the function

f using Taylor polynomials.

For the piecewise polynomial to be smooth there must be continuity conditions at

the breakpoints. If there are νi continuity conditions at the breakpoint ξi then the

vector ν = (ν2, . . . , νl) specifies the number of continuity conditions at each of the

internal breakpoints. The space of all piecewise polynomials of degree less than k

with breakpoints and continuity conditions as defined above is Π<k,ξ,ν

2.2 B-splines

Having defined the subspace Π<k,ξ,ν in the previous section, the next step is to

obtain a basis which is required to construct a particular function f in that

subspace. One possibility is to use the truncated power basis. This basis uses a

double sequence ψij which is defined as follows:

ψij :=

(x− ξ1)j/j!, i = 1;

(x− ξi)j+/j!, i = 2, . . . , l, for j = 0, . . . , k − 1

The truncated power function f(x) := (x− ξ)r+ is a piecewise polynomial of order

P0114977 Mark Cannon

2.2 B-splines 13

r + 1. The subscript ‘+’ notation indicates that the function is truncated so that

(x− t)+ is zero to the left of t as shown in figure 2.1. Hence f is always positive.

Note that the power functions are continuous except for the case r = 0 when there

is a jump at ξ.

t

x

f(x)=(x-t)+

Figure 2.1: The function f(x)

Since ψij is a basis then every function in the space Π<k,ξ,ν can be expressed as a

linear combination of the basis sequence in exactly one way. Piecewise polynomials

like this which are sufficiently smooth at the places where the polynomials pieces

connect are called splines. The points where the pieces connect are called knots.

Note that D(· − ξ)r+ = r(· − ξ)r−1+ and so each (· − ξ)r+ has r − 1 continuous

derivatives, with a jump in the rth derivative.

However the truncated power basis suffers from some serious problems. There is a

possible bad ‘condition’ caused when non-uniform ξ leads to some of the basis

functions to become nearly linearly dependent on others. This then means that the

linear system which has to be solved is also badly conditioned. The problem is

that the power functions grow rapidly but the function that is being approximated

may not. Hence the situation can arise where large terms are added or subtracted

leading to rounding errors. The way to avoid this is to use basis splines or

B-splines which are defined as scaled kth divided differences of the truncated

power functions and because these B-spline values are always small then the

problem of rounding errors does not occur.

The jth normalised B-spline of order k, using the non-decreasing knot sequence

P0114977 Mark Cannon

2.2 B-splines 14

t = (tj) is denoted by Bj,k,t and is defined as:

Bj,k,t := (tj+k − tj)[tj, . . . , tj+k](· − x)k−1+ , all x ∈ R (2.9)

The dot placeholder notation is used to indicate that the kth divided difference of

the function (t− x)k−1+ , which has two variables t and x, is calculated by fixing x

and treating it as a function of t only.

The B-splines can also be calculated from a recurrence relation and this is much

more convenient to use than (2.9) since it can be implemented far more easily and

efficiently in computer code. The relation is derived using Leibniz’ formula (2.2)

from section 2.1 and a proof is given in [2] IX. The recurrence relation is:

For k = 1, Bj,1(x) =

1, if tj ≤ x < tj+1

0, otherwise

For k > 1, Bj,k = ωjkBj,k−1 + (1− ωj+1,k)Bj+1,k−1 ,

where, ωjk :=x− tj

tj+k−1 − tj

The B-splines have many useful properties which make them suitable as a basis for

piecewise polynomials. They are described as having local or small support which

means that they are non-zero only on the interval [tj . . tj+k]. Moreover they are

positive on that interval. They provide a local partition of unity which is also

called the normalisation condition:

j

Bj,k = 1 on Ik,t

These properties are the reason that the B-spline values will always remain small.

The actual smoothness of Bjk depends on the number of times which the break ξi

appears in the knot sequence.

The spline space $k,t is defined as all possible functions which are linear

combinations of B-splines of order k for the knot sequence t. The Curry-Shoenberg

P0114977 Mark Cannon

2.3 B-spline interpolation 15

Theorem says that it is equal to the space of all piecewise polynomials for a

sequence of continuity conditions:

$k,t = Π<k,ξ,ν on Ik,t

However this is true only on the ‘basic interval’ Ik,t associated with the knot

sequence t. A proof of the theorem is in [2] IX.

The knot sequence t can be chosen by translating the desired smoothness at a

break, specified by ν into a corresponding number of knots at that site. Fewer

knots means more continuity conditions according to the equation:

Number of continuity conditions at ξ + number of knots at ξ = k (2.10)

The B-spline form or B-form of a piecewise polynomial is equivalent to the ppform

of f in section 2.1 and is an efficient way of representing the B-spline in computer

code. It consists of the order k; the number of linear parameters n where

n = kl −∑

i νi; the knot sequence vector t and the coefficient vector α for the

B-spline basis where:

f(x) =n

i=1

αiBi(x) (2.11)

Another useful property of B-splines is that they can be differentiated easily by

differencing the B-spline coefficients. The first derivative of a B-spline of order k is

of order k − 1.

2.3 B-spline interpolation

B-splines can be used to interpolate a function g and this is accomplished by

setting up a set of linear equations. The aim is to make the spline match g at n

data sites using a basis of dimension n. Equation (2.10) shows that the maximum

P0114977 Mark Cannon

2.3 B-spline interpolation 16

number of repeated knots is k, in which case there are no continuity conditions at

that site. Hence the non-decreasing knot sequence t = (ti)n+k1 has the condition

ti < ti+k for all i. (Bi)n1 is the corresponding linearly independent sequence of

B-splines of order k. The dimension of the basis is therefore n. The unique data

sites are a sequence which is strictly increasing τ = (τi)n1 . Then a for a given

function g the spline f :=∑n

1 αjBj from (2.11) agrees with g at τ if and only if:

n∑

j=1

αjBj(τi) = g(τi), i = 1, . . . n (2.12)

and this is the linear system where the vector α = (αi)n1 consists of the n

unknowns. The coefficient matrix (Bj(τi)) is called the spline collocation matrix

and if this matrix is invertible then the linear system can be solved.

The Schoenberg-Whitney Theorem [2] XIII states that (Bj(τi)) is invertible

provided the knot sequence t is such that:

• there are fewer than k + 1 repetitions in t for any breakpoint ξi

• where an interpolation site τj coincides with a breakpoint ξi, there are fewer

than k repetitions in t

• the diagonal elements of the associated coefficient matrix are non-zero, so

Bi(τi) 6= 0

There are some further properties of the spline collocation matrix which make it

easier to solve using computer code. The matrix is banded as a result of the fact

that the B-spline is non-zero only for x ∈ [ti . . ti+k] and τi is in this interval. So

matrix has at most k non-zero elements on each row and these are all grouped

around the diagonal. The matrix is said to have a low bandwidth (of k) and sparse

matrices like this lead to much more efficient computation.

Another property is the total positivity of the spline collocation matrix. This

means that all its minors i.e. all possible determinants are greater than or equal to

P0114977 Mark Cannon

2.4 Collocation 17

zero. This is significant because it means that the linear system can be solved by

Gauss elimination without pivoting which greatly reduces the number of

operations needed to solve the system.

2.4 Collocation

A collocation method can be used to solve partial differential equations,

ordinary differential equations and integral equations. It is the method as applied

to ordinary differential equations that is of interest here. Rather than matching

values to g, the aim is to match the differential equation at the collocation sites.

This has to be done implicitly since the solution of the differential equation is not

known; it is this solution that is being sought. Only second order equations with

two boundary conditions will be considered here.

The order of the differential equation is m=2 and this is also equal to the number

of boundary conditions, also known as side conditions. The first step is to choose

the number of polynomial pieces l on the interval [a . . b] with the breakpoints

ξ1 = a < ξ2 < · · · < ξl+1 = b.

Then select k collocation points within each subinterval ξi . . ξi+1. The distribution

of the points is important and in this particular instance they are chosen so that

they are the zeros of Legendre polynomial of order k. The reason for this choice is

discussed further in section 2.5.1. The order of the piecewise polynomial

approximation is k +m and the dimension of the spline is n = kl +m.

Then the knot sequence has to be generated from the break sequence. This is done

so that there are m− 1 continuous derivatives at the break. This means that there

are k knots at each break apart from at the end points where there are k +m. It is

now possible to generate the splines Bj,k+m,t and their derivatives.

The unknown function is expressed as a linear combination of the B-spline basis as

in (1.11). This can be differentiated and substituted into the differential equation

P0114977 Mark Cannon

2.5 Collocation at Gaussian points 18

(or a linearised version of the equation) and together with the side conditions this

gives an almost block diagonal system. The number of blocks will be equal to the

number of intervals l. The number of columns in the ith block correspond to the

k +m B-splines that support this interval and the number of rows in the block are

made up of the k collocation equations in the ith interval plus side conditions (if

any) in that interval. This almost block diagonal linear system can be efficiently

solved by computer code by using Gauss elimination with partial pivoting.

This above describes one iteration of the collocation method. If the differential

equation is linear then the method has finished. For non-linear differential

equations there is a procedure to linearise them and then use iteration based on

Newton’s method to get a solution. The linearisation procedure is described in

section 4.1 and the theory of why it is efficient is considered in section 2.5.

2.5 Collocation at Gaussian points

In this section some theorems and results from the paper “Collocation at Gaussian

points” by de Boor and Swartz are described [1]. The two most important

theorems from this paper are Theorem 3.1 which describes how non-linear

problems can be solved efficiently by using Newton’s method and Theorem 4.1

which shows that Gaussian points are a good choice for the collocation points. The

approximations are piecewise polynomial functions of order m+ k with m− 1

continuous derivatives. The problem that is being considered in the paper is to

find the solution x ∈ C(m)[a, b], m > 0 of an mth order nonlinear ordinary

differential with m linear side conditions where:

Dmx = Fx; βi = ci, i = 1, . . . ,m (2.13)

using the abbreviation

(Fx)(t) = F (t, x(t), . . . , (Dm−1x(t)), where F = F (t, z0, . . . , zm−1) (2.14)

P0114977 Mark Cannon

2.5 Collocation at Gaussian points 19

2.5.1 Theorem 3.1

In this section there is a description of the assumptions and conditions of Theorem

3.1 which is on page 595 of the paper [1] and a discussion of the significance of its

consequences. It is stated at the start of the theorem to let x ∈ C(m+n)[a, b], n ≥ 0

be a solution of (2.13). The first hypothesis is that F (t, z0, . . . , zm−1) is sufficiently

smooth near x. This means the function F which is a function of the coefficients

and derivatives of order lower than m must be sufficiently smooth not only at the

solution x but close to it as well. As an example in the paper it is assumed that

F ∈ C2(N ), where N is in some ǫ-neighbourhood of C. To put this into some

context for the differential equation that is investigated in this dissertation it is

shown in section 4.1 that (using the slightly different notation defined here):

F (t; z0, z1) = −2

tz1 − zn0

It is also shown that although there is a singular point, that the terms are well

defined as the singular point is approached. Hence for this problem it does seem

that this condition can be assumed true. The second hypothesis is that the linear

problem associated with x is uniquely solvable and possesses a Green’s function

G(t, u). A Green’s function is a fundamental solution to an inhomogeneous

differential equation with boundary conditions. It is effectively a building block

that can be used to construct many other useful solutions. Regarding the

Lane-Emden equation which is the focus of this investigation it is shown in section

3.2.1 that there are some analytic solutions of the Lane-Emden equation and they

are unique and these solutions have a similar form. Hence it seems reasonable to

assume that the linearised form for the Lane-Emden equation satisfies this

condition.

The first part (a) of the theorem states that there is no other approximate solution

x near x. In other words if the iteration starts close to x then it should converge

on that solution and on no other.

The second part (b) is that the collocation equation has a solution in the

P0114977 Mark Cannon

2.5 Collocation at Gaussian points 20

neighbourhood of x and that it is unique.

The third part (c) states that Newton’s method for approximately solving the

collocation equation converges quadratically in some neighbourhood of x∆, the

collocation approximation (i.e. the solution to the collocation equations). This is

highly significant since it means that if the iteration converges on a solution at all

then it should do so rapidly.

The fourth part (d) gives an error estimate for x∆:

||Di(x− x∆)||∞ ≤ const.|∆|min(n,k), i = 0, . . . ,m

Hence the infinity norm of the error and the m derivatives of the error is bounded.

Note that |∆| is the size of the piecewise interval. Hence a result of this is that the

error can be reduced by reducing the interval, i.e. by increasing the number of the

partitions of the piecewise polynomial. It can also be decreased by increasing k,

the number of the collocation points.

In part (e) it is stated that even more significantly:

Di(x− x∆) = Di(x−Rx) +O(|∆|2min(n,k)), i = 0, . . . ,m

This is indeed significant since it is saying that the difference between the solution

to the non-linearised equation and the solution to the linearised equation is

bounded in a similar fashion to part (d). This is important since just because the

solution to the linearised equation converges, it does not necessarily mean that this

solution is anywhere near the solution of the actual differential equation. This

theorem shows that in fact it is near and gives error estimates for their difference

and a strategy for improving the accuracy of the approximation.

P0114977 Mark Cannon

2.5 Collocation at Gaussian points 21

2.5.2 Theorem 4.1

In this section there is a description of the assumptions and conditions of Theorem

4.1 which is on page 600 of the paper [1] and a discussion of the significance of its

consequences. It is assumed that both hypotheses (i) and (ii) of Theorem 3.1 hold.

It is also assumed that the coefficients of the differential operator are smooth

enough.

Additionally it is assumed that condition (4.7) from [1] holds. This condition is a

further smoothness condition and is that the moduli of the derivatives of the

Green’s functions of the linearised equation are all less than a constant K. Now

assume that the k collocation points in the standard interval [−1 . . 1] are chosen so

that:

∫ 1

−1

q(u)k∏

i=1

(u− ρi) du = 0

for every q ∈ Π<n. This means that the collocation points are the zeros of the

Legendre polynomial of order k, also known as Gaussian points.

Then the solution obtained by collocation at the breakpoints has a bound on the

error as follows:

|Dj(x− x∆)(t)| ≤ c1|∆|k+n, i = 0, . . . ,m− 1

Also there is a bound on the global error as follows:

||Dj(x− x∆)(t)||∞ ≤ c1|∆|k+min(n,m−i), i = 0, . . . ,m

Now Dif is piecewise polynomial and is of order m+ k− i and so the global bound

shows that the approximation is of optimal order if n ≥ m− i. In other words the

global error of the approximation is of the same order as the optimal one.

Note that by using Gaussian points as the collocation points allows the choice

P0114977 Mark Cannon

2.5 Collocation at Gaussian points 22

n = k and then the error bound for the global error is O(|∆|m+k) and the error

bound at the breakpoints is O(|∆|2k).

Now 2k > m+ k and hence the approximation at the breaks is of better than

optimal order. This is a phenomenon known as superconvergence and means that

the solution will be much more accurate at the breakpoints than at the rest of the

solution. This is shown clearly in the results for the linear problem in [1] Table I.

For example, for uniform collocation points and N = 10 (where N is the order) the

global error in the solution is 9× 10−8 and the maximum error at the breakpoints

is also 9× 10−8. However for the Gaussian points the global error is 3× 10−10 and

the maximum error at the breakpoints is 8× 10−13. The superconvergence leads to

a far lower error at the breakpoints than the global error for Gaussian points. In

addition, the overall solution is much better for Gaussian points than for uniform

points; the global error is orders of magnitude lower. This result is seen for other

values of N and also in the errors for the first and second derivative.

The rate of convergence to the solution as N is increased can also be seen in the

table. This is shown in the table as a multiplying factor showing how much better

the accuracy is for each increase in N . Away from the breakpoints the rate is the

same for Gaussian points as for other schemes. However at the breaks the rate

increases significantly.

2.5.3 Finite Element Method

The Finite Element Method is a discretization method and a description can be

found in [5]. It has been used to solve boundary value problems that are solutions

to partial differential equations. The domain is split into a number of subdomains

and the solution of the partial differential equation is approximated by a

polynomial function on each element. The polynomials are then pieced together

with an appropriate degree of smoothness over the whole domain. An integral of

the inner product of the residual and weight functions is constructed and the

product is forced to zero by setting the integral to zero. There is analogy to this

P0114977 Mark Cannon

2.5 Collocation at Gaussian points 23

process in collocation since by choosing the Gaussian zeros as the collocation

points the error function q is made small by making it orthogonal. However in this

case the weight function is 1. Using more collocation points forces the product

closer and closer to zero and so the solution improves.

P0114977 Mark Cannon

Chapter 3

Description of problem

The problem which is investigated is the solution of the Lane-Emden equation.

This is a dimensionless form of Poisson’s equation and has been used historically

in the field of astrophysics as a simple model of a star. It describes the behaviour

of polytropic fluids such as the plasma in a star where the pressure and density are

related by a power equation and where the fluid is also in hydrostatic equilibrium.

A solution to the equation is called a polytrope. The Lane-Emden equation is a

second order ordinary differential equation and its solution describes how the

density (relative to the central density) varies as a function of the dimensionless

radius.

The Lane-Emden equation has analytic solutions for certain values of the power n

in the power law equation and these values are used to investigate the accuracy of

the numerical solution obtained by collocation. The solution is then obtained for a

value of n for which there is no analytic solution and which is a model of our own

sun. The key parameters obtained are the zero of the solution, which corresponds

to the boundary of the star (where the density goes to zero) and also the derivative

at that zero.

These parameters are then used together with some known physical parameters of

the sun to estimate three properties at the core of the sun: the pressure, the

density and the temperature. These values are then compared to the values

obtained from the modern Standard Solar Model.

P0114977 24 Mark Cannon

3.1 Derivation of the Lane-Emden equation 25

3.1 Derivation of the Lane-Emden equation

Historically the Lane-Emden equation is of significance. It was first described in

1869 by J. Homer Lane who used it to calculate the temperature and density at the

surface of the sun [8]. A. Ritter also published many papers independently during

the period 1878-1889 [10] and it has been suggested that it would have been more

appropriate to call the equation the Lane-Ritter equation. Emden later wrote a

famous book on the theory of stellar structure called “Gaskugeln” (“Gas Spheres”)

which was published in 1907 [9]. In it he systemized a great deal of earlier work

and also presented a good proportion of new results and accurate tables.

The derivation of the Lane-Emden equation here is based on (but not identical to)

that given in Chandrasekhar’s book “An Introduction to the Study of Stellar

Structure”, Chapter IV [6]. The book was originally published in 1939 but the

reference here is to a corrected republication in 1958. The starting point is an

assumption that the pressure P and density ρ in a star are related by a power

equation:

P = Kργ, where K and γ are constants and γ = (n+ 1)/n (3.1)

It is assumed that this relationship, including the value of the constants, holds

throughout the star. Such systems which are in equilibrium are known as complete

polytropes. The constant γ is the adiabatic index and it characterises the

behaviour of the specific heat of a gas. The quantity n is called the polytropic

index. The next assumption is that the star is in gravitational (or hydrostatic)

equilibrium. The equation is derived using Newton’s Law of gravitation and is:

dP

dr= −ρ(r)GM(r)

r2(3.2)

where M(r) is the mass inside radius r and G is the constant of gravitation.

Since there are three unknowns, M , P and ρ then a third equation is needed to

P0114977 Mark Cannon

3.1 Derivation of the Lane-Emden equation 26

give a solution. This is the equation of mass continuity:

dM

dr= 4πr2ρ (3.3)

So, solving for M in (3.2) gives:

M(r) =r2

ρG

dP

dr⇒ dM

dr= − 1

G

d

dr

(

r2

ρ

dP

dr

)

(3.4)

and substituting for dM/dr into (3.3) and rearranging gives:

1

r2d

dr

(

r2

ρ

dP

dr

)

= −4πGρ (3.5)

From (3.1):

dP

dr= Kγργ−1dρ

dr(3.6)

and substituting this into (3.5) gives:

1

r2d

dr

(

r2

ρKγργ−1dρ

dr

)

= −4πGρ (3.7)

Now define ρ ≡ λθn, γ ≡ (n+ 1)/n, substitute into (3.7) and rearrange:

[

(n+ 1)

4πGKλ

1−n

n

]

1

r2d

dr

(

r2dθ

dr

)

= −θn (3.8)

Then introduce the dimensionless variable ξ, which is defined by:

ξ =r

α, where α =

[

(n+ 1)

4πGKλ

1−n

n

]1/2

(3.9)

Substituting into (3.8) and rearranging gives the usual form of the Lane-Emden

equation:

1

ξ2d

(

ξ2dθ

)

+ θn = 0 (3.10)

P0114977 Mark Cannon

3.2 Discussion of the Lane-Emden equation 27

This is a second order ordinary differential equation, which means that it requires

two boundary conditions in order to be well-defined. We can choose λ in ρ ≡ λθn

at ξ = 0 to be equal to the central density of the star ρc. We must then seek a

solution of (3.10) which takes the value unity at the origin. Hence θ(0) = 1 is the

first boundary condition. Now there is no mass inside radius 0 and so from the

equation of hydrostatic equilibrium (3.2), dP/dr = 0. Hence, also, dθ/dξ = 0 at

ξ = 0 and so the second boundary condition is θ′(0) = 0. Differentiating out

equation (3.10) gives the second order differential equation which has to be solved:

d2θ

dξ2+

2

ξ

dξ+ θn = 0, with θ(0) = 1, θ′(0) = 0 (3.11)

3.2 Discussion of the Lane-Emden equation

Note that there are analytic solutions for values of n equal to 0, 1 and 5. Varying

n corresponds to varying the type of reactions that are occurring in the star

although only a limited range of values of n model actual stars.

For n = 0, the density of the solution as a function of radius is constant. This is

the solution for a constant density incompressible sphere which does not

correspond to any real star.

n = 0.5 to 1 corresponds to a neutron star

n = 1 to 1.5 approximates a fully convective star, i.e. a very cool late-type star

such as a M, L, or T dwarf. This includes red giants, brown dwarfs and giant

gaseous planets.

n = 3 is also known as the Eddington Approximation. It is useful as it corresponds

to a fully radiative star or main sequence star such as our own sun and also to

white dwarfs. There is no analytic solution for this value of n and it is the

numerical solution of this case that is the aim of the investigation.

n = 5 is the other value for which there is an analytic solution but it does not

P0114977 Mark Cannon

3.2 Discussion of the Lane-Emden equation 28

correspond to any real star structure since the zero is at infinity.

3.2.1 Analytic solutions

The details of the three analytic solutions which exist for the given boundary

conditions are in Chandrasekhar’s book, chapter IV [6] and are as follows:

For n = 0: θ0 = 1− 1

6ξ2, which has a zero at ξ1 =

√6 (3.12)

For n = 1: θ1 =sin(ξ)

ξ, which has a zero at ξ1 = π (3.13)

For n = 5: θ5 =1

1 + 13ξ2, which has a zero at infinity (3.14)

Note that the first zero is always described as ξ1 for all values of n. For the two

cases where there is a zero, the first derivative at these points are:

For n = 0: θ′(ξ1) = −√6

3(3.15)

For n = 1: θ′(ξ1) =cos(π)

π− sin(π)

π2(3.16)

All these solutions have been incorporated into the Maple code so that the

maximum error can be calculated both globally to give an estimate of ‖f − g‖∞and also the error in the approximations for the zero and the derivative at the zero.

3.2.2 A singular non-linear boundary problem

Note that in (3.11) the coefficient of θ′ is 2/ξ and this is singular at ξ = 0.

Symmetry and physical arguments above imply the boundary condition θ′(0) = 0.

This boundary condition means that the term (2/ξ)θ′(0) is well-defined as ξ

approaches 0. There is an important distinction between regular and irregular

singular points. The singular point at ξ = 0 is regular by definition if (ξ − ξ0)P (ξ)

P0114977 Mark Cannon

3.2 Discussion of the Lane-Emden equation 29

is bounded as ξ → ξ0. That is the defined expression must remain finite, where

P (ξ) is the coefficient of θ′ and ξ0 is the singular point. If this quantity does not

remain finite then the point is an irregular singular point. In this case ξ0 = 0 and

P (ξ) = 2/ξ and so:

(ξ − ξ0)P (ξ) = (ξ − 0)2

ξ= 2, which is finite (3.17)

Hence the singularity can be classed as a regular singular point. Another term for

a point like this is a non-essential singularity. Furthermore the singular point is on

the boundary and this can have an effect when attempting to find a solution. This

has to be taken into consideration when using alternative methods to collocation

and this is discussed further in section 5.1.

In addition the equation is non-linear due to the θn term, at least for n > 1. For

n = 0, 1 the equation simplifies to a linear differential equation.

Note also that having the two boundary conditions in (3.11) on the same boundary

(ξ = 0) makes this an initial value problem (in effect) and so more care needs to be

taken with the accuracy. Hence a determination of the accuracy is the aim of the

first part of the investigation. By getting numerical solutions for the cases

n = 0, 1, 5 and then comparing these with the analytic solutions it can be shown

whether the method of collocation provides accurate solutions or not. If it does

then more confidence can be placed in the solution of the case n = 3. A boundary

condition of this type is called a Cauchy boundary condition. It consists of a

Dirichlet and a Neumann boundary condition.

In conclusion the Lane-Emden equation is a singular non-linear boundary problem

where the regular singular point lies on the boundary. This should provide a stern

test for the collocation method.

P0114977 Mark Cannon

Chapter 4

Maple investigations

4.1 Linearisation of the Lane-Emden equation

The method used to linearise the differential equation is given by de Boor [2] in

chapter XV, equations (9), (10) and (11) and also in the course notes [3] in (11) on

page 24. The boundary-value problem:

(D2g)(x) = F (x; g(x), (Dg)(x)) (4.1)

is linearised by treating the function F as the function of two variables z1 and z2.

Newton’s method is applied, given an initial approximation f0(x) to g(x) and

(Df0)(x) to (Dg)(x). Then a Taylor approximation is used with z1 close to the

function fr(x) and z2 close to the function (Dfr)(x) giving the linearised equation:

(D2y)(x) = y(x)∂F

∂z1(x; fr(x), (Dfr)(x))

+ (Dy)(x)∂F

∂z2(x; fr(x), (Dfr)(x))

− fr(x)∂F

∂z1(x; fr(x), (Dfr)(x))

− (Dfr)(x)∂F

∂z2(x; fr(x), (Dfr)(x))

+ F (x; fr(x), (Dfr)(x)) (4.2)

After solving the equation there is a new solution y = fr+1(x). If fr+1 is

sufficiently close to fr and (Dfr+1) is sufficiently close to (Dfr) then stop.

Otherwise replace r by r + 1 in (4.2) and solve the equation again. A limit has to

P0114977 30 Mark Cannon

4.2 Description of the Maple code 31

be put on the number of iterations in case the method fails to converge.

Now, rearranging equation (3.11) and changing variables to be consistent with the

notation above gives:

g(x)′′ = −2

xg(x)′ − g(x)n = 0 (4.3)

Hence,

F (x; z1, z2) = −2

xz2 − zn1

So,∂F

∂z1= −nzn−1

1 and∂F

∂z2= −2

x

Now substitute into equation (4.2) and simplify giving:

g′′(x) +2

xg′(x) + n [v(x)]n−1 g(x) = (n− 1)[v(x)]n (4.4)

where v(x) is the value of g(x) obtained in the previous iteration. Now substitute

for the required values of n, giving:

For n = 0, g′′(x) +2

xg′(x) = −1 (4.5)

For n = 1, g′′(x) +2

xg′(x) + g(x) = 0 (4.6)

For n = 3, g′′(x) +2

xg′(x) + 3 [v(x)]2 g(x) = 2[v(x)]3 (4.7)

For n = 5, g′′(x) +2

xg′(x) + 5 [v(x)]4 g(x) = 4[v(x)]5 (4.8)

4.2 Description of the Maple code

The code used to solve the Lane-Emden problem is based on the Maple code in the

file M840Exercises.mws which was supplied with the course. The ‘Main

P0114977 Mark Cannon

4.2 Description of the Maple code 32

Procedures’ plus the ‘Chapter XV Main Example’ were copied and modified. The

procedures in Main Procedures are mostly the same as in M840Exercises.mws

except as described in this section. The two procedures colloc and difequ have

been modified and there are two new procedures and a new block of main code.

The code has been altered so that it can solve the Lane-Emden equation for a

general value of n, the polytropic index. Hence there is a new parameter passed

into colloc, n_int which is then stored as a global variable.

The purpose of the other changes are to accurately determine the zero of the

solution i.e. the value of ξ1 which gives θ(ξ1) = 0 and then to also calculate the

derivative at that zero. These two parameters are of particular significance and are

used later to calculate physical properties of the sun. The zero is first detected in a

new procedure plotApprox and then another new procedure findZero is used to

get a more accurate estimate by searching more finely and then using linear

interpolation.

As described in section 3.2.2 the problem is effectively an initial value problem

with the value θ and first derivative θ′ specified at the left hand boundary ξ = 0.

Therefore the right hand boundary for the purposes of the calculation has to be

chosen so that the zero will lie to the left of this value. By experiment a suitable

value for n = 0, 1, 3 was found to be 10.0 and so this was chosen for the second

parameter to the procedure colloc.

The modifications to difequ are fairly substantial and this procedure is listed in

Appendix A. The main changes are as follows:

• The variable gx is defined to contain the exact solution for n = 0, 1, 5 using

equations (3.12)-(3.14)

• Since both boundary conditions are at 0, then both side conditions must be

at zero.

• The values of v(x) and h(x) depend on the value of n and the general case

P0114977 Mark Cannon

4.2 Description of the Maple code 33

can be obtained from equation (4.4). This is used to set the values of v[1]

and v[4] in the code.

• The value of the side conditions are set according to (3.11).

There is a new procedure plotApprox which is called to post-process the results

obtained after calling colloc and this is also listed in Appendix A. Its main

functions are as follows:

• It plots a graph of the solution and in addition for n = 0, 1, 5 the exact

solution and the error function are also plotted on the same graph.

• The maximum error is recorded in the cases where an exact solution is known

• The zero of the function is detected by determining when the solution

changes sign and then the procedure findZero is called.

• The coordinates of the solution are stored for later use.

The procedure findZero is also in the Appendix:

• It searches between the two values found in plotApprox with a finer

resolution and then when the zero is detected it calculates its value using

linear interpolation.

• The value of the first derivative at the zero is also calculated using the

procedure ppvalu

• For x = 0 and 1 the exact values of the zero and first derivative are given in

(3.12)-(3.13) and (3.15)-(3.16) and are used to calculate the error in these

values.

The main code is as follows:

P0114977 Mark Cannon

4.3 Results of the investigation 34

• It calls colloc and plotApprox for n in the range 0 to 5. This prints out the

plots and the results obtained and the Maple output is listed in Appendix B.

• Then all the solutions for n=0 to 5 are plotted on one graph.

• Finally the central pressure, density and temperature are calculated using

the results for the zero and derivative obtained for n = 3.

4.3 Results of the investigation

4.3.1 Accuracy of the method

The results of the solutions for n = 0, 1, 5 are considered in this subsection. In

order to compare the results for different values of n it was decided to keep the

number of intervals fixed at 8. The order of the polynomials was then varied

between 5 and 10. For each of the three cases there is an analytic solution as

detailed in section 3.2.1 and hence the maximum error can be calculated which

gives an estimate for ‖f − g‖∞. In addition for the cases n = 0, 1 the exact value

of the zero of the solution is known and hence the accuracy of the linear

interpolation method can also be investigated.

The results are summarised in Tables 4.1-4.3 and in Figures 4.1-4.3. First consider

the results for n = 0 in Table 4.1. Note that increasing the order beyond 5 does

not improve either the maximum error or the estimate of the zero of the solution.

This implies that a limitation has been reached in the resolution of the method.

This is also indicated in Figure 4.1 where the error (shown in green) is not of the

expected shape.

Next consider the results for n = 1 in Table 4.2. Here, increasing the order results

in an improvement of the maximum error, the estimate of the zero ξ1 and also of

the estimate of the first derivative θ′(ξ1) at the zero. The solution is also shown in

Figure 4.2 where the error curve in green is of the expected form. Note that there

are multiple zeros for the case n = 1 but it is only the first zero which is of interest

P0114977 Mark Cannon

4.3 Results of the investigation 35

for stellar modelling.

Finally, consider the results for n = 5 in Table 4.3. There is no zero since it is at

infinity but it can be seen that the maximum error improves as the order of the

polynomials increases. However the accuracy for n = 5 is much less than for n = 1.

This is expected since n = 1 is a linear problem whereas for n = 5 it is a non-linear

problem in which the solution is obtained after 7 iterations of Newton’s method.

These results indicate that the method is reasonably accurate, for example for

n = 1 the error in the zero varies between 1.6× 10−5 for order 5 to 1.1× 10−11 for

order 10. This is certainly good enough for a stellar model which is only an

approximation in any case.

It is the solution for n = 3 that is being sought and assuming that the method is

as accurate for n = 3 as for n = 5 (which seems reasonable) then the results for

n = 5 and n = 1 can be used to select the required degree of accuracy for the zero

solution of n = 3. For example say the accuracy of the zero is required to 6

decimal places then referring to Table 4.2 then such accuracy is indicated for order

7 where the maximum error is 6.0× 10−8. Then referring to Table 4.3 it can be

seen that such a value of the maximum error can be expected for the non-linear

case when the order is 9.

Order Max error ξ1 (Zero) Error of ξ1 θ′(ξ1) Error of θ′(ξ1)5 2.00E-23 2.44948974278 -5.115E-13 -8.16496580928E-01 1.705E-136 3.00E-23 2.44948974278 -5.115E-13 -8.16496580928E-01 1.705E-137 2.30E-22 2.44948974278 -5.115E-13 -8.16496580928E-01 1.705E-138 2.20E-22 2.44948974278 -5.115E-13 -8.16496580928E-01 1.705E-139 1.00E-22 2.44948974278 -5.115E-13 -8.16496580928E-01 1.705E-1310 2.10E-22 2.44948974278 -5.115E-13 -8.16496580928E-01 1.705E-13

Table 4.1: Results for n = 0, 8 intervals

P0114977 Mark Cannon

4.3 Results of the investigation 36

Order Max error ξ1 (Zero) Error of ξ1 θ′(ξ1) Error of θ′(ξ1)5 4.176E-05 3.14157679305 -1.586E-05 -3.18221082925E-01 8.880E-056 2.323E-06 3.14159714976 4.496E-06 -3.18311437319E-01 -1.551E-067 6.045E-08 3.14159266219 8.596E-09 -3.18309720196E-01 1.660E-078 2.262E-09 3.14159265903 5.441E-09 -3.18309889446E-01 -3.262E-099 5.744E-11 3.14159265361 1.631E-11 -3.18309885994E-01 1.895E-1010 1.690E-12 3.14159265360 1.072E-11 -3.18309886187E-01 -3.297E-12

Table 4.2: Results for n = 1, 8 intervals

Order Max error5 8.029E-046 6.092E-057 9.102E-068 1.576E-069 6.323E-0810 3.498E-08

Table 4.3: Results for n = 5, 8 intervals

Figure 4.1: Lane-Emden solution for n = 0

P0114977 Mark Cannon

4.3 Results of the investigation 37

Figure 4.2: Lane-Emden solution for n = 1

Figure 4.3: Lane-Emden solution for n = 5

P0114977 Mark Cannon

4.3 Results of the investigation 38

4.3.2 Results for n = 3

Having investigated the accuracy of the method then the results for n = 3 are now

considered. See the estimates for the zero of the solution in Table 4.4. As the order

increases the value of the zero ξ1 converges towards 6.896849 (to six decimal

places). Note that this agrees with the value that is calculated in Chandrasekhar

[6] in Chapter IV Table 4 which is 6.89685. The value of the first derivative θ′(ξ1)

converges to 0.042429758 and this is also consistent with the value in [6].

A standard way to determine the “accuracy” of a numerical method applied to

determining an approximate solution to a differential equation is to progressively

double the number of computing points until successive approximations differ by

less than the required accuracy. The results in Table 4.4 illustrate how this

approach would work. If an accuracy of 6 decimal places is required then the order

of the polynomials required is 8 as indicated by the value 5.1× 10−7 in Table 4.4 in

the “difference” column. This required value of 8 is close to the value of 9 for the

order that was estimated in section 4.3.1.

Since the method will solve the Lane-Emden equation for any given value of n it is

a fairly simple task to get the solutions for all values of n from 0 to 5 and plot

them on a single graph. The procedure to do this is included in the Appendix and

the resulting diagram is shown in Figure 4.5. This shows how increasing the value

of n affects the solution. As n increases the mass becomes gradually more centrally

condensed. This means that the mass is more concentrated towards the centre of

the star. For a value of n = 3 there is central part which is more dense and this

gradually gives way to a much less dense part near the boundary of the star with a

large tail. However for n = 1 the density falls rapidly near the boundary of the

star and so the density is more constant through the star and hence less centrally

condensed.

P0114977 Mark Cannon

4.3 Results of the investigation 39

Order ξ1 (Zero) Difference θ′(ξ1)5 6.89905355146 - -4.23799904310E-026 6.89681721997 -2.236E-03 -4.24307003795E-027 6.89684817352 3.095E-05 -4.24297439469E-028 6.89684867876 5.052E-07 -4.24297571413E-029 6.89684861744 -6.132E-08 -4.24297576318E-0210 6.89684861943 1.990E-09 -4.24297576036E-02

Table 4.4: Results for n = 3, 8 intervals

Figure 4.4: Lane-Emden solution for n = 3

P0114977 Mark Cannon

4.3 Results of the investigation 40

Figure 4.5: Lane-Emden solution for various values of n

P0114977 Mark Cannon

4.3 Results of the investigation 41

4.3.3 Application of the results to our sun

The solution for n=3 is a model of our own sun and can be used to estimate some

physical parameters. Using the Lane-Emden analysis and actual external

measurements of the sun then the value of some internal properties can be

estimated.

The pressure at the centre of a star Pc is given in Chandrasekhar [6] chapter IV,

equations (80) and (81). Combining these two gives:

Pc =1

4π(n+ 1)[θ′(ξ1)]2GM2

R4= 1.25× 1016 Nm−2 (4.9)

where the mass of the sun M = 1.9891× 1030 kg, the radius of the sun

R = 6.955× 108 m, the gravitational constant G = 6.67384× 10−11 m3 kg−1 s−2 and

θ′(ξ1) = −0.042429758 from Table 4.4.

Also the density at the centre of the star ρc is given in [6] chapter IV, equation

(78):

ρc = −[

ξ13

1

θ′(ξ1)

]

ρ, where ρ =M

43πR3

(ρ is the mean density)

= 7.65× 104 kgm−3 (4.10)

where all the constants are defined above and ξ1 = 6.896848619 from Table 4.4.

Finally there is an analysis in [6] chapter VI, equations (69)-(72), which estimates

the temperature at the centre of the sun Tc for n = 3. The result is:

Tc = 19.72× βµM

⊙R⊙

R× 106 Kelvin

= 1.18× 107 K (4.11)

where:

• β is a constant factor relating the radiation pressure pr and the pressure P as

P0114977 Mark Cannon

4.3 Results of the investigation 42

pr = (1− β)P and its value is calculated in [6] as β = 0.003;

• the mean molecular weight of the stellar plasma µ = 0.6;

• ⊙ is the relative solar mass (and hence cancels out with M);

• R⊙ is the relative solar radius (and hence cancels out with R)

It is interesting to compare the values calculated above with those based on the

modern Standard Solar Model (SSM) as shown in Table 4.5. The SSM values were

obtained from [7].

Pc (Nm−2) ρc (kgm−3) Tc (K)

Lane-Emden 1.25× 1016 7.65× 104 1.18× 107

SSM 2.34× 1016 15.2× 104 1.57× 107

Table 4.5: Comparison of Lane-Emden and Standard Solar Model

Hence the values calculated using the Lane-Emden model are in reasonable

agreement with the best available solar models even though nuclear processes and

details of energy transfer have not been considered.

These values can be put into context by comparing them with the values for the

centre of the earth. The density at the core of the sun is only 11 times that of the

earth’s centre (although in fact the mean density of the sun is actually less than

that of the earth). However the temperature is a factor of 2500 times greater and

the pressure is 65,000 times greater. This shows just how different the state of

matter is in the sun’s plasma. It should also be borne in mind that conditions at

the centre of the earth are very different its surface. For example the “standard

atmosphere” which represents normal pressure at sea level is defined to be

1.01325× 104 (Nm−2). Thus the pressure at the centre of the sun is greater than

atmospheric pressure on the earth by a factor of more than 2× 1012.

P0114977 Mark Cannon

Chapter 5

Conclusion

5.1 Summary and discussion of results

It has been shown that the method of collocation can indeed be used to solve an

initial value type problem with Cauchy boundary conditions with high accuracy.

The solutions obtained for the polytropic index n = 3 agree with the literature.

Collocation can also be used to solve at least some differential equations which

have a regular singular point even when that singularity is on the boundary. It

can also be used to efficiently solve non-linear problems.

It is true that in order to get very accurate results it was necessary to use many

intervals and high order polynomials, particularly for higher values of n. For

example if 2 intervals and order 5 polynomials are used for the case n = 5 then the

accuracy is greatly reduced and the maximum error is 5.8× 10−2 which is not very

good. However the overhead of using the extra intervals and higher order is not

too great because the problem still runs quickly even on a moderately specified

laptop computer. What is less clear is how the efficiency compares to other

methods of solving the Lane-Emden equation and how the accuracy compares.

One alternative method of solving the Lane-Emden equation consists of obtaining

two separate first order differential equations by introducing a new variable. These

equations can then be solved on a computer using any standard numerical

integration package. However, numerical integration suffers from the disadvantage

that errors accumulate as the solution gets further from the boundary at the initial

condition. Hence the accuracy will be worst at the right hand boundary where the

P0114977 43 Mark Cannon

5.2 Further areas of study 44

zero of the solution occurs. In other words the accuracy is worst at the very point

where we want to determine the zero and the derivative at the zero. On the other

hand collocation is trying to fit the curve globally and so the errors are spread out

over the interval and there is no reason why the maximum error would occur at

the right hand boundary. Intuitively it seems that the accuracy of collocation

might be greater although this would need to be verified.

There is also one further problem with numerical integration for this problem and

that is the regular singularity at the origin. The integration will fail if this

boundary is included. One possible solution is to start with a very small finite

value of ξ and apply the boundary conditions there. However the error introduced

leads to a large error in the solution when far from the boundary. The solution is

to use a power series expansion of θ about ξ = 0 and use the solution to the series

to determine the initial conditions at a small finite value of ξ.

5.2 Further areas of study

There are many further areas of study which could extend the investigations in

this dissertation. Some are improvements in the method itself and others are new

areas of investigation; some possibilities for both are described in the following

paragraphs.

Improve the procedure findZero

There is a more accurate and efficient way of calculating the zero of the solution

which would require only a modification of the procedure findZero. Rather than

sweeping across the whole of the interval in constant sized steps, detecting the zero

and then performing a linear interpolation it would be possible to home in on the

solution using an iterative method. The step size could be gradually reduced and

it would only be necessary to keep track of the sign of the last solution. In this

way it would be possible to specify the accuracy required and then stop when the

last two estimates agree to that number of decimal places. It appears that this

P0114977 Mark Cannon

5.2 Further areas of study 45

would converge to the solution fairly rapidly and so would be more efficient than

the current method.

Reduce the maximum error

Having obtained as accurate a value as possible for the zero then the problem

could be modified to be a two-point boundary problem. So the boundary

conditions would become θ(0) = 1 and θ(ξ1) = 0. This may well increase the

overall accuracy of the solution and lead to a lower value of the maximum error.

This theory could be tested for the cases n = 0 and n = 1 since there are analytic

solutions for these values of n.

Compare collocation against other methods

A useful extension would be to investigate the efficiency of collocation compared to

other methods, one of which is described above. This investigation could take the

form of an efficiency determination by calculating the run time that the computer

takes to solve the problem. The actual results obtained could also be compared

and at least for those cases where there are analytic solutions a comparison of

accuracy could be made. There are other solutions in the literature and these

methods could be investigated too.

Sensitivity to initial coefficient values

The sensitivity of the solution to the initial guess for the Newton iteration could

also be investigated. In other words how close do the initial values of the

coefficients of the piecewise polynomial representation have to be to the final

converged values in order that convergence takes place? For this problem analytic

solutions are available and these suggest what values should be chosen. However

for other problems the starting values of the coefficients might have to be guessed

or randomly chosen. As part of this investigation it would also be possible to see if

the number of iterations that are required for convergence varies with the initial

values of the coefficients.

Non-integer values of n

Some models for stars use non-integer values of the polytropic index n. For

P0114977 Mark Cannon

5.2 Further areas of study 46

example a neutron star is in the range n = 0.5 . . 1 and a value of n = 1.5 is a good

model for fully convective star cores such as a red giant and giant gaseous planets

like Jupiter. However when the Maple code was used to solve these problems the

code failed. The problem was that instead of returning real floating point values

for the solution, there were complex number values returned instead. It would be

interesting to see if the collocation method and its implementation can be

debugged, fixing these errors, so that correct solutions can be obtained for the

non-integer values. Note that these solutions do exist and numerical integration

gives these solutions and there are also examples of tables with such solutions in

[6].

The Chandrasekhar Limit

The study of a high density white dwarf with n = 3 could also be used to give an

indication of the Chandrasekhar Mass. This is the critical mass above which

electron degeneracy pressure in the star’s core is insufficient to balance the star’s

own gravitational self-attraction and it collapses into either a neutron star or a

black hole.

The Lane-Emden equation is not just of historical interest; it is still a topic of

active research today. For example see “The Lane-Emden equation revisited”

(2003) [11] and “Approximate Analytic and Numerical Solutions to Lane-Emden

Equation via Fuzzy Modeling Method” (2012) [12] among others and so its

numerical solution is still relevant.

P0114977 Mark Cannon

Appendix A

Maple Code

The altered Maple code used to solve the differential equation by collocation is

listed here. The starting point was the Maple code in the file M840Exercises.mws

which was supplied with the course. The ‘Main Procedures’ plus the ‘Chapter XV

Main Example’ were copied and modified. The procedures in Main Procedures are

mostly the same as in M840Exercises.mws except for the source code listed here.

###################################################################

# This function is similar to the one in M840Exercises.mws

# Any edits have a comment at the start of the change with text as follows:

# Change here - ......

difequ:=proc(mode::integer,xx,v_tmp)

local i,kmax,ncoef,npiece,\

ep1,ep2,error1,solutn,\

un,x,v,ii,jj,icnt,coef_approx1,nn,ni:

global bbreak_approx,coef_approx,l_approx,kpm_approx,\

m_side,iside_side,xside_side,\

itermx_other,k_other,rho_other,\

factor_difequ,s2ovep_difequ,gx,n_le:

v:=v_tmp:

npiece:=100: kmax:=20: ncoef:=npiece*kmax:

# integer mode, i,iside,itermx,k,kmax,kpm,l,m,ncoef,npiece:

# parameter (npiece:=100, kmax:=20, ncoef:=npiece*kmax):

# real v[kmax],xx, bbreak,coef,eps,ep1,ep2,error1,factor,rho,solutn:

# * ,s2ovep,un,x,xside:

# common/approx/ bbreak[npiece],coef[ncoef],l,kpm:

# common/side/ m,iside,xside[10]:

# common/other/ itermx,k,rho[kmax-1]:

# save eps,factor,s2ovep:

P0114977 47 Mark Cannon

A Maple Code 48

#c from * a practical guide to splines * by c. de boor :

#calls ppvalu(interv):

#c to be called by c o l l o c , p u t i t:

#c information about the differential equation is dispensed from here:

#c:

#c****** i n p u t ******:

#c mode an integer indicating the task to be performed.:

#c := 1 initialization:

#c := 2 evaluate de at xx:

#c := 3 specify the next side condition:

#c := 4 analyze the approximation:

#c xx a point at which information is wanted:

#c:

#c****** o u t p u t ******:

#c v depends on the mode . see comments below:

#c:

#c:

#c this sample of difequ is for the example in chapter xv. it is a:

#c nonlinear second order two point boundary value problem.:

#c:

nn:=convert(n_le, float):

# Change here - Analytic solutions exist for the cases n=0,1,5

# Define gx depending on the value of n (the polytropic index)

if n_le=0 then gx:=1.0-(x_loc)^2/6.0

elif n_le=1 then gx:=sin(x_loc)/x_loc

elif n_le=5 then gx:=1.0/sqrt(1.0+(x_loc)^2/3.0)

else gx:=0

end if:

if mode=1 then goto(10) end if:

if mode=2 then goto(20) end if:

if mode=3 then goto(30) end if:

if mode=4 then goto(40) end if:

#c initialize everything:

#c i.e. set the order m of the dif.equ., the nondecreasing sequence:

#c xside_side[i],i:=1,...,m, of points at which side cond.s are given and:

#c anything else necessary.:

10:

m_side := 2:

# Change here - both boundary conditions are at 0

xside_side[1] := 0.:

xside_side[2] := 0.:

#c *** print out heading:

printf(" ******************************************\n");

printf(" Lane-Emden problem n=%d", n_le):

printf("\n"):

P0114977 Mark Cannon

A Maple Code 49

# Change here - epsilon is not needed and has been deleted

l_approx := 1:

bbreak_approx[1] := 0.:

# Change here - all coefficents default to zero

for i from 1 to kpm_approx do:

coef_approx[i] := 0.:

end do:

# Overwrite the first coefficient

coef_approx[1] := 1.0:

itermx_other := 10:

return eval(v):

#c:

#c provide value of left side coef_approxf.s and right side at xx .:

#c specifically, at xx the dif.equ. reads:

#c v[m+1]d**m + v[m]d**(m-1) + ... + v[1]d**0 := v[m+2]:

#c in terms of the quantities v[i],i:=1,...,m+2, to be computed here.:

20:

v[3] := 1.0:

v[2] := 2.0/xx:

# coeff_approx is an array in ppvalu

icnt:=0:

for jj from 1 to l_approx do:

for ii from 1 to kpm_approx do:

icnt:=icnt+1:

coef_approx1[ii,jj]:=coef_approx[icnt]:

end do:

end do:

un := ppvalu(bbreak_approx,coef_approx1,l_approx,kpm_approx,xx,0):

# Change here - the values of v(x) and h(x) are obtained in the main text

# Note that n=0 and n=1 are the two linear cases. All other values of n

# are non-linear

if (n_le=0) then

v[1]:=0.0:

v[4]:=-1.0

elif (n_le=1) then

v[1]:=1.0:

v[4]:=0.0

else

v[1]:=nn*(un^(nn-1.0)):

v[4]:=(nn-1.0)*(un^nn)

end if:

return eval(v):

#c:

#c provide the m side conditions. these conditions are of the form:

#c v[m+1]d**m + v[m]d**(m-1) + ... + v[1]d**0 := v[m+2]:

P0114977 Mark Cannon

A Maple Code 50

#c in terms of the quantities v[i],i:=1,...,m+2, to be specified here.:

#c note that v[m+1] := 0 for customary side conditions.:

30:

v[m_side+1] := 0.:

if iside_side=1 then goto(31) end if:

if iside_side=2 then goto(32) end if:

if iside_side=3 then goto(39) end if:

31:

v[2] := 1.:

v[1] := 0.:

v[4] := 0.:

goto(38):

32:

v[2] := 0.:

v[1] := 1.:

v[4] := 1.:

38:

iside_side := iside_side + 1:

39:

return eval(v):

#c:

#c Mode 4 - analysis:

# Change here - don’t do any extra analysis

40:

printf("Don’t do anything"):

printf("\n"):

return eval(v):

end proc:

###################################################################

findZero:=proc(x_start, x_end, coef_approx1)

# This is a new procedure. It searches between x_start and x_end for

# the zero - i.e. where the function changes sign. It then calculates

# the ’x’ coordinate of the zero using linear interpolation.

# The value of the first derivative at this zero is also calculated.

# Also for x=0,1 the actual value of the zero and the derivative is

# known and so the error can be calculated

local ii, numPoints, dx, zeroPoint, x1, x2, y1, y2, firstDeriv, secondDeriv:

global bbreak_approx,l_approx,kpm_approx, n_le:

numPoints := 1001:

dx := (x_end - x_start)/(numPoints - 1):

x2 := x_start;

for ii from 1 to numPoints do:

P0114977 Mark Cannon

A Maple Code 51

x1:=x2:

x2:=x1+dx:

y1:=ppvalu(bbreak_approx, coef_approx1, l_approx, kpm_approx, x1, 0):

y2:=ppvalu(bbreak_approx, coef_approx1, l_approx, kpm_approx, x2, 0):

# Check if the zero has been found

if signum(y2) <> signum(y1) then

# Calculate the zero using linear interpolation

zeroPoint:=(x2*y1 - x1*y2)/(y1 - y2):

printf(" zero at %25.18e\n", zeroPoint);

# The zero is only known for n=0 and n=1 (n=5 is at infinity)

# so print out the error in the zero for these cases

if n_le=0 then printf(" zeroError = %23.16e\n", zeroPoint-sqrt(6.0));

elif n_le=1 then printf(" zeroError = %23.16e\n", zeroPoint-Pi);

end if:

firstDeriv:=ppvalu(bbreak_approx, coef_approx1, l_approx, kpm_approx, zeroPoint, 1):

printf(" 1st deriv at zero = %23.16e\n", firstDeriv);

# Similarly the first derivative at the zero is only known for n=0,1

# so print out the error in the derivative for these cases

if n_le=0 then printf(" derivError = %23.16e\n", firstDeriv + sqrt(6.0)/3.0);

elif n_le=1 then printf(" derivError = %23.16e\n", firstDeriv - cos(Pi)/Pi + sin(Pi)/Pi^2 );

end if:

end if:

end do:

end proc:

###################################################################

plotApprox:=proc(graphtitle, c)

local ii, jj, coef_approx1, icnt, gr1, numPoints, v1, v2,

v3, v4, xflt, dx, xylist, colLst, t1, p, maxError, absError,

zeroPoint, numGraphs, t7:

# The following parameters are required to plot the piecewise polynomial

global bbreak_approx,coef_approx,l_approx,kpm_approx,n_le,plist:

#calls splint, bsplpp, ppvalu:

#c****** i n p u t ******:

#c graphtitle...string to display as the graph title:

#c:

#c****** o u t p u t ******:

#c none:

P0114977 Mark Cannon

A Maple Code 52

icnt:=0:

maxError:=0.:

for jj from 1 to l_approx do:

for ii from 1 to kpm_approx do:

icnt:=icnt+1:

coef_approx1[ii,jj]:=coef_approx[icnt]:

end do:

end do:

# Only plot the exact graph and error for n=0,1,5

if n_le=0 or n_le=1 or n_le=5 then numGraphs:=3

else numGraphs:=1

end if:

# Plot the approximation, the exact value and the error on one diagram

gr1:=NULL:

numPoints:=1001:

v1:=Vector(numPoints):v2:=Vector(numPoints):

v3:=Vector(numPoints):v4:=Vector(numPoints):

xflt:=0.:

dx:=bbreak_approx[l_approx+1]/(numPoints-1):

for ii from 1 to numPoints do:

v1[ii]:= xflt:

v2[ii]:= ppvalu(bbreak_approx,coef_approx1,l_approx,kpm_approx,xflt,0):

v3[ii]:= evalf(subs(x_loc=xflt, gx)):

v4[ii]:= (v2[ii] - v3[ii])*c:

# Keep a record of the largest value of the error

absError:=abs(v2[ii] - v3[ii]):

if absError>maxError then maxError:=absError end if:

# Has the solution crossed the ’y’ axis?

if ii>1 then

if signum(v2[ii]) <> signum(v2[ii-1]) then

# If a zero has been detected then calculate an accurate value

findZero(v1[ii-1], v1[ii], coef_approx1):

end if:

end if:

xflt:=xflt+dx:

end do:

# Plot the solutions

xylist[1] := zip( (x,y) -> [x,y], v1, v2 ):

xylist[2] := zip( (x,y) -> [x,y], v1, v3 ):

xylist[3] := zip( (x,y) -> [x,y], v1, v4 ):

colLst:=[red,blue,green]:

for jj from 1 to numGraphs do:

p:=plot(xylist[jj],title=graphtitle,colour=colLst[jj],labels=["",theta(xi)]);

t7:=textplot([10.0,0.1,xi],’align’=’left’):

P0114977 Mark Cannon

A Maple Code 53

gr1:=gr1,display({p, t7}):

end do:

# Keep a copy of the co-ordinates in plist so that a plot

# can be done later for all the solutions n=0..5

plist[n_le+1]:=eval(xylist[1]):

printf(" maxError =%10.3e\n", maxError);

# Now display the graph

display(gr1);

end proc:

###################################################################

#c main program for Lane-Emden problem:

#c solution of a second order two point boundary value:

#c problem on (0., 10.) , by collocation with pp functions having:

#c pieces of varying order. Newton iteration is to be stopped:

#c when two iterates agree to 7 decimal places.:

colloc(0.,10.0,8,9,0,0.,0.00000001,0):

t1:=cat("Lane-Emden n=0, l=8, order=9"):

plotApprox(t1, 1.0*10^23);

colloc(0.,10.0,8,9,0,0.,0.00000001,1):

t1:=cat("Lane-Emden n=1, l=8, order=9"):

plotApprox(t1, 1.0*10^10);

colloc(0.,10.0,8,9,0,0.,0.00000001,2):

t1:=cat("Lane-Emden n=2, l=8, order=9"):

plotApprox(t1, 1.0);

colloc(0.,10.0,8,9,0,0.,0.00000001,3):

t1:=cat("Lane-Emden n=3, l=8, order=9"):

plotApprox(t1, 1.0);

colloc(0.,10.0,8,9,0,0.,0.00000001,4):

t1:=cat("Lane-Emden n=4, l=8, order=9"):

plotApprox(t1, 100000000000.0);

colloc(0.,10.0,8,9,0,0.,0.00000001,5):

t1:=cat("Lane-Emden n=5, l=8, order=9"):

plotApprox(t1, 1.0*10^7);

#########################################################

# Print out the solutions for n=1 to 5 on one graph

#

t1:=typeset("Solutions ", theta(xi)," to the Lane-Emden equation for various values of n"):

P0114977 Mark Cannon

A Maple Code 54

gr1:=NULL:

for jj from 1 to 6 do:

p:=plot(plist[jj],title=t1,labels=["",theta(xi)]):

gr1:=gr1,display(p):

end do:

t1:=textplot([2.39,-0.3,"n=0"],’align’=’below’):

t2:=textplot([4.3,-0.23,"n=1"],’align’=’below’):

t3:=textplot([6.1,-0.19,"n=2"],’align’=’below’):

t4:=textplot([5.5,0.089,"n=3"],’align’=’above’):

t5:=textplot([6.4,0.16,"n=4"],’align’=’above’):

t6:=textplot([7.3,0.23,"n=5"],’align’=’above’):

t7:=textplot([10.0,-0.2,xi],’align’=’left’):

display({gr1,t1,t2,t3,t4,t5,t6,t7},’view’=[0..10,-1..1]);

###################################################

# Calculate the pressure (Pc), density (pc) and

# temperature (Tc) at the core of the sun

#

printf("*********************************************\n"):

printf("* Calculate pressure, density and temperature\n"):

xi1:=6.896848617438180720:

theta1_d:=0.042429758:

n:=3:

M:=1.9891*10^(30):

R:=6.955*10^(8):

G:=6.67384*10^(-11):

Pc:=evalf(M^2*G/(4*Pi*R^4*(n+1)*(0.042429758)^2)):

pc:=evalf(xi1/(3*theta1_d)*M/((4/3*Pi*R^3))):

beta:=(1-0.003):

mu:=0.6:

Tc:=19.72*beta*mu*10^6:

printf("Pressure Pc = %12.5e\n", Pc):

printf("Density pc = %12.5e\n", pc):

printf("Temperature Tc = %12.5e\n", Tc):

P0114977 Mark Cannon

Appendix B

Maple Output

The output of the Maple code is shown here. Note that the plots of the graphshave been removed since these are already in the main text. Only the output forthe calculation of order 9 are here. To change the order, adjust the fourthparameter in the calls to colloc. and re-run the code. Note that the scaling factorused when plotting graph of the error has been set to an appropriate value fororder 9 and so may have to be adjusted when using a different order.

******************************************

Lane-Emden problem n=0

using 7 Gaussian collocation points

approximation from a space of splines of order 9 on 8 intervals of dimension 58.

converged after 1 of 10 allowed iterations

zero at 2.449489742782666561e+00

zeroError = -5.1153767537800000e-13

1st deriv at zero = -8.1649658092755552e-01

derivError = 1.7051255845990000e-13

maxError = 1.000e-22

******************************************

Lane-Emden problem n=1

using 7 Gaussian collocation points

approximation from a space of splines of order 9 on 8 intervals of dimension 58.

converged after 1 of 10 allowed iterations

zero at 3.141592653606104391e+00

zeroError = 1.6311152219315000e-11

1st deriv at zero = -3.1830988599432569e-01

derivError = 1.8946498215887540e-10

zero at 6.283185307180666380e+00

zeroError = 3.1415926535908731e+00

1st deriv at zero = 1.5915494311129818e-01

derivError = 4.7746482929508885e-01

zero at 9.424777960933622445e+00

zeroError = 6.2831853073438292e+00

1st deriv at zero = -1.0610329508958929e-01

P0114977 55 Mark Cannon

B Maple Output 56

derivError = 2.1220659109420138e-01

maxError = 5.744e-11

******************************************

Lane-Emden problem n=2

using 7 Gaussian collocation points

approximation from a space of splines of order 9 on 8 intervals of dimension 58.

converged after 7 of 10 allowed iterations

zero at 4.352874595858075083e+00

1st deriv at zero = -1.2724865080654556e-01

maxError = 1.109e+00

******************************************

Lane-Emden problem n=3

using 7 Gaussian collocation points

approximation from a space of splines of order 9 on 8 intervals of dimension 58.

converged after 7 of 10 allowed iterations

zero at 6.896848617438180720e+00

1st deriv at zero = -4.2429757631788092e-02

maxError = 1.000e+00

******************************************

Lane-Emden problem n=4

using 7 Gaussian collocation points

approximation from a space of splines of order 9 on 8 intervals of dimension 58.

converged after 7 of 10 allowed iterations

maxError = 1.000e+00

******************************************

Lane-Emden problem n=5

using 7 Gaussian collocation points

approximation from a space of splines of order 9 on 8 intervals of dimension 58.

converged after 7 of 10 allowed iterations

maxError = 6.323e-08

*********************************************

* Calculate pressure, density and temperature

Pressure Pc = 1.24707e+16

Density pc = 7.64778e+04

Temperature Tc = 1.17965e+07

P0114977 Mark Cannon

Bibliography

[1] Carl de Boor and Blair Swartz, Collocation at Gaussian points, SIAM Journalon Numerical Analysis, Vol.10, No. 4, September 1973, pp 582-606

[2] Carl de Boor, A Practical Guide to Splines, Revised Edition, Springer-Verlag,New York, USA, 2001

[3] The Open University, M840 option: Advances in Approximation Theory

Module Guide, 2013; available from the Maths MSc website.

[4] M. J. D. Powell, Approximation theory and methods, Cambridge UniversityPress, 1981

[5] U. Ascher, R. Mattheij, and R. Russell, Numerical Solution of Boundary

Value Problems for Ordinary Differential Equations, SIAM, Philadelphia,second edition, 1995

[6] S. Chandrasekhar, An Introduction to the Study of Stellar Structure, DoverPublications Inc., New York, USA, 1958

[7] J. Bahcall, Physics Letters B, 433, 1, 1998

[8] J. Homer Lane, On the Theoretical Temperature of the Sun under the

Hypothesis of a Gaseous Mass Maintaining Its Volume by Its Internal Heat

and Depending on the Laws of Gases Known to Terrestrial Experiment, Amer.J. Sci, 2nd ser., 50, 57-74 1869

[9] R. Emden, Gaskugeln, Teubner - Verlag, Leipzig and Berlin, 1907

[10] A. Ritter, Unterschungen uber die Hohe der Atmosphare und die Constitution

gasformiger Weltkoper, presented to the Wiedmann Annalen, 1878-1889

[11] Rafael Benguria, The Lane-Emden equation revisited, ContemporyMathematics, Vol.327, 2003, pp 11-19

[12] De-Gang Wang, Wen-Yan Song, Peng Shi, Hamid Reza Karimi, Approximate

Analytic and Numerical Solutions to Lane-Emden Equation via Fuzzy

Modeling Method, Mathematical Problems in Engineering Volume 2012,Article ID 259494

P0114977 57 Mark Cannon