Numerical Modeling in Biomedical Systems

Similar documents
Topic 4a Introduction to Root Finding & Bracketing Methods

Non-Ideal Gas Behavior P.V.T Relationships for Liquid and Solid:

x 1 b 1 Consider the midpoint x 0 = 1 2

Section 8.2 Polar Coordinates

Generalized Vapor Pressure Prediction Consistent with Cubic Equations of State

From E.G. Haug Escape Velocity To the Golden Ratio at the Black Hole. Branko Zivlak, Novi Sad, May 2018

Extra Examples for Chapter 1

SAMPLE LABORATORY SESSION FOR JAVA MODULE B. Calculations for Sample Cross-Section 2

3.6 Applied Optimization

Suppose you have a bank account that earns interest at rate r, and you have made an initial deposit of X 0

AVS fiziks. Institute for NET/JRF, GATE, IIT-JAM, JEST, TIFR and GRE in PHYSICAL SCIENCES

Numerical Integration

Non-Linear Dynamics Homework Solutions Week 2

Mass Transfer (Stoffaustausch)

7.2.1 Basic relations for Torsion of Circular Members

In many engineering and other applications, the. variable) will often depend on several other quantities (independent variables).

, the tangent line is an approximation of the curve (and easier to deal with than the curve).

OSCILLATIONS AND GRAVITATION

To Feel a Force Chapter 7 Static equilibrium - torque and friction

Experiment 1 Electric field and electric potential

When two numbers are written as the product of their prime factors, they are in factored form.

Chapter Eight Notes N P U1C8S4-6

Physics 2B Chapter 22 Notes - Magnetic Field Spring 2018

working pages for Paul Richards class notes; do not copy or circulate without permission from PGR 2004/11/3 10:50

Circular Motion & Torque Test Review. The period is the amount of time it takes for an object to travel around a circular path once.

FE FORMULATIONS FOR PLASTICITY

Problem 1. Part b. Part a. Wayne Witzke ProblemSet #1 PHY 361. Calculate x, the expected value of x, defined by

The Substring Search Problem

you of a spring. The potential energy for a spring is given by the parabola U( x)

Hopefully Helpful Hints for Gauss s Law

PHYS 110B - HW #7 Fall 2005, Solutions by David Pace Equations referenced as Eq. # are from Griffiths Problem statements are paraphrased

2 x 8 2 x 2 SKILLS Determine whether the given value is a solution of the. equation. (a) x 2 (b) x 4. (a) x 2 (b) x 4 (a) x 4 (b) x 8

Method for Approximating Irrational Numbers

Physics 111 Lecture 5 Circular Motion

Solution to HW 3, Ma 1a Fall 2016

Physics 161 Fall 2011 Extra Credit 2 Investigating Black Holes - Solutions The Following is Worth 50 Points!!!

Physics 211: Newton s Second Law

ASTR415: Problem Set #6

dp p v= = ON SHOCK WAVES AT LARGE DISTANCES FROM THE PLACE OF THEIR ORIGIN By Lev D. Landau J. Phys. U.S.S.R. 9, 496 (1945).

Solving Problems of Advance of Mercury s Perihelion and Deflection of. Photon Around the Sun with New Newton s Formula of Gravity

Rigid Body Dynamics 2. CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2018

1D2G - Numerical solution of the neutron diffusion equation

PHYS Summer Professor Caillault Homework Solutions. Chapter 5

Markscheme May 2017 Calculus Higher level Paper 3

Answers to Coursebook questions Chapter 2.11

Physics 11 Chapter 20: Electric Fields and Forces

Flux. Area Vector. Flux of Electric Field. Gauss s Law

Lab #4: Newton s Second Law

3.1 Random variables

10.2 Parametric Calculus

Numerical solution of diffusion mass transfer model in adsorption systems. Prof. Nina Paula Gonçalves Salau, D.Sc.

PDF Created with deskpdf PDF Writer - Trial ::

Solutions to Problem Set 8

radians). Figure 2.1 Figure 2.2 (a) quadrant I angle (b) quadrant II angle is in standard position Terminal side Terminal side Terminal side

Uniform Circular Motion

The geometric construction of Ewald sphere and Bragg condition:

1. Show that the volume of the solid shown can be represented by the polynomial 6x x.

( ) [ ] [ ] [ ] δf φ = F φ+δφ F. xdx.

Magnetic Field. Conference 6. Physics 102 General Physics II

Radian Measure CHAPTER 5 MODELLING PERIODIC FUNCTIONS

AP Physics - Coulomb's Law

Universal Gravitation

17.1 Electric Potential Energy. Equipotential Lines. PE = energy associated with an arrangement of objects that exert forces on each other

Molecular Energy Changes During a Reaction

Homework # 3 Solution Key

INTRODUCTION. 2. Vectors in Physics 1

PHYS 110B - HW #7 Spring 2004, Solutions by David Pace Any referenced equations are from Griffiths Problem statements are paraphrased

Handout: IS/LM Model

Potential Energy and Conservation of Energy

Reading Assignment. Problem Description for Homework #9. Read Chapters 29 and 30.

Trigonometric Functions of Any Angle 9.3 (, 3. Essential Question How can you use the unit circle to define the trigonometric functions of any angle?

COMPARING MORE THAN TWO POPULATION MEANS: AN ANALYSIS OF VARIANCE

Motithang Higher Secondary School Thimphu Thromde Mid Term Examination 2016 Subject: Mathematics Full Marks: 100

Chapter 13 Gravitation

Chapter 1: Introduction to Polar Coordinates

Recitation PHYS 131. must be one-half of T 2

SAMPLE QUIZ 3 - PHYSICS For a right triangle: sin θ = a c, cos θ = b c, tan θ = a b,

Physics 2A Chapter 10 - Moment of Inertia Fall 2018

Geometry of the homogeneous and isotropic spaces

COORDINATE TRANSFORMATIONS - THE JACOBIAN DETERMINANT

arxiv: v1 [physics.pop-ph] 3 Jun 2013

A Tutorial on Multiple Integrals (for Natural Sciences / Computer Sciences Tripos Part IA Maths)

Right-handed screw dislocation in an isotropic solid

Boundary Layers and Singular Perturbation Lectures 16 and 17 Boundary Layers and Singular Perturbation. x% 0 Ω0æ + Kx% 1 Ω0æ + ` : 0. (9.

Math 1105: Calculus I (Math/Sci majors) MWF 11am / 12pm, Campion 235 Written homework 3

ac p Answers to questions for The New Introduction to Geographical Economics, 2 nd edition Chapter 3 The core model of geographical economics

Physics 11 Chapter 4: Forces and Newton s Laws of Motion. Problem Solving

matschek (ccm2548) Ch17-h3 chiu (57890) 1

Objects usually are charged up through the transfer of electrons from one object to the other.

APPENDIX D COMPRESSIBILITY FACTOR EQUATIONS D.1 THE REDLICH KWONG EQUATION

Appendix B The Relativistic Transformation of Forces

Lecture 2 - Thermodynamics Overview

Eddy Currents and Magnetic Calibrations in LDX using a Copper Plasma. D.P. Boyle, PPPL M.E. Mauel, D.T. Garnier, Columbia J.

Auchmuty High School Mathematics Department Advanced Higher Notes Teacher Version

Nuclear Medicine Physics 02 Oct. 2007

Electrostatics (Electric Charges and Field) #2 2010

7.2. Coulomb s Law. The Electric Force

Between any two masses, there exists a mutual attractive force.

Chemical Reaction Engineering

RECTIFYING THE CIRCUMFERENCE WITH GEOGEBRA

Transcription:

Numeial Modeling in Biomedial Systems BME 15:35 Letue 7 9/6/17

Nonlinea Systems Dunn Chapte 5 Nonlinea equations Root finding Baketing methods Open methods Gaphial Bisetion False Position Newton s method Fied-point iteation Newton- Raphson Bent s method

How do we solve this nonlinea equation to find? 3 7 + 6 = Plot f () = 3 7 +6 vesus and see whee it osses zeo? 1 f() -1 - f() = 3 7 +6 Roots nea = -3,, 1-3 -4-3 - -1 1 3 - Gaphial methods ae not vey auate but they an give us a lue about the egion whee the oot(s) lie - Guess a value fo, evaluate whethe f () =? - This will take a long time - Bette to develop systemati methods to seah fo f () = until ou equied level of auay is eahed

Baketing Methods We want to find the oots of f(), i.e. the values of whee f() = Whee to stat looking? Baketing methods use the fat that the value of f() hanges sign at eah oot f() 1-1 - + + - - + - f() = 3 7 + 6-3 -4-3 - -1 1 3 Stategy: Find two values of, ( 1, ) giving positive and negative values fo f() The oot must lie somewhee between these values of Naow the distane between ( 1, ) to lose in on the tue oot

Eample - Falling objet fom Letue m F up = dag foe mass, m F down = gavitational foe Using Newton s nd law leads to an analytial epession fo veloity v as a funtion of time t and system paametes mass (m) and dag oeffiient (): v gm / m t 1 e Given g,m,,t we an alulate v t But what if we ae given g,m,v,t and we want to alulate? v(t) 4 1 3 If an objet has mass m = 68.1 kg, what dag oeffiient () is neessay in ode to eah a veloity of v = 4 m/s at time t = 1 seonds? 1 t Poblem: We an t eaange the epession in the fom = f (g,m,v,t)

Reap gm / m How to solve a nonlinea equation? vt 1 e Eg., find when g = 9.8 m/s, m = 68.1 kg, v = 4 m/s, t = 1 s t Solve this nonlinea equation fo : 4 9.8 68.1 1 e / 68.1 1 What ae the value(s) of whih satisfy: 9.8 68.1 /68.1 1 1 e 4 Whee does the funtion f() equal zeo? f 68.1 / 68.1 1 e 4 9.8 1 These ae just diffeent ways of asking the same question

We need to find the oot(s) of f 68.1 /68.1 1 e 4 9.8 1 I.e. the value(s) of whih lead to f () = We an stat to make some guesses fo, and see what we get fo f (): Guess fo f() 4 34.115 8 17.653 1 6.67 16 -.69-8.41 f() 6 5 4 3 1-1 5 1 15 Dag oeffiient, / m 14.75 looks lose to zeo. v t gm 1 e t gives v = 4.59 m/s when = 14.75 Gaphial methods ae not vey auate, but they an povide us with useful initial guesses to use with othe methods

Bisetion Method In geneal: If f () is eal and ontinuous in the ange between l and u, and f( l ) f( u ) <, then thee is at least one oot in the ange l to u f() 6 5 4 3 1-1 5 1 15 Dag oeffiient, Step 1: Choose lowe ( l ) and uppe ( u ) guesses fo the loation of the oot. Step : If f( l ) f( u ) <, then the oot is estimated to lie at = ( l + u ) / Step 3: If f( l ) f( ) <, then the tue oot must lie between l and If f( l ) f( ) >, then the tue oot must lie between and u Retun to step with the new guesses fo the inteval, epeat until the inteval width is suffiiently small (i.e. the estimate fo the oot is within an aeptable toleane)

Repeat the pevious (falling mass) eample using the bisetion method: Eample - Bisetion Method 6 5 4 f 68.1 /68.1 1 e 4 9.8 1 Step 1: Make initial guesses fo l and u l = 1, u = 16 Chek: f (1) f (16) = 6.67 -.69 (i.e. < ) a oot eists in this ange Step : Estimate the oot as lying at the midpoint of this ange: = ( l + u ) / = 14 f() 3 1-1 5 1 15 Dag oeffiient, Step 3: Calulate f( l ) f( ) = f (1) f (14) = 9.517. I.e. >, the tue oot does not lie between l and the tue oot must lie between and u (between 14 and 16) Retun to step with the new guesses fo the inteval: new estimate fo = (14+16)/ = 15 test whethe the oot lies between 14-15 o 15-16

6 The tue value fo the oot is = 14.78 We an evaluate the eo in the value geneated by the bisetion method at eah iteation: As peviously when evaluating the eo in iteative methods, we an use the uent and pevious values to geneate an appoimate elative eo, a : a new new old 1% f() 5 4 3 1-1 5 1 15 Dag oeffiient, Iteation l u a [%] t [%] 1 1 16 14-5.79 14 16 15 6.667 1.487 3 4 5 6 14 14.5 14.75 14.75 15 15 15 14.875 14.5 14.75 14.875 14.815 3.448 1.695.84.4 1.896.4.641.19 - Afte 6 iteations, the appoimate elative eo a <.5% (and t is even lowe)

Compae the appoimate elative eo to the tue elative eo: Iteation a [%] t [%] 1-5.79 6.667 1.487 3 3.448 1.896 4 1.695.4 5.84.641 6.4.19 With the bisetion method, the tue elative eo is always less than the appoimate elative eo: (This is a good thing fo engineeing design / poblem solving) If we teminate the alulation when a < s, we an be onfident that the tue value is within ou stopping iteion Relative Eo [%] 8 7 6 5 4 3 1 Appoimate Eo Tue Eo 4 6 8 Iteation #

With the bisetion method, the tue elative eo is always less than the appoimate elative eo. Why is this the ase? Choose lowe and uppe guesses fo the oot: Tue oot: l u The bisetion method gives a new estimate at l Bisetion method: Tue eo, t u This tue eo must always be less than /: Ou estimated (appoimate) eo a is always equal to /: new old u l So ou elative appoimate eo will always oveestimate the tue eo: a new new old 1%

Funtions in Matlab Matlab has many built-in funtions eg. sin( ), ep( ), mean( ), binde( ), plot( ).., We an also define ou own funtions whih an be alled (by name) fom the ommand line, o fom within othe sipts / m-files

Anonymous Funtions in Matlab Suppose we want to find the minimum of the following funtion a when a = 1, b = -, = 1 f b f() 5 4 3 f()=a +b+, a=1,b=-,=1 lea all; lose all; a = 1; b = -; = 1; f = @()(a*.^ + b* + ); Ceate an anonymous funtion (@): 1-6 -4-4 6 = [-*pi:.1:*pi]; plot(,f()); % Plots funtion f() ove [-pi < < pi] title('f()=a^+b+, a=1,b=-,=1'); label(''); ylabel('f()'); hold on; % Find and plot the minimum minimum = fminbnd(f,-,); % We an pass ou funtion dietly to the minimization outine plot(minimum,f(minimum),'o'); % We an evaluate ou funtion at the value minimum Anonymous funtions an have moe than one vaiable eg: f = @(,y)(a*.^+b*y.^)

Eample: A evesible hemial eation involving eatants A and B foming podut C an be witten as: A + B C (Eg. H + CO CH 3 OH) and haateized by the equilibium elationship:, whee C i epesents the onentation of onstituent i. C K CaCb If the vaiable epesents the numbe of moles of podut C geneated by this eation, we an wite the onentation of podut C as (C, + ), whee C, is the initial onentation of C,. We an efomulate the equilibium elationship as K C, C C a, b,

K C, C C a, b, Question: If the equilibium onstant fo this eation is K =.16, and the initial mola onentations of onstituents a, b, and ae C a, = 4, C b, = 8, C, = 4, espetively, detemine the numbe of moles of podut C (epesented by vaiable ) geneated unde these onditions. We would like to wite = and plug in ou values fo K, C a,, C b,, C,, But we an t. Equivalently, ou poblem is to find the values of whih satisfy: f C, C C a, b, I.e. find the oot(s) of f() = K 4 4 8.16

Step 1: Plot the funtion and estimate whee the oot lies K =.16; Ca = 4; Cb = 8; C = 4; = linspae(,,5); % This is the funtion we ae inteested in (afte eaanging): f = @() (C+)./(((Ca-*).^).*(Cb-)) - K; figue; plot(,f(),'b-'); label('amount of C podued, [Mol]'); ylabel('f()'); ylim([-.5.5]); It looks like the oot is aound 16

Step : Implement the baketing method to get an auate estimate fo the oot Xl = 1; Xu = ; i = 1; i_ma = 1; Es = 1; while (1) X = (Xl + Xu)/; % Initial lowe and uppe guesses fo the oot % Iteation ounte stats at one % Ma # iteations allowed % Stopping eo (when % elative appo eo < Es) % New oot estimate fom Baketing Method if i > 1 % Ensue that i > 1 (an t alulate Ea on 1st loop) Ea = abs((x - X_old)/X)*1; % Calulate appo. elative eo (%) Ea_stoe(i) = Ea; % Stoe the appo. elative eo end test = f(xl)*f(x); if test < Xu = X; else Xl = X; end X_old = X; oot_stoe(i) = X; if i > 1 if Ea < Es i > i_ma beak end end i = i + 1; end % Test whethe f() hanges sign between Xl and X % If test <, oot must be between Xl and X % The alulated oot beomes ou new uppe guess (Xu) % If test is not <, oot must be between X and Xu % The alulated oot beomes ou new lowe guess (Xl) % Assign the latest oot to X_old fo use in the net loop % Stoe the latest oot fo plotting late % If we ae on the,3,4 iteation, hek the appo. eo % If eithe ondition is tue, eit the loop % Inement the iteation ounte fo the net loop

Step 3: Plot out the esults disp('calulated oot'); X disp('# of Iteations'); i disp('appoimate (Relative) Eo'); Ea figue; subplot(1,3,1); plot([1:i],oot_stoe,'-b'); label('iteation #'); ylabel('estimated Root, X'); ais squae; title('bisetion Algoithm fo oot of f()'); lim([1 i]); subplot(1,3,); plot([:i],ea_stoe(:end),'b-'); label('iteation #'); ylabel('\epsilon_a [%]'); ais squae; title('appoimate Eo, \epsilon_a [%]'); lim([1 i]); legend(['\epsilon_s = ',numst(es),'%']); subplot(1,3,3); plot([:i],ea_stoe(:end),'b-'); label('iteation #'); ylabel('\epsilon_a [%]'); ais squae; title('appoimate Eo, \epsilon_a [%]'); ylim([ 5]); lim([3.5 7]); legend(['\epsilon_s = ',numst(es),'%']);

Nonlinea Systems Dunn Chapte 5 Net time: False-position, Newton s method, Fied point iteation Nonlinea equations Root finding Baketing methods Open methods Gaphial Bisetion False Position Newton s method Fied-point iteation Newton- Raphson Bent s method

Open Methods fo Root Finding: Newton-Raphson The most widely used method fo oot finding 1) Stat with one initial guess fo the oot ( i ) f () Slope = f () f() ) Daw a line tangent to the point at [ i, f( i )] f ( i ) y = f ( i ) 3) Ou new estimate fo the oot oesponds to the -value whee the tangent fom [ i, f( i )] osses the -ais i+1 i = ( i i+1 ) The slope of the tangent line f ( i ) equals f i y i f i i1 Reaanging this in tems of the new oot estimate ( i+1 ): i1 i f i f i

Eample: Use the Newton-Raphson method to find the oot of f() = e - Given a funtion f(), its deivative f (), and an initial guess fo the oot ( i, i = ), the Newton-Raphson equation gives us a new oot estimate ( i+1 ): i1 i f f i i Funtion: f () = e - Deivative: f () = e - 1 Initial guess: = Use these epessions in the N-R equation: i1 i f f i i i1 i i e e i i 1

Oiginal poblem: Find the oot of f() = e -.5 f() = e - -.3 f() = e - - 1.5 (Tue oot =.567143).5. 1.15 y.5 y.1.5 -.5-1 -.5-1.5 -.5.5 1 1.5 -.1.4.45.5.55.6 Newton-Raphson Iteation i t [%] 1 1.5 11.8.566311.147 3.567143.1-5 4.567143 < 1-8

Tanspot Eample: Kogh Tissue Cylinde Model fo studying tanspot of metabolites fom apillaies to suounding tissue Tissue z Capillay The itial adius it is the distane at whih the metabolite onentation is edued to zeo: C m C it vaies with distane along the apillay aoding to: it R ln R R 1 R 4D C T t m D 4 V T DT R 1z R 1 K whee R it t m.

Question (i) : What is the itial tissue adius ( it ) whee gluose is no longe supplied to ells, at a distane z =.5 m unde the onditions listed in the table? 1 1 4 4 1 ln R K D z R V D t R C D R R R T T m T. m it t R whee We annot eaange this equation in the fom it = We need to find the oot of f ( it ) =. (The value of it whih satisfies f ( it ) = ). 1 ln R Dz B A R R 4 m T t R C D A 1 K D B T 4 T V D D Let s simplify this nonlinea epession: whee (A, B, and D ae just onstants whih an be found fom values given in the table) and z is given in the question.

Let s make this epession even simple: Let = R R ln R A B DzR 1 A B Dz ln 1 If we solve this nonlinea equation fo (find the oots of f ( ) ln( ) A E( 1) ) then we an easily onvet the answe fom R it : E B Dz Wite Matlab ode to implement the Newton-Raphson method to solve this poblem: Fist steps: 1) Define the elevant onstants ) Define the funtion we want to solve (find the oot(s) of) 3) Plot out the funtion to obtain a ough idea of whee the oot(s) lie

Net steps: 4) Define additional onstants (initial guess fo the oot ( 1 ), stopping eo ( s ), ) 5) Set up a loop to keep geneating and stoing new estimates fo the oot, using the Newton-Raphson method i1 6) Estimate and stoe the eo ( a ) at eah iteation of the loop (if i >1). Eit the loop if this eo is small enough ( a < s ) 7) Plot out the oot estimates and eo estimates as a funtion of iteation numbe i f f i i

Question (pat ii): You just alulated it fo a single aial loation of z =.5 m. Tissue z How does it vay as z anges fom 1 m to.15 m? Capillay Modify you ode fom pat (i) to alulate it at lots of z values between 1 m and.15 m Stoe the values alulated fo it at eah z value. Plot it vesus distane z.

Poblems with the Newton-Raphson method: (1) Slow Convegene Eample: f () = 1 1 Find the oot fom an initial guess of =.5 1 116 -.99 1.8 117 8 6 -.99 -.994 -.996 1 1.6 1.4 y 4 y -.998-1 y 1. 1 1 3 4 5-1. -1.4..3.4.5.6.7.8.8 1.6 49 5 51 5 53 The new guess is the value whee the tangent fom f( ) osses the -ais Iteation i.5 1 51.65 46.485 3 41.8365 The algoithm is slowly onveging on the tue oot ( = 1) Due to (1) the natue of the funtion f () () ou initial guess fo the oot,

Poblems with the Newton-Raphson method: () No Convegene f () f () 1 1 Point of infletion nea the oot Tapped at loal ma / min f () f () 1 1 Slope of f() nea oot Slope of f() = at estimated oot

Poblems with the Newton-Raphson method: No Convegene Thee is no geneal onvegene ule fo the Newton-Raphson method Convegene depends on the natue of f() and the initial guess Computational methods using N-R should inlude some safety featues: 1. Substitute the final estimate fo the oot bak into f (). Chek whethe the esult is lose to zeo. Limit the numbe of iteations to some maimum value 3. Chek whethe the slope f () = at any iteation 4. Make the pogam plot the estimated oot at eah iteation fo inspetion

Nonlinea Systems Dunn Chapte 5 Nonlinea equations Root finding Baketing methods Open methods Gaphial Bisetion False Position Newton s method Fied-point iteation Newton- Raphson Bent s method