lecture 6: roots and numerical integration topics ...gatzke/211/lec6.pdf · lecture 6: roots and...

16
Lecture 6: Roots and Numerical Integration Topics: Techniques for numerical integration Review of material for test 1 HW: HW 1, Part 5 Assignment posted online Feb 2/3 : TEST 1 in class Team declarations due by email

Upload: others

Post on 11-Jun-2020

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 6: Roots and Numerical Integration Topics ...gatzke/211/Lec6.pdf · Lecture 6: Roots and Numerical Integration Topics: Techniques for numerical integration Review of material

Lecture 6: Roots and Numerical Integration

Topics: Techniques for numerical integration

Review of material for test 1

HW: HW 1, Part 5

Assignment posted online

Feb 2/3 : TEST 1 in class

Team declarations due by email

Page 2: Lecture 6: Roots and Numerical Integration Topics ...gatzke/211/Lec6.pdf · Lecture 6: Roots and Numerical Integration Topics: Techniques for numerical integration Review of material

Step 1: Represent each vector in its Cartesian

components

45˚

100

N

45 N

75 N F1

F2

F3

F1 = [75j] N

F2 = [-45j] N

F3 = [-100cos45i – 100sin45j] N+x

+y

Step 2: Add like components

FR = ([-100cos45]i + [75 -45 -100sin45]j) N

FR = ([-70.7]i + [-40.7]j) N

+x

+y

FR

θ

FR = (-70.72 + -40.72)1/2 = 81.6 N

Θ = tan-1(40.7/70.7) = 29.9˚

Step 3: Find the magnitude and angle of the resultant vector

Page 3: Lecture 6: Roots and Numerical Integration Topics ...gatzke/211/Lec6.pdf · Lecture 6: Roots and Numerical Integration Topics: Techniques for numerical integration Review of material

)(

)(1

i

iii xF

xFxx

′−=+

Make an initial guess for the root of the equation (xi)

The iterative Newton’s Method follows as

)( xF

0)( =xF

)(' ixF

ix1+ix

( ) 0)()( 1' =−+ + iiii xxxFxF

)( ixF

Page 4: Lecture 6: Roots and Numerical Integration Topics ...gatzke/211/Lec6.pdf · Lecture 6: Roots and Numerical Integration Topics: Techniques for numerical integration Review of material

In general, nonlinear equations can have more than 1 root – the

iterative Newton’s method allows you to approximate 1 root that is

close to your initial guess. This is termed a local root.

Example

x3 = ln(x) + 3

F(x) = x3 - ln (x) – 3

F’(x) = 3x2 – 1/x

Iteration Xi F(xi) F’(x) Xi+1

1 1 -2 2 2

2 2 4.3 11.5 1.63

3 1.63 .84 7.35 1.52

)(

)(1

i

iii xF

xFxx

′−=+

F(1.52) = 0.09

Fairly close to 0 after only 3 iterations

Page 5: Lecture 6: Roots and Numerical Integration Topics ...gatzke/211/Lec6.pdf · Lecture 6: Roots and Numerical Integration Topics: Techniques for numerical integration Review of material

)( xF

0)( =xF

Lx UxUxLx

Bisection Method

No derivative needed!Needs XL and XU

Page 6: Lecture 6: Roots and Numerical Integration Topics ...gatzke/211/Lec6.pdf · Lecture 6: Roots and Numerical Integration Topics: Techniques for numerical integration Review of material

Finding the roots of a nonlinear equation in MATLAB

We want to use the command: fzero

fzero (‘function name’, initial guess) returns the root of the function that is

closest to your initial guess

Function: F(x) = x3 - ln (x) – 3

Initial guess for local root: 1

To use this command, we must first write a separate function file that specifies

the function of interest

In MATLABGo over example of using fzero to find the local root of a nonlinear function

Page 7: Lecture 6: Roots and Numerical Integration Topics ...gatzke/211/Lec6.pdf · Lecture 6: Roots and Numerical Integration Topics: Techniques for numerical integration Review of material

What is a definite integral?

It is a mathematical concept that represents a select region (between x=a and

x=b) of the area between the curve described by f(x) and the x axis

I

(AUC)

“AUC” importance in BME

Materials

Strain Energy (stress-strain)

Pharmacokinetic

Total Drug Content (concentration-time)

Cardiovascular Physiology

Work done by the heart (P-V)

Page 8: Lecture 6: Roots and Numerical Integration Topics ...gatzke/211/Lec6.pdf · Lecture 6: Roots and Numerical Integration Topics: Techniques for numerical integration Review of material

What is the utility of integration to a Biomedical Engineer?

-Some physical quantities are not measured, but instead calculated

-Some calculations involve integration

Example: Integrating concentration fields

Fixed

concentration of

chemical species

Flow in Flow out

Velocity: Vector field Concentration: Scalar field

Page 9: Lecture 6: Roots and Numerical Integration Topics ...gatzke/211/Lec6.pdf · Lecture 6: Roots and Numerical Integration Topics: Techniques for numerical integration Review of material

c(x) = (-0.0125x + 0.0025) moles/m3

y=0

y=0.2

x=-0.6 x=0.2

This equation applies across the

bottom of the channel only – this

is termed a cross-section plot in

COMSOL

Page 10: Lecture 6: Roots and Numerical Integration Topics ...gatzke/211/Lec6.pdf · Lecture 6: Roots and Numerical Integration Topics: Techniques for numerical integration Review of material

∫=b

a

c dxxcM )(

∫−

+=1.0

6.0

x 0.0025) (-0.0125x dM c

)0025.02

0125.0(

2

xx

M c +−=-0.6

.1

Mc

= [-0.0125 (.1)2/2 + (0.0025 * .1)] - [-0.0125 (-.6)2/2 + (0.0025 * (-.6))]

Mc

= 1.875e-4 – - 3.75e-3 = 3.93e-3 moles/m2

a b

If I multiply Mc

by the channel height, I will get some value with units moles/m.

Mc

x 0.2m = 7.9e-4 moles/m WHAT DOES THIS REPRESENT?

This is approximate value COMSOL would return for a sub-domain integration in this 2-

D space, only because concentration is largely independent of y.

Page 11: Lecture 6: Roots and Numerical Integration Topics ...gatzke/211/Lec6.pdf · Lecture 6: Roots and Numerical Integration Topics: Techniques for numerical integration Review of material

There are easy integrals that you should know

xdxIb

a

33 == ∫

2

2xxdxI

b

a

== ∫

3

32 xdxxI

b

a

== ∫

a

b

a

b

a

b

*There are also integration tables you

can refer to

Page 12: Lecture 6: Roots and Numerical Integration Topics ...gatzke/211/Lec6.pdf · Lecture 6: Roots and Numerical Integration Topics: Techniques for numerical integration Review of material

When function (integrand) is complex, apply a numerical method to approximate the value

∫b

a

dxxf )(

Single Application of the Trapezoid Rule:

[ ])()(2

)(bfaf

abIT +−=

[ ] 5.2122

)12( 22 =+−=TI

Example

∫2

1

2dxx

Exact answer:

7/3 = 2.33

Page 13: Lecture 6: Roots and Numerical Integration Topics ...gatzke/211/Lec6.pdf · Lecture 6: Roots and Numerical Integration Topics: Techniques for numerical integration Review of material

For a better approximation, use the Composite Trapezoid Rule:

++= ∑−

=

)()(2)(2

1

10 N

N

iiT xfxfxf

hI

,N

abh

−= bxax N ≡≡ and 0

N = number of subdivisions

The spacing between “x” values is h

Page 14: Lecture 6: Roots and Numerical Integration Topics ...gatzke/211/Lec6.pdf · Lecture 6: Roots and Numerical Integration Topics: Techniques for numerical integration Review of material

∫2

1

2dxx

++= ∑−

=

)()(2)(2

1

10 N

N

iiT xfxfxf

hI

4/1=−=N

abh

Assume N = 4 (i.e. we will divide the area into 4 trapezoids)

This implies that we will evaluate the function at xo = a =1x1 = a+1h = 1.25x2 = a+2h = 1.5x3 = a+3h = 1.75xN = a +4h = a + Nh = b = 2

1 2 3 4

Page 15: Lecture 6: Roots and Numerical Integration Topics ...gatzke/211/Lec6.pdf · Lecture 6: Roots and Numerical Integration Topics: Techniques for numerical integration Review of material

xo = a =1x1 = a+1h = 1.25x2 = a+2h = 1.5x3 = a+3h = 1.75

xN = a +4h = a + Nh = b = 2

++= ∑−

=

)()(2)(2

1

10 N

N

iiT xfxfxf

hI

2)( xxf = 4/1=−=N

abh N = 4

[ ])2()]75.1()5.1()25.1([2)1(2

4/1fffffIT ++++=

[ ])2()]75.1()5.1()25.1([2)1(2

4/1fffffIT ++++=

34.2=TI

Exact answer:

7/3 = 2.33

Page 16: Lecture 6: Roots and Numerical Integration Topics ...gatzke/211/Lec6.pdf · Lecture 6: Roots and Numerical Integration Topics: Techniques for numerical integration Review of material

Test 1 Topics

• Define basic terms that appear in lecture notes

• Perform vector operations

• Perform matrix operations

• Know basic MATLAB syntax

• Resolve Cartesian vectors into components

• Add Cartesian vectors

• Iterative Newton’s Method for root finding

• Mass Balances on simple system

Test format

-A mix of problems, short answer, and multiple choice

-No notes allowed

-Calculators are allowed, but you may be asked to show your work