Numerical*Methods*and*Modeling*in**...

Preview:

Citation preview

Numerical  Methods  and  Modeling  in    Biomedical  Engineering  

Instructor    :  Dr  Vivi  Andasari  Office      :  44  Cummington  St,  Room  329  Office  hours  :  By  appointment  (andasari@bu.edu)  Lecture  materials  are  available  on  Blackboard  and    lecture’s  website:  h5p://9ny.cc/z26j2x      

•  Knowledge  on  mulNvariable  calculus,  linear  algebra,  some  basics  on  differenNal  equaNons  including  ordinary  differenNal  equaNons  (ODEs)  and  parNal  differenNal  equaNons  (PDEs).    

•  Know  how  to  use  MATLAB®,  or  other  numerical  soVware  you  prefer.  

•  Do  we  need  computer  lab  for  those  who  want  to  deepen  their  MATLAB’s  skill?  

Requirements  

•  Homework        30%  •  Midterm  project    30%  •  Final  project        35%  •  Presence  (quizzes)    5%  

 q  Individual  and  group  homework  q Midterm  and  final  exams:  group  projects  

 ü  Be  on  Nme  to  class  ü  No  cell  phone  disrupNons  or  electronic  device  distracNons  ü  Turn  in  homework  on  Nme    

Grading  

SoEware  (1) MATLAB  hdp://www.bu.edu/tech/services/support/desktop/distribuNon/mathsci/matlab/    Or,  some  alternaNve    (2)  Octave  à  hdps://www.gnu.org/soVware/octave/    (3)  SciLab  à  hdp://www.scilab.org/    (4)  Python      

Octave  

The  Octave  language  is  quite  similar  to  Matlab  so  that  most  programs  are  easily  portable.  

SciLab  

What  will  be  covered  

What  are  numerical  methods?  Techniques  by  which  mathemaNcal  problems  (from  real  life  problems  e.g.  in  biology,  physics,  economy)  are  formulated  so  that  they  can  be  solved  with  

arithmeNc  operaNons.  

They  provide  approximaNons  to    the  problems  in  quesNon.  

Why  study  numerical  methods?  

Kuusela  &  Alt  (2009)  J.  Math.  Biol.  

(RC, snout-to-tail) direction and 2.20 ! 10"4 cm!hr"1 in thedorsal-to-ventral (DV, top-to-bottom) direction.

To incorporate cell movement into the model, we supposethat the combined density of the cell types, as well as thedensity of the extracellular matrix, remain constant. This isreasonable, because cells are largely composed of water, andunder this assumption, cells can only move by displacing aneighboring cell. We simplify the model by considering justtwo cell types, iridophores and melanophores. The balanceequation for the density of the ith cell type can be written

!ni

!t " #!niv # $ #!ji " ni$r1 " r2% [2]

where v & (r1xi ' r2yj) is the uniform velocity field generatedby growth, r1 and r2 are the growth rates in each direction, andji is the flux relative to the mass-average velocity. In earlydevelopment, the path taken by pigment cells is likely to becontrolled either by a chemotactic mechanism (13–17) or by

guidance cues in the extracellular matrix (18). We postulatethat the iridophore cells move chemotactically in response toone of the morphogens, and that the flux of these cells relativeto the melanophore cells comprises both a diffusional com-ponent caused by random motion and a directed componentthat results from the tactic response. Of course, the connectionbetween morphogen and movement may not be so direct: themorphogens may modify the matrix, which may in turn provideguidance to the cells. It is not crucial whether it is themelanophores or the iridophores that are chemotactic, andwhether they are attracted or repelled; all combinations willgive rise to similar phenomena. In addition, it is possible thatundifferentiated pigment cells first respond to the morphogendistribution by differentiation, but chemotaxis is still necessaryto maintain the integrity and forms of the stripes.

Under the assumption of constant growth and both diffusiveand tactic contributions to the flux, the governing equation forthe density of the iridophore cells can be written,

!n!t " #!nv # $Dn#2n $ #!$%$u%#u%% " n$r1 " r2% [3]

The term %(u) & %0/(k ' u)2 represents the local response ofcells to the concentration of the chemotactic substance (19). Inthe simulations, we choose %0 ( 0, which means that u is arepellent.§ A schematic showing the key assumptions made inderiving the model is shown in Fig. 2. For computationalconvenience, both the above equation and the equations formorphogen evolution with growth incorporated can be trans-formed from a growing domain into a fixed domain, at theexpense of introducing additional terms. This results in thefollowing system of equations,

!n!t #

1L1

2!

!x!Dn!n!x $

%0

$k " u%2 n!u!x" "

1L2

2!

!y!Dn!n!y

$%0

$k " u%2 n!u!y"

!u!t # Du! 1

L12

!2u!x2 "

1L2

2!2u!y2" " f$u, v% $ $r1 " r2%u,

!v!t # Dv! 1

L12

!2v!x2 "

1L2

2!2v!y2" " g$u, v% $ $r1 " r2%v, [4]

where L1(t) & L1(0) exp r1t and L2(t) & L2(0) exp r2t representthe changing domain dimensions as a function of time. Pigmentcells in larval Pomacanthus arcuatus initially form a uniformgray pigmentation when the fish is between 5 and 7 mm inlength, and we take a uniform initial distribution of both typesof pigment cells. The juvenile pigment pattern consisting offive vertical white bars subsequently develops from this uni-form distribution (21).

Numerical Simulations Producing Striped Patterns. Wefirst solve the equations on a one-dimensional growing domainwith the piecewise linear kinetics used by Kondo and Asai. Themorphogen evolution is independent of the cell movement,and the number of maxima of u and v double at regularintervals (Fig. 3 a–c). Hereafter we refer to this behavior asmode doubling. The doubling occurs via a mechanism of peaksplitting: peaks bifurcate to troughs, whereas troughs maintaintheir spatial location. As a pattern in the morphogen distri-bution develops, iridophore cells accumulate at the minima(Fig. 3 d–f ), which results in the formation of white pigment

§Pattern formation has been studied in the larval salamander (20),where the formation of a horizontal line free from melanophoresapparently arises from repulsion of melanophores from the forminglateral line.

FIG. 1. Juvenile pattern sequence on Pomacanthus semicirculatus,showing the transition from 3 to 6 to 12 vertical stripes. (a) 2 months;(b) 6 months; and (c) 12 months. [Reprinted with permission fromNature (376, 765–768; copyright 1995, Macmillan Magazines Ltd.)].Computer rendition of juvenile P. imperator shown at Bottom forcomparison.

5550 Developmental Biology: Painter et al. Proc. Natl. Acad. Sci. USA 96 (1999)

Final  project  group  2  Fall  2014  (Jawde,  Huang,  Weber,  Yao)  

Shirinifard  et  al  (2009)  PLoS  ONE  

Why  study  numerical  methods?  

Most  (  >  99.9%)  of  real  world  problems  in  science  and  engineering  are  too  complex  and  sophisNcated  to  be  

solved  analyNcally  (exactly),  hence  they  can  only  be  solved  numerically  (approximately).  

[ComputaNonal  Modeling  of  Endovascular  Deep  Brain  SimulaNon]  hdps://www.msi.umn.edu/content/computaNonal-­‐modeling-­‐endovascular-­‐deep-­‐brain-­‐simulaNon  

Errors  and  Numerical  Series  

•  Computers use a base-2 representation à 1 0 1 0 1 1 0 1

•  Computers cannot precisely represent certain exact

base-10 numbers. Non-integer numbers, such as π = 3.1415926535…, e = 2.718281…, or are cumbersome and can’t be expressed by a fixed number of significant figures.

•  The discrepancy creates an error usually referred to

as round-off error or rounding error

 Round-off error is the difference between an approximation of a number used in computation and its exact value1.

Suppose ã is an approximation to the (nonzero) exact value a, then:

Absolute error

Relative error

1  =  hdp://mathworld.wolfram.com/RoundoffError.html  

 Example: The value of π = 3.141592653589… is to be stored on a base-10 system that allows 7 significant figures. Chopping approximation à π = 3.141592 Absolute error = |3.1415926535 – 3.141592|

= 0.000000653… Rounding approximation à π = 3.141593 Absolute error = |3.1415926535 – 3.141593|

= 0.000000346…

Fractional numbers in computers are usually represented using floating-point form:

manNssa  base  of  the  number  system  being  used  

exponent  

Example: in a floating-point base-10 system that allows only 4 decimal places to be stored, the quantity 1/34 = 0.029411765 would be stored as 0.2941 x 10-1

Allows both fractions and very large numbers to be expressed on the computer

Takes up more space Takes longer time to process Source of round-off error

In Matlab’s Command Window type in:

>> a=0.0000123454981202! By default, Matlab displays numeric output as 5-digit scaled, fixed point values. Now change the display format to 15-digit scaled fixed point by typing:

>> format long! and type the value of a again. *These format settings only affect how numbers are displayed, not how Matlab computes or saves them.

•  For numerical methods, the true value of a function is known from its analytical solution. •  However, in real-world applications, it is impossible

to know the true value of a function a priori. •  Hence, the percentage relative error:

(1.1)

Let the power series for f(x) be

where are constants.

At

Substituting for in f(x) gives:

(1.2)

(3) The resultant Maclaurin’s series must be convergent

0  

f(0)  f(h)  

x  

y=f(x)  

y  

h  

P  

Q  

Using Maclaurin’s series, at some point Q in Figure above:

Using Maclaurin series, determine the first four terms of the power series for cos(x).

Solution: The constants needed for Maclaurin series are

Hence, the power series

If the y-axis and origin are moved a units to the left, the equation of the same curve relative to the new axis becomes y = f(a+x) and the function value at P is f(a).

0  

f(0)  

f(a+h)  

x  

y=f(a+x)  y  

a  

P  

Q  

At point Q:

f(a)  h  

(1.3) f(a+ h) = f(a) + hf 0(a) +h2

2!f 00(a) + · · ·

a+h  

Zero  order  

Taylor series provides a means to predict a function value at one point (xi+1) in terms of the function value and its derivatives at another point (xi):

where:

n = order of derivative

(1.4)

Since h = xi+1 – xi, sometimes Taylor series are written in ways that look a little different from eqn. (1.3) but in reality are completely equivalent, such as If we want to to predict a function backward, at point (xi-1) in terms of the function and its derivatives at point (xi) where h = xi – xi-1, then

(1.5)

(1.6)

 Use zero-through third-order Taylor series expansion to predict for

using a base point at . Compute the true percent relative error for each approximation.

 Use zero-through third-order Taylor series expansion to predict for

using a base point at . Compute the true percent relative error for each approximation. Solution The true value of the function at is , which is the value that we are going to predict/approximate.

For , the Taylor series approximation is

and relative error

For , the first derivative is , and the first order Taylor series approximation

For , the second derivative is , and the second order Taylor series approximation

and relative error

and relative error

For , the third derivative is , and the third order Taylor series approximation

hence, the remainder term is

The Taylor series expansion to the third order derivative yields an exact estimate at ,

Taylor series can be used to estimate truncation errors. The notion of truncation errors usually refers to errors introduced when a more complicated mathematical expression is “replaced” with a more elementary formula. From the Taylor series expansion

we truncate the series after the first derivative term

Using

for , we get

or

Rearranging the equation gives us

truncaNon  error  first-­‐order  approximaNon  

(1.7)

The problem with evaluating is that f(x) is unknown because x is unknown. We can overcome this if: •  is close to x, and •  is continuous and differentiable

We use Taylor series to compute f(x) near

Suppose we have a function f(x) which has one dependent variable x. Assume that is an approximation of x. To assess the effect of the discrepancy between x and on the value of the function, we use

where

or

Dropping the second- and higher-order terms and rearranging gives us

represents an estimate of the error of the function f(x) represents an estimate of the error of x

This enables us to approximate the error in f(x) given the derivative of a function and an estimate of the error in x.

(1.8)

Taylor series with two variables x and y can be described from the figure on the left. We want to determine a function at point B from a function and its derivatives at point A. The coordinates at both points are different, where:

at A à function f = f(a, b) at B à function f = f(a+∆x, b+∆y)

also: at C à function f = f(a, b+∆y) at D à function f = f(a+∆x, b)

C  

A  

B  

D  x

y

∆x  ∆y  

a

b

First we relate f(a+∆x, b+∆y) at point B to the functions and its derivatives at point C. This involves changing only the x coordinate while keeping y constant, hence it is a typical one-dimensional approximation: Now we need approximation for the first term on the right hand side of eqn. (1.9), which is approximation at point C derived from function and its derivative at point A.

(1.9)

That is, All derivatives on the right hand side of eqn. (1.10) are evaluated at (x = a, y = b). Now we turn our attention back to eqn. (1.9) and look at the second term on the right hand side where it involves derivative ∂f/∂x evaluated at (a, b+∆y) which needs to be expressed in terms of what is happening at (x = a, y = b). We do this by defining

(1.10)

(1.11)

Then we write the Taylor series for g(a, b+∆y) in complete analogy with that for f in eqn. (1.10): We need an approximation for the third term of eqn. (1.10), that is

(1.12)

(1.13)

Now, substituting eqns. (1.10), (1.12), and (1.13) into eqn. (1.9) and rearranging yields which is the Taylor series for 2 variables (2 dimension) up to second order terms.

(1.14)

If all second-order and higher terms are dropped and rearrange, we get

where is the estimate of the error in x

is the estimate of the error in y

•  Numerical  Methods  for  Engineers,  S.C.  Chapra  and  R.P.  Canale.  

•  Higher  Engineering  MathemaNcs,  John  Bird.  •  All  You  Wanted  To  Know  About  MathemaNcs  but  Were  Afraid  To  Ask,  Louis  Lyons.  

References  

Recommended