computational approaches *5mm in ...coral.ufsm.br/biomatematica/wwmbpetrovskaya1.pdfr.l.burden,...

56
COMPUTATIONAL APPROACHES IN MATHEMATICAL ECOLOGY Natalia Petrovskaya School of Mathematics, University of Birmingham, UK Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Upload: others

Post on 27-May-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

COMPUTATIONAL APPROACHES

IN MATHEMATICAL ECOLOGY

Natalia Petrovskaya

School of Mathematics,

University of Birmingham, UK

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 2: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

The outline of the course (3 lectures, 1.5 hours each)

WE WILL DISCUSS:∙ definition of basic numerical methods

∙ how to apply them in ecological problems

WE WILL NOT DISCUSS:∙ programming techniques

http://web.mat.bham.ac.uk/N.B.Petrovskaya/NBPetrovskaya teaching.htm

∙ software for ecological applicationsR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005

∙ basic mathematics behind numerical methods

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 3: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

The outline of the course (3 lectures, 1.5 hours each)

INTRODUCTION:

∙ Computational ecology beyond statistics∙ Error analysis

HANDLING FUNCTIONS:

∙ Interpolation∙ Numerical integration∙ Finding roots

HANDLING FUNCTION DERIVATIVES:

∙ Numerical solution of ODEs∙ Numerical solution of PDEs

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 4: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

LECTURE 1: Error analysis and

function approximation

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 5: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Why computational methods in ecology (apart fromprocessing big data sets)?

∙ Complexity of ecological problems↓

∙ Complex mathematical models↓

∙ Solution in closed form is not available↓

∙ Numerical solution↓

Is a numerical solution good enough? →reliable and accurate computational methods

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 6: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

What is wrong with the numerical solution?

x0 0.25 0.5 0.75 1

-0.7

-0.6

-0.5

-0.4

-0.3

-0.2

-0.1

0

0.1

0.2

0.3

0.4

U(x) 2a

x0 0.5 1 1.5

-1

-0.5

0

0.5

1

1.5

1aU(x)

x0 0.5 1 1.5

-1

-0.5

0

0.5

1

1.5

1buh(x)

x0 0.25 0.5 0.75 1

-2

-1

0

1

2

3

4

5

6

7

8

uh(x) 2b

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 7: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

How do we know that the numerical solution iscorrect?

X

Y

0 0.2 0.4 0.6 0.8 10

0.2

0.4

0.6

0.8

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 8: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Error analysis

▶ A wrong ecological hypothesis

▶ Errors in the mathematical model

▶ Measurement errors

▶ Truncation errors

▶ Round-off errors

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 9: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Truncation error

∙ A truncation error is a characteristics of a numericalmethod used in the problem.

∙ Example: Consider the population size n(t) and let thepopulation growth rate be dn(t)/dt .

– Replace dn(t)/dt by a finite difference (n2 − n1)/�t , wheren2 and n1 are the total number of a given species at time tand t + �t .

– Assume zero error of the measurements.– The error of the method (as we replace the true derivative

with a finite difference) has nothing to do with themeasurement error.

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 10: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Truncation error in ecological problems

∙ In ecological problems, while a huge body of the researchhas been provided on the measurement errors, thetruncation error related to the method has not been studiedin detail.

∙ Example: Most of the sampling protocols currently used forthe pest control imply that the truncation error is muchsmaller that the measurement error.

– The theory states the truncation error is fully controllableand therefore the inherent error is of the utmostimportance.

– THIS IS NOT ALWAYS TRUE! (e.g. highly aggregateddensity distributions)

– For a small number of samples the truncation errorbecomes a random error.

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 11: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Truncation error

∙ A newly developed method is worthless without an erroranalysis!

∙ It does not make sense to use methods which introduceerrors with magnitudes larger than the effects to bemeasured or simulated.

∙ On the other hand, using a method with very high accuracymight be computationally too expensive to justify the gainin accuracy.

∙ Basic means of control: the quality (e.g. a polynomialdegree) of function or/and function derivativeapproximation, the time step size, the grid step size

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 12: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Obtaining reliable and accurate numerical solutions

4 3

2 1

Mat

hem

atic

al m

odel

Num

eric

al m

etho

d

Cod

e de

velo

pmen

t

Ver

ifica

tion

Val

idat

ion

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 13: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Obtaining reliable and accurate numerical solutions

∙ Preparation: specification of objectives, geometry, initialand boundary conditions, and available benchmarkinformation; selection of the numerical method.

∙ Verification: a process for assessing simulation numericaluncertainty. Robustness of the simulation results should beproved by comparing them with the known analyticalproperties of the model, e.g. with exact solutions.

∙ Validation: a process for assessing simulation modellinguncertainty by using benchmark experimental data.

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 14: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Summary

∙ Exploiting any computer program requires goodunderstanding of (a) the ecological problem, (b) themathematical model, and (c) a numerical method used inthe code.

∙ Error analysis is a must! Never skip preparation,verification and validation steps when you solve a problemnumerically.

∙ "Do use others people software but if you cannotunderstand a numerical algorithm behind the software,then never use it." (F.S. Acton, 1990)

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 15: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

References

∙ F.S. Acton. Numerical Methods That Work. Washington,DC: Math. Assoc. Amer., 2nd edition 1990.

∙ R.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole,Belmont,CA, 2005.

∙ J.D. Hoffman. Numerical Methods for Engineers andScientists. CRC Press, 2nd edition, 2001.

∙ S.V.Petrovskii, N.B.Petrovskaya. Computational Ecologyas an Emerging Science. J.R.Soc. Interface Focus, 2012,vol.2(2), pp.241-254.

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 16: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Function interpolation

in ecological problems

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 17: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Ecological problem: pest insect monitoring and control

∙ The information aboutpest population sizeis obtained throughtrapping

∙ Once the samples(trap counts) arecollected, the totalnumber of the insectsin the field is evaluated

The need in reliable methods to estimate the pest populationsize in order to avoid unjustified pesticides application and yetto prevent pest outbreaks.

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 18: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Experimental layout for pest insect monitoring

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 19: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Example of spatial data: flatworm (Arthurdendyus triangulatus) spatial density

distribution u(x , y) reconstructed from field data.

Given the pest density u(x , y) at selected points, how canwe reconstruct the pest insects density at any point (x , y)?

X

Y

0 0.2 0.4 0.6 0.8 10

0.2

0.4

0.6

0.8

113

12

11

10

9

8

7

6

5

4

3

2

1

u(x,y)

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 20: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Example of temporal data: oscillations of the pest insect population

What is the accuracy of our evaluation?

0 0.5 1 1.5 2 2.5 30

1000

2000

3000

4000

continuous function

interpolation

n(t)

t

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 21: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Example of temporal data: oscillations of the pest insect population

How to achieve reliable accuracy?

0 0.5 1 1.5 2 2.5 30

1000

2000

3000

4000

continuous function

interpolation

n(t)

t

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 22: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

References

∙ N.B.Petrovskaya, N.L.Embleton. Computational Methodsfor Accurate Evaluation of Pest Insect Population Size.W.A.C. Godoy and C.P. Ferreira (eds.), EcologicalModelling Applied to Entomology, Springer-Verlag BerlinHeidelberg, 2014.

∙ N.B.Petrovskaya, S.V.Petrovskii, A.K.Murchie. Challengesof Ecological Monitoring: Estimating PopulationAbundance From Sparse Trap Counts. J.R.Soc.Interface,2012, vol.9(68), pp.420-435

∙ R.L.Metcalf, W.H.Luckmann (eds) Introduction to InsectPest Management. Wiley, London, 1982.

∙ T.R.E. Southwood, P.A.Henderson PA Ecological Methods.Blackwell Science Ltd., Oxford, 2000.

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 23: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

An interpolation problem: outline

∙ Interpolation problem statement

∙ 1-d polynomial interpolation: Lagrange interpolation,interpolation by divided differences

∙ Interpolation error

∙ Piecewise polynomial interpolation

∙ 2-d polynomial interpolation

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 24: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Interpolation problem

∙ Given the pairs (x0,F0), (x1,F1),. . ., (xN ,FN), the problemof interpolation is to find an approximate value of f (x) thatcorresponds to any selected value of x ∈ D.

∙ 1-d interpolation: Consider a 1-d domain [a,b]. Let onlyone value Fi be defined at each point xi and Fi ≡ fi . Forsuch data the interpolation problem can be formulated as:Given the pairs (x0, f0), (x1, f1),. . . (xN , fN), and an arbitrarypoint x ∈ [a,b], find an approximate value of f (x).

∙ Straightforward solution: replace f (x) with a polynomialp(x).

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 25: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Polynomial interpolation

∙ How do we know that the polynomial interpolation is goodenough for our problem?

– The Weierstrass approximation theorem.

∙ How can we construct a polynomial p(x) that willinterpolate f (x)?

– We have to use all input information given to us.

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 26: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Polynomial interpolation

∙ We have N + 1 pairs (xi , fi), i = 0,1,2 . . . ,N:

f (x) ≈ p(x) =N∑

k=0

ak�k (x),

where �k (x) are polynomial basis functions chosen for theapproximation.

∙ Fit the polynomial to data:

p(xi) = f (xi), i = 0,1 . . . ,N.

∙ Solve for unknown coefficients a = (a0,a1, . . . ,aN),

Va = f.

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 27: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Monomial basis

f (x) ≈ p(x) =N∑

k=0

akxk .

a0 + a1x0 + . . .+ aNxN0 = f0,

a0 + a1x1 + . . .+ aNxN1 = f1,

...a0 + a1xN + . . .+ aNxN

N = fN .

Because points (x0, x1, . . . , xN) are distinct, the matrixinverse V−1 exists,

a = V−1f.

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 28: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Lagrange interpolation

�k (x) ≡ Lk (x) =∏l ∕=k

x − xl

xk − xl, k = 0,1, . . . ,N.

Lk (xi) = �ik =

{1, if i = k ,0, if i ∕= k .

p(x) =N∑

k=0

f (xk )∏l ∕=k

x − xl

xk − xl

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 29: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Interpolation by divided differences

For any function g(x) the divided differences are

g(xi , xj) = (g(xi)− g(xj))/(xi − xj),g(xi , xj , xk ) = (g(xi , xj)− g(xj , xk ))/(xi − xk ),

...g(xi , xj . . . , xm, xp) = (g(xi , . . . , xm)− g(xj , . . . , xp))/(xi − xp)

Any polynomial is p(x) = p(x0) + (x − x0)p(x0, x1)+. . . (x − x0)(x − x1) . . . (x − xN−1)p(x0, x1, . . . , xN)

We have f (x) ≈ p(x), p(xk ) = f (xk ) :

f (x) ≈ f (x0) +N∑

k=1ak�k (x) =

f (x0) +N∑

k=1f (x0, x1, . . . , xk )(x − x0)(x − x1) . . . (x − xk−1).

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 30: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Interpolation error

∙ The accuracy of interpolation depends on

– the total length of the interval [a,b], where the points xi arelocated,

– the polynomial degree N that we use for the interpolation.

∙ The interpolation error E(x) at the point x

E(x) = ∣f (x)− p(x)∣

How to estimate the interpolation error E(x) if f (x) is notavailable?

E(x) = ∣f (x)− p(x)∣ =∣∣ f (N+1)(s)hN+1

(N + 1)!∣∣,

E(x) < ChN+1.

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 31: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Interpolation error

x0 x1 p1(1) e(1) er (1)0 2 8.66025 6.16025 2.46410

0.5 1.5 4.13924 1.63924 0.6556950.75 1.25 2.91612 0.416123 0.166449

0.875 1.125 2.60443 0.104427 0.0417709

Example: Linear interpolation of the function f (x) = 5x2sin(�6 x)at the point x = 1.

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 32: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Piecewise interpolation

∙ Example: Consider (x0 = a, x1, x2, x3 = b) and letfi = f (xi), i = 0,1,2,3.

∙ We can construct an cubic polynomial p(x) =3∑

k=0akxk ,

p(xi) = f (xi), i = 0, . . . ,3.

∙ Alternatively, piecewise linear interpolationpm(x) = cm

0 + cm1 x ,

where x ∈ [xm, xm+1], m = 0,1,2.

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 33: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

2− D interpolation

∙ Let the function f (x , y) be defined at nodes (xi , yj) of arectangular grid, fij ≡ f (xi , yj).

∙ Given the values fij , the problem of interpolation is to findan approximate value of f (x , y) corresponding to anyselected point (x , y) ∈ D.

∙ We can interpolate f (x , y) by applying consequentinterpolation to each coordinate x and y .

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 34: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

2− D interpolation

∙ Consider 1− D interpolation in the x-direction for any fixedj = 0,1,2, . . . ,N2:

f̃j(x) =N1∑i=0

fijN1∏p ∕=i

x − xp

xi − xp

∙ Given the values f̃j(x), consider 1− D interpolation in they -direction:

p(x , y) =N2∑j=0

f̃j(x)N2∏q ∕=j

y − yq

yj − yq

∙ The resulting interpolation formula is

f (x , y) ≈ p(x , y) =N1∑i=0

N2∑j=0

fijN1∏p ∕=i

N2∏q ∕=j

x − xp

xi − xp

y − yq

yj − yq

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 35: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Interpolation methods: checklist (incomplete!)

∙ Are you going to interpolate a function by polynomials?

∙ How much data are available to you? For a cloud of pointsit may be better to use LS approximation. For sparse datathe accuracy may not be as expected.

∙ Check what data are available to you. Can you use astandard interpolation algorithm?

∙ Decide whether you want to use interpolation by a singlepolynomial or piecewise interpolation.

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 36: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

References

∙ P.J.Davis. Interpolation and Approximation. Dover Pub.Inc.1975.

∙ W.E.Grove. Brief Numerical Methods. Englewood Cliffs,N.J. : Prentice-Hall, 1966.

∙ E.Isaacson and H. B. Keller. Analysis of NumericalMethods. New York ; London : Wiley, 1966.

∙ W.H.Press, S.A. Teukolsky, W.T. Vetterling, B.P.Flannery.Numerical Recipes: The Art of Scientific Computing (3rded.). New York: Cambridge University Press, 2007.

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 37: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Methods of numerical integration

in ecological problems

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 38: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Example of spatial data: flatworm (Arthurdendyus triangulatus) spatial density

distribution u(x , y) reconstructed from field data

The trap counts in the domain D are converted into thevalues ui ≡ u(xi , yi) of the pest insect population densityu(x , y) at locations ri = (xi , yi), i = 1, . . . ,N.

X

Y

0 0.2 0.4 0.6 0.8 10

0.2

0.4

0.6

0.8

113

12

11

10

9

8

7

6

5

4

3

2

1

u(x,y)

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 39: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Numerical integration in the pest control problem

∙ If the density u(x , y) is known at any point (x , y) of thedomain D, the total pest population size I is given by

I =∫∫D

u(x , y)dxdy .

∙ For given precise values ui ≡ u(xi , yi), i = 1, . . . ,N, thepest population size I is reduced to computation of aweighted sum of the values ui ,

I ≈ Ia(N) =N∑

i=1

!iui .

∙ The approximation error (integration error) depends on N,

e(N) =∣I − Ia(N)∣∣I∣

.

∙Ia(N)→ I, as N →∞.

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 40: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Numerical integration technique

∙ Generate a regular grid of N nodes in the unit square.

∙ Consider the values ui , i = 1,2, . . . ,N at grid nodes.

∙ Replace u(x , y) with polynomial pnK (x , y) of degree K in

the neighbourhood of node n.

∙ Integrate pnK (x , y) instead of f (x , y) (Newton-Cotes

formulas)

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 41: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

1− D numerical integration: Newton-Cotes formulas

∙ Let x1 = a, xi+1 = xi + h, h = (b − a)/N and fi ≡ f (xi)

∙ Consider a polynomial pk (x) of degree k , pk (xn) = f (xn)for n = i , i + 1, . . . , i + k .

xi+k∫xi

f (x)dx ≈ ai =

xi+k∫xi

pk (x)dx

∙ (a) p0(x) = const :ai = hfi ,

I ≈ Ia(N) =N∑

i=1

ai =N∑

i=1

hfi =N∑

i=1

!i fi

!i = h, i = 1, . . . ,N

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 42: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

1− D numerical integration: Newton-Cotes formulas

x

f(x)

xi+2

fi+2

xi

fi

xi+1

fi+1

b

x

f(x)

xi+2

fi+2

xi

fi

xi+1

fi+1

c

x

f(x)

xi+2xi

fi

xi+1

fi+1

a

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 43: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

1− D numerical integration: Newton-Cotes formulas

∙ (b) p1(x) = c0 + c1x :

ai =12

h(fi + fi+1),

∙ Trapezoidal rule of integration

I ≈ Ia(N) =N∑

i=1

ai =h2

[f1 + 2

N∑i=2

fi + fN+1

]

!1 = !N+1 = h/2 and !i = h, i = 2, . . . ,N

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 44: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

The trapezoidal rule of integration

x

f(x)

xi+2

fi+2

xi

fi

xi+1

fi+1

b

x

f(x)

xi+2

fi+2

xi

fi

xi+1

fi+1

c

x

f(x)

xi+2xi

fi

xi+1

fi+1

a

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 45: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

1− D numerical integration: Newton-Cotes formulas

∙ (c) p2(x) = c0 + c1x + c2x2:

Ii =

xi+2∫xi

f (x)dx ≈ ai =13

h(fi + 4fi+1 + fi+2)

∙ Simpson’s rule of integration

b∫a

f (x)dx ≈ Ia(N) =h3

⎡⎣f1 + 2N/2−1∑

i=1

f2i+1 + 4N/2∑i=1

f2i + fN+1

⎤⎦

!i =4h3, i = 2,4, . . . ,N − 1, !i =

2h3, i = 3,5, . . . ,N − 2,

!i =h3, i = 1, or i = N

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 46: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

The Simpson rule of integration

x

f(x)

xi+2

fi+2

xi

fi

xi+1

fi+1

b

x

f(x)

xi+2

fi+2

xi

fi

xi+1

fi+1

c

x

f(x)

xi+2xi

fi

xi+1

fi+1

a

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 47: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Approximation (integration) error

Pest abundance I ≈ Ia(N) =N∑

i=1

!iui .

Ia(N)→ I, as N →∞

e(N) =∣I − Ia(N)∣∣I∣

→ 0, as N →∞.

▶ Given weight coefficients !i , i = 1, . . . ,N, theapproximation error depends on the number N of pointswhere the data are available.

▶ For any fixed N the approximation error depends on aspatial pattern of the density function.

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 48: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Example: approximation error for a 1− d densityfunction

u(x)

x N=3

e(N)

N

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 49: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Convergence and tolerance

∙ convergence rate e = O(hp) (asymptotic convergenceestimate)∙ tolerance � : e ≤ �

100 101 102

10-10

10-9

10-8

10-7

10-6

10-5

10-4

10-3a

N*

e

e=τ

N100 101 102

10-9

10-7

10-5

10-3

10-1

trapezoidal rule

Simpson’s rule

b

N

e

e=τ

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 50: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

2− D integration in rectangular domains

∙ Let the function f (x , y) be defined at nodes (xi , yj) of arectangular grid, fij ≡ f (xi , yj).

I =

1∫0

1∫0

f (x , y)dxdy =∑i,j

Iij ,

where

Iij =

xi+1∫xi

yj+1∫yj

f (x , y)dxdy .

∙ The integration problem is reduced to the integralevaluation in each sub-domain cij = [xi , xi+1]× [yj , yj+1]

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 51: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

2− D integration in rectangular domains

∙ Consider a 1− D integral

Iij =

yj+1∫yj

F (y)dy ,

where

F (y) =

xi+1∫xi

f (x , y)dx .

∙ Employ 1− D Newton-Cotes formulas in order to evaluatethe function F (y)

∙ Example: Trapezoidal rule of integration

Iij ≈h2

4[f (xi , yj) + f (xi+1, yj) + f (xi , yj+1) + f (xi+1, yj+1)

]Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 52: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Numerical integration for pest insect monitoring

Accuracy requirements are not very demanding:

e(N) ≤ �,

where � ∼ 0.2− 0.5 is a specified tolerance.N is small in field measurements⇒ (often but not always)inaccurate evaluation Ia of the pest abundance I.

▶ For any fixed (small) N the approximation error depends ona spatial pattern of the density function.

What is the number N of traps to provide the accuracyrequired in ecological applications?

What accuracy can we expect when N is fixed?

Can we rely upon convergence estimates e = O(hp)?

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 53: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Approximation error for different spatial density patterns

(a) e(N) ∼ 10−2 (b) e(N) ∼ 1.0

XY

0 0.2 0.4 0.6 0.8 10

0.2

0.4

0.6

0.8

1 0.85

0.8

0.75

0.7

0.65

0.6

0.55

0.5

0.45

0.4

0.35

0.3

0.25

0.2

0.15

0.1

0.05

b u(x,y)

X

Y

0 0.2 0.4 0.6 0.8 10

0.2

0.4

0.6

0.8

1 0.85

0.8

0.75

0.7

0.65

0.6

0.55

0.5

0.45

0.4

0.35

0.3

0.25

0.2

0.15

0.1

0.05

a u(x,y)

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 54: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Current challenges: "the coarse grid problem"

∙ Financial and labor resources available for monitoring arealways limited.

∙ N is small in field measurements⇒ (in some cases)inaccurate evaluation Ia of the pest abundance I.

∙ Recognition of spatial patterns is extremely important!

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 55: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

References

∙ R.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole,Belmont,CA, 2005.

∙ P.J.Davis P.Rabinowitz. Methods of Numerical Integration.Academic Press, New York, 1975.

∙ H.Engels. Numerical Quadrature and Cubature.Academic Press, New York, 1980.

∙ N.B.Petrovskaya, N.L.Embleton. Computational Methodsfor Accurate Evaluation of Pest Insect Population Size. inW.A.C. Godoy and C.P. Ferreira (eds.), EcologicalModelling Applied to Entomology, Springer, 2014.

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014

Page 56: COMPUTATIONAL APPROACHES *5mm IN ...coral.ufsm.br/biomatematica/WWMBPetrovskaya1.pdfR.L.Burden, J.D.Faires. Numerical Analysis. Brooks/Cole, CA, 2005 basic mathematics behind numerical

Basic concepts

∙ Approximation f (x) ≈ p(x)

∙ Accuracy E(x)→ 0

∙ Convergence E(x) = O(hm)

∙ Efficiency/convenience

Computational approaches in mathematical ecology WWMB’14: Federal University of Santa Maria 28-30 July, 2014