Top Banner
Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions, financial decisions, curve fitting, fixed point iterations, numerical solutions to differential equations require scientific computation. Excel is a very useful and easy to use software to perform these computations.
30

Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

Dec 25, 2015

Download

Documents

Carmella Martin
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

Scientific Computation Using Excel1. Introduction

Scientific computing is very important for solving real world application problems. Population predictions, financial decisions, curve fitting, fixed point iterations, numerical solutions to differential equations require scientific computation. Excel is a very useful and easy to use software to perform these computations.

Page 2: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

Difference Equation

2. Difference EquationA difference equation is an equation relating

successive terms of a sequence. The solution to the difference equation is the sequence (a function of n ) that satisfies the difference equation. While it can always be expressed in terms of the specific numbers in the sequence, whenever possible, it is desirable to express the solution as a formula in closed form in terms of the general term .

Page 3: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

Difference Equations

Example 1 The exponential growth or decay model is

represented by the difference equation:

with initial value . Its solution is given by the formula

for all

1n nx kx 0x

0n

nx x k0,1,2,...n

Page 4: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

Difference Equations

Example 2The Fibonacci sequence:

satisfies the difference equation

for with .

{1,1,2,3,5,8,...}

1 1n n nF F F

1,2,3,...n

1 0 1F F

Page 5: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

Difference Equations

Example 3Newton’s method for solving nonlinear equation. Consider the equation

the nth approximation to a solution to the equation can be generated by the formula:

( ) 0f x

1

( )

'( )n

n nn

f xx x

f x

Page 6: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

Difference Equations

Example 4

Fixed point iteration. A point is a fixed point of the function

if

. To find a fixed point, one can starts with an initial guess and generate the successive approximations by the difference equation

.

( )f x( )f x x

1 ( )n nx f x

Page 7: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

Applications

I. Population Models

1. Simple Models

Let be the population of certain specie in the nth period. If the population grows at a rate of k per period, then

nP

1n nP kP

Page 8: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

Population of Yeast CultureTime in hours n

Observed yeast

biomass

Change in biomass

0 9.6 8.7

1 18.3 10.7

2 29.0 18.2

3 47.2 23.9

4 71.1 48.0

5 119.1 55.5

6 174.6 82.7

7 257.3

nP1n nP P

Page 9: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

Simple ModelThe population of the next period can be

approximated by

1 1.6n nP P

Growth of Yeast Culture

0

100

200

300

0 2 4 6 8

Time in hours

Bio

mas

s

Page 10: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

Simple Model

Prediction of population

020000400006000080000

0 5 10 15 20

Time in hours

Bio

mas

s

Page 11: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

Logistic Model

The simple model assumes the population grows without bound, but certain resources can support only a maximum population level. A logistic model governed by the difference equation

is a better model for most real-world situation.

1 ( )n n nP k M P P

Page 12: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

The Graph of a Yeast Culture

Growth a a yeast culture

0200400600800

0 5 10 15 20

Time in hours

Yeas

t Bio

mas

s

Page 13: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

The Model

From the graph of population verse time, the population appears to be approaching a limiting value, we estimate this value to be 665. Consider the model,

By regression, we can estimate the to be 0.00082.

1 (665 )n n n nP P kP P

Page 14: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

Financing a Car or a Home

You want to buy a car or a home by financing. Every one will tell you this is a good time to do it. A mortgage company will loan you a certain amount of money with a fixed annual interest rate , now you will repay this debt with a series of equal monthly payments over a fixed number of months. There are several questions that you, as a consumer, should be able to answer:

Page 15: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

Financing a Car or a Home a.       Given the loan amount, the term, the interest

rate, how much will be the monthly payment? b.      Given the term of the loan, the interest rate.

If you know how much you can pay for each month, what will be the maximum amount of loan that you can afford to?

c.       For each month, how much of your monthly payment is going into the principal? How much is paying for the interests?

 

Page 16: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

A Car Rental Model

Consider a car rental company with distributorships in Orlando and Tampa. The company specializes in catering to travel agents who wants to arrange tourist activities in both Orlando and Tampa. Consequently, a traveler will rent a car in one city and drop the car off in the second city. Travelers may begin their itinerary in either city. The company is trying to determine how much to charge for this drop-off convenience.

Page 17: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

A Car Rental Model

Because cars are dropped off in both cities, will a sufficient number of cars end up in each city to satisfy the demand for cars in that city? If not, how many cars must be the company transport from Orlando to Tampa or from Tampa to Orlando? The answers to these questions will help the company figure out the expected costs

Page 18: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

A Car Rental Model

The historical records suggest that 60% of the cars rented in Orlando are returned to Orlando, whereas the other 40% of the cars end up in Tampa. Of the cars rented in Tampa, 70% are returned to Tampa, whereas the 30% end up in Orlando. Define

the number of cars in Orlando at the end of day

the number of cars in Tampa at the end of day .

nO

nT

Page 19: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

A Car Rental Model

We can use the following system of difference equations to model the flow of the cars for the company:

1

1

0.6 0.3

0.4 0.7n n n

n n n

O O T

T O T

Page 20: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

A Car Rental Model

Various initial conditions:

Orlando Tampa

Case 1 7000 0

Case2 5000 2000

Case 3 2000 5000

Case 4 0 7000

Page 21: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

Predator-Prey Models

Owls and Mice Assume that the spotted owl’s primary food source is a single prey, say mice. Let represent the size of the spotted owl population at the end of day , and let represent the size of the mice population. We can use the following nonlinear system of difference equations to model the populations of the two species:

nO

nM

Page 22: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

Owls and Mice

Where are positive constantdepending on specific situations. Now let’s consider specific values:

.

1

1

(1 )

(1 )n n n n

n n n n

M a M bO M

O c O dO M

, , ,a b c d

0.2, 0.001, 0.3, 0.002a b c d

Page 23: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

Owls and Mice

We will study how the long term behavior of this dynamical system depending on the initial condition

Owls Mice

Case 1 850 200

Case 2 849 201

Case 3 851 199

Case 4 860 190

Page 24: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

Fixed Point Iteration and Chaos Fixed Point Iteration

A point x is called a fixed point of a function if . An iteration defined by is called a fixed point iteration. If the sequence converges, then it will converge to one of the fixed points of the function. It will be interesting to find out what initial value will lead to a convergent sequence.

( )f x ( )f x x1 ( )n nx f x

{ }nx

Page 25: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

Fixed Point Iteration

Example: Consider the function , it can shown easily that 0 and 1 are the fixed points. If the initial value is between –1 and 1 (exclude –1 and 1), then the sequence generated by the fixed point iteration converges to 0, if the initial value is 1, it converges to 1. If the initial value is –1, it diverges. If the absolute value of the initial value is greater than 1, it diverges.

2( )f x x

Page 26: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

Fixed Point Iteration

Example: Consider a fixed point iteration of the form , we would like to find out what will happen to the sequence for a given initial value . Let’s see what happen if . If , the sequence is all zeros no matter what value of a is. But if , we have the following:

1 ( )n nx f x

0x

( )f x ax0 0x

0 0x

Page 27: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

Fixed Point Iteration

If , the sequence diverges.

If , the sequence converges to 0.

If a = 1, the sequence is constant .

If a = -1 , the sequence oscillates between and .

| | 1a

| | 1a

0x

0x 0x

Page 28: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

Chaos

Example: Now let us explore what will

happen if

First, if the initial value is 0, then all

successive iterates are 0. Second, if any iterate

is either 0 or 1, then all successive iterates

will remain 0.Third, if any iterate is negative,

then the succeeding value will also be

negative;

( ) (1 )f x a x x

nx

1nx

Page 29: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

Chaos

further, will be more negative than because of the term . Consequently, the successive term will diverge toward . Fourth, if any iterate is larger than 1, then the succeeding value will be negative and the sequence will thereafter diverge to . As a result, we see that the only meaningful cases involve starting with values between 0 and 1 and remaining there for all values of thereafter.

1nx nx

1 nx

Page 30: Scientific Computation Using Excel 1. Introduction Scientific computing is very important for solving real world application problems. Population predictions,

Chaos

Now let us see what effect the value a of has

on the process. You can study this using

Excel. We will explore what will happen to

the sequence if a between 0 and 1, between 1

and 3, between 3 and 4, greater than 4.