Module - UWEC Computer Science Department

Download Report

Transcript Module - UWEC Computer Science Department

CS 170:
Computing for the Sciences and
Mathematics
Integration
Monte Carlo Methods
Administrivia
 Last time
Exam #2
 Will be returned on Monday.

 Today
 Integration
 Monte Carlo methods
 No class Thursday (Thanksgiving)
Accumulation
 Velocity function v(t) = 65 km/hr with t in hr
 What is the total distance traveled from t = 0 to t = 2?
 What is the area under the curve from t = 0 to t = 2?
Non-Uniform Velocity
 Estimate of total distance traveled during each 1 sec
interval?
 Estimate of total distance traveled between t = 0 and
t = 5 sec?
t (se c)
0
1
2
3
4
5
v (m/se c)
24
33
40
45
48
49
Underestimation
 Underestimate of total distance traveled with 1 m
intervals
A Better way?
 Is there a way to not underestimate?
t (se c)
0
1
2
3
4
5
v (m/se c)
24
33
40
45
48
49
Overestimation
 Overestimate of total distance traveled with 1 m
intervals
Better Estimate
 Under- and overestimates of total distance traveled
during each 0.5 sec interval?
 Under- and overestimates of total distance traveled
between t = 0 and t = 5 sec?
t (se c)
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
v
24.00 28.75 33.00 36.75 40.00 42.75 45.00 46.75 48.00 48.75 49.00
(m/se c)
Estimates with Interval = 0.5 m
 As intervals get smaller, under- and overestimates
approach:
1.
2.
3.
same number
total distance traveled from t = 0 to t = 5 sec
area under curve from t = 0 to t = 5 sec
Definite integral of f from a to b


b
a
b
a
f (t)dt  lim(left - hand sum) = lim( f (t0 )t  f (t1)t 
n
n
f (t)dt  lim(right - hand sum) = lim( f (t1)t  f (t1 )t 
n
n
 f (tn1 )t)
 f (tn )t)
In English: The integral of a function is the sum of all
of the “slices” as the slice width goes to 0.
Sometimes, this is called the antiderivative.
Total change in function
total change inF(t)
 a F'(t)dt   from t  a to t  b  F(b) F(a)
b
 Note that, if I know what F(t) is, this is easy
 Sometimes, we don’t!
 Same issue we had for differential eqns.
Monte Carlo Simulation
 Probabilistic model involving element of chance
 Not deterministic
 Uses a deterministic method/algorithm with random inputs
 Uses random number generator
HOMEWORK!
 No class Thursday
 Next Monday’s Class in P265