SlideShare a Scribd company logo
1
1
Programming, Computation, Simulation
Applications in Math & Physics
Numerical Integrations
Syeilendra Pramuditya
Department of Physics
Institut Teknologi Bandung
2
Physics Problem
 Period of Pendulum
How Easy!
2
2
( )
( )
2
1
2
d t
t SHM
dt
g
f
l
l
T
f g

 
 

  
 
 
3
Physics Problem
 Large Amplitude Pendulum..?
4
Physics Problem
 Large Amplitude Pendulum..?
sin
g
d d
l
    
 
 
 
5
Large Amplitude Pendulum
Problem: Division by zero
6
Large Amplitude Pendulum
Legendre Complete Elliptic Integral of the First Kind
Trigonometric identities, change of variable, etc…
7
Large Amplitude Pendulum
 Input
 g, l, 0
 Process
 Evaluate the integral
 Output
 Period of the pendulum
Small Amplitude
1
2
l
T
f g

 
Solution by series expansion
Check your result
8
Do The Code
 Benchmark your integrator code first
0
1 0
sin(30 ) 0.5
sin (0.5) 30



9
9
Numerical Integration
 Definite integral of f(t) on
interval [a,b]
 Analytic method: anti-
derivative
 F where F’(t) = f(t)
 Iab = F(b) – F(a)
( ) ( ) ( ) ( )
b
ab
a
F t I f t dt F b F a
   

10
Hand Calculation?
 Calculate until 2 decimal numbers?
 a = 88/17
 b = square-root of 23
 c = ln(7)
11
11
Numerical Integration
 ln7 = .. ?
 ln5 = .. ?
7
5
1
( )
1
ln 7 ln5
ab
f t
t
I dt
t

  

 Need to somehow calculate the numerical value of natural
logarithm
 Real-world functions don’t have anti derivatives
 Direct calculation of definite integrals is needed
12
Numerical Integration
 Newton-Cotes Formula
 Composite Method
 Quadrature Method
 Riemann Sum
 Etc…
13
13
Numerical Integration
 Example: value of ln(1.2)
1
1
ln( )
x
x dt
t
 
1.2
1
1
ln(1.2) dt
t
 
 Ln(1.2) = area below the curve
14
14
Numerical Integration
 General Formula
0
( ) ( )
b n
ab i i
i
a
I f t dt f t w

  

 f(ti) : function f evaluated at ti
 wi : weighting factor
15
Numerical Integration
 Calculating Area
16
16
Rectangle Rule
( ) ( ) ( ) ( )
b
ab i i
a
I f t dt f t w f a b a
    

17
17
Midpoint Rule
( ) ( ) ( )
2
b
ab i i
a
a b
I f t dt f t w f b a

 
    
 
 

18
18
Trapezoid Rule
   
( ) ( ) ( )
2
b
ab i i
a
f a f b
I f t dt f t w b a

    

19
19
Non-Linear Rule (Simpson)
Approx. by 3-point Lagrange interpolation (Quadratic)
2
( )
p x ax bx c
  
20
20
Simpson Rule
( ) ( ) ( ) 4 ( )
6 2
b
ab i i
a
b a a b
I f t dt f t w f a f f b
   
 
     
 
 
 
 

Derived using integ. by substitution for 3-point Lagrange interpolation (Quadratic)
21
21
Simpson Rule
1
1
1
( ) ( ) 4 ( )
6 2
b N
i i
ab i i
i
a
x x
x
I f x dx f x f f x



 
 


    
 
 
 
 


Derived using integ. by substitution for 3-point Lagrange interpolation (Quadratic)
N partitions
22
More Complex Integral
7.6
3.2
2
( )
ln( )
( )
5
ab
I f t dt
x
f t
x




23
Adaptive Method
 Automatic Re-partitioning
24
Monte Carlo Integration
1
Average of 2, 8, 5, 12, 4
2 8 5 12 4
Average
5
1
( ) ( )
( )
1
( ) ( )
N
b
i
a
i
b
b
b a
b
a
a
a
f x f x
N
f x dx
f x f x dx
b a
dx

   


 





Discrete Functions
Continuous Functions
25
Monte Carlo Integration
( )
1
( ) ( )
b
b
b a
b
a
a
a
f x dx
f x f x dx
b a
dx
 




1
1
( ) ( )
N
b
i
a
i
f x f x
N 
 
1
( ) ( ) ( ) ( )
b N
b
i
a
i
a
b a
f x dx b a f x f x
N 

    

Rectangle of same area with original function
26
Do The Code: Monte Carlo Integration
5.7
1
1
ln(5.7) 1.74
dt
t
 

27
Do The Code: Monte Carlo Integration
N ln(5.7)
10 1.669
20 1.914
40 1.622
80 1.872
160 1.819
320 1.690
640 1.693
1280 1.723
2560 1.739 1.600
1.650
1.700
1.750
1.800
1.850
1.900
1.950
1 10 100 1000 10000
N points
Numerical
Value
5.7
1
1
ln(5.7) 1.74
dt
t
 

28
Do The Code: Monte Carlo Integration
5.7
1
1
ln(5.7) 1.74
dt
t
 

N ln(5.7) ln(5.7) ln(5.7)
10 1.669 2.087 1.651
20 1.914 1.936 1.670
40 1.622 2.043 1.901
80 1.872 1.787 1.759
160 1.819 1.675 1.789
320 1.690 1.777 1.653
640 1.693 1.726 1.705
1280 1.723 1.751 1.712
2560 1.739 1.738 1.740
1.500
1.600
1.700
1.800
1.900
2.000
2.100
2.200
1 10 100 1000 10000
N points
Numerical
value
29
Do The Code: Monte Carlo Integration
5.7
1
1
ln(5.7) 1.74
dt
t
 

1
1.2
1.4
1.6
1.8
2
2.2
2.4
2.6
2.8
0 20 40 60 80 100
N=10
N=160
N=2560
30
Do The Code: Monte Carlo Integration
7.6
3.2
2
( )
ln( )
( )
5
ab
I f t dt
x
f t
x




31
Sample Problem
A variable force is applied to an initially stationary box of mass
2.35 kg at x= 0 m. The box moves in +x direction due to the
applied force. What is the speed of the box when its position is at x
= 7.53 m? The surface is frictionless.
2 ˆ
( ) 5 sin ( rad)
F x x x i N
 

2 2
1 1
2 2
2 2
1 1
( ) ( )cos(0)
1
( ) 5 sin ( )
2
f i
x x
f
x x
x x
f
x x
K K K W
K F x dx F x dx
mv F x dx x x dx
   
 
  
 
 


32
The Integral
2
2
1
5 sin ( )
x
x
I x x dx
 

Gnuplot
set xrange [0:10]
set xrange [0:20]
plot x*(sin(x))**2
33
Practice
 Develop your integrator code using Simpson rule in Pascal
language
 The code mainly evaluates numerically:
 What is the final speed of the box?
 Using 75 partitions
2
2
1
5 sin ( )
x
x
I x x dx
 


More Related Content

What's hot

Linear transformations-thestuffpoint.com
Linear transformations-thestuffpoint.comLinear transformations-thestuffpoint.com
Linear transformations-thestuffpoint.com
Abu Bakar Soomro
 
Hermite integrators and Riordan arrays
Hermite integrators and Riordan arraysHermite integrators and Riordan arrays
Hermite integrators and Riordan arrays
Keigo Nitadori
 
Hierarchical matrix techniques for maximum likelihood covariance estimation
Hierarchical matrix techniques for maximum likelihood covariance estimationHierarchical matrix techniques for maximum likelihood covariance estimation
Hierarchical matrix techniques for maximum likelihood covariance estimation
Alexander Litvinenko
 
A block-step version of KS regularization
A block-step version of KS regularizationA block-step version of KS regularization
A block-step version of KS regularization
Keigo Nitadori
 
Homework 1 of Optical Semiconductor
Homework 1 of Optical SemiconductorHomework 1 of Optical Semiconductor
Homework 1 of Optical Semiconductor
Lê Đại-Nam
 
Identification of unknown parameters and prediction of missing values. Compar...
Identification of unknown parameters and prediction of missing values. Compar...Identification of unknown parameters and prediction of missing values. Compar...
Identification of unknown parameters and prediction of missing values. Compar...
Alexander Litvinenko
 
Low-rank matrix approximations in Python by Christian Thurau PyData 2014
Low-rank matrix approximations in Python by Christian Thurau PyData 2014Low-rank matrix approximations in Python by Christian Thurau PyData 2014
Low-rank matrix approximations in Python by Christian Thurau PyData 2014
PyData
 
Parallel Coordinate Descent Algorithms
Parallel Coordinate Descent AlgorithmsParallel Coordinate Descent Algorithms
Parallel Coordinate Descent Algorithms
Shaleen Kumar Gupta
 
Optimal Budget Allocation: Theoretical Guarantee and Efficient Algorithm
Optimal Budget Allocation: Theoretical Guarantee and Efficient AlgorithmOptimal Budget Allocation: Theoretical Guarantee and Efficient Algorithm
Optimal Budget Allocation: Theoretical Guarantee and Efficient Algorithm
Tasuku Soma
 
redes neuronais
redes neuronaisredes neuronais
redes neuronais
Roland Silvestre
 
Maximizing Submodular Function over the Integer Lattice
Maximizing Submodular Function over the Integer LatticeMaximizing Submodular Function over the Integer Lattice
Maximizing Submodular Function over the Integer Lattice
Tasuku Soma
 
Lecture note4coordinatedescent
Lecture note4coordinatedescentLecture note4coordinatedescent
Lecture note4coordinatedescent
Xudong Sun
 
chap 2 Ex#1.1
chap 2 Ex#1.1chap 2 Ex#1.1
chap 2 Ex#1.1
Ans Ali
 
Convergence methods for approximated reciprocal and reciprocal-square-root
Convergence methods for approximated reciprocal and reciprocal-square-rootConvergence methods for approximated reciprocal and reciprocal-square-root
Convergence methods for approximated reciprocal and reciprocal-square-root
Keigo Nitadori
 
ZK Study Club: Sumcheck Arguments and Their Applications
ZK Study Club: Sumcheck Arguments and Their ApplicationsZK Study Club: Sumcheck Arguments and Their Applications
ZK Study Club: Sumcheck Arguments and Their Applications
Alex Pruden
 
Fast Wavelet Tree Construction in Practice
Fast Wavelet Tree Construction in PracticeFast Wavelet Tree Construction in Practice
Fast Wavelet Tree Construction in Practice
Rakuten Group, Inc.
 
Digitalcontrolsystems
DigitalcontrolsystemsDigitalcontrolsystems
Digitalcontrolsystems
Satish Gottumukkala
 
linear transfermation.pptx
linear transfermation.pptxlinear transfermation.pptx
linear transfermation.pptx
Umme habiba
 

What's hot (19)

Linear transformations-thestuffpoint.com
Linear transformations-thestuffpoint.comLinear transformations-thestuffpoint.com
Linear transformations-thestuffpoint.com
 
Hermite integrators and Riordan arrays
Hermite integrators and Riordan arraysHermite integrators and Riordan arrays
Hermite integrators and Riordan arrays
 
Hierarchical matrix techniques for maximum likelihood covariance estimation
Hierarchical matrix techniques for maximum likelihood covariance estimationHierarchical matrix techniques for maximum likelihood covariance estimation
Hierarchical matrix techniques for maximum likelihood covariance estimation
 
A block-step version of KS regularization
A block-step version of KS regularizationA block-step version of KS regularization
A block-step version of KS regularization
 
Homework 1 of Optical Semiconductor
Homework 1 of Optical SemiconductorHomework 1 of Optical Semiconductor
Homework 1 of Optical Semiconductor
 
Identification of unknown parameters and prediction of missing values. Compar...
Identification of unknown parameters and prediction of missing values. Compar...Identification of unknown parameters and prediction of missing values. Compar...
Identification of unknown parameters and prediction of missing values. Compar...
 
Low-rank matrix approximations in Python by Christian Thurau PyData 2014
Low-rank matrix approximations in Python by Christian Thurau PyData 2014Low-rank matrix approximations in Python by Christian Thurau PyData 2014
Low-rank matrix approximations in Python by Christian Thurau PyData 2014
 
Parallel Coordinate Descent Algorithms
Parallel Coordinate Descent AlgorithmsParallel Coordinate Descent Algorithms
Parallel Coordinate Descent Algorithms
 
Optimal Budget Allocation: Theoretical Guarantee and Efficient Algorithm
Optimal Budget Allocation: Theoretical Guarantee and Efficient AlgorithmOptimal Budget Allocation: Theoretical Guarantee and Efficient Algorithm
Optimal Budget Allocation: Theoretical Guarantee and Efficient Algorithm
 
redes neuronais
redes neuronaisredes neuronais
redes neuronais
 
Maximizing Submodular Function over the Integer Lattice
Maximizing Submodular Function over the Integer LatticeMaximizing Submodular Function over the Integer Lattice
Maximizing Submodular Function over the Integer Lattice
 
Lecture note4coordinatedescent
Lecture note4coordinatedescentLecture note4coordinatedescent
Lecture note4coordinatedescent
 
chap 2 Ex#1.1
chap 2 Ex#1.1chap 2 Ex#1.1
chap 2 Ex#1.1
 
Convergence methods for approximated reciprocal and reciprocal-square-root
Convergence methods for approximated reciprocal and reciprocal-square-rootConvergence methods for approximated reciprocal and reciprocal-square-root
Convergence methods for approximated reciprocal and reciprocal-square-root
 
ZK Study Club: Sumcheck Arguments and Their Applications
ZK Study Club: Sumcheck Arguments and Their ApplicationsZK Study Club: Sumcheck Arguments and Their Applications
ZK Study Club: Sumcheck Arguments and Their Applications
 
Fast Wavelet Tree Construction in Practice
Fast Wavelet Tree Construction in PracticeFast Wavelet Tree Construction in Practice
Fast Wavelet Tree Construction in Practice
 
Digitalcontrolsystems
DigitalcontrolsystemsDigitalcontrolsystems
Digitalcontrolsystems
 
linear transfermation.pptx
linear transfermation.pptxlinear transfermation.pptx
linear transfermation.pptx
 
Solution2
Solution2Solution2
Solution2
 

Similar to SPSF03 - Numerical Integrations

A successful maximum likelihood parameter estimation in skewed distributions ...
A successful maximum likelihood parameter estimation in skewed distributions ...A successful maximum likelihood parameter estimation in skewed distributions ...
A successful maximum likelihood parameter estimation in skewed distributions ...
Hideo Hirose
 
Block diagram, Transfer Function from block diagram reduction, (8 Rules to re...
Block diagram, Transfer Function from block diagram reduction, (8 Rules to re...Block diagram, Transfer Function from block diagram reduction, (8 Rules to re...
Block diagram, Transfer Function from block diagram reduction, (8 Rules to re...
Waqas Afzal
 
Modern Control - Lec 05 - Analysis and Design of Control Systems using Freque...
Modern Control - Lec 05 - Analysis and Design of Control Systems using Freque...Modern Control - Lec 05 - Analysis and Design of Control Systems using Freque...
Modern Control - Lec 05 - Analysis and Design of Control Systems using Freque...
Amr E. Mohamed
 
Project final control
Project final controlProject final control
Project final control
Shironamhin Sharif
 
Applied numerical methods lec10
Applied numerical methods lec10Applied numerical methods lec10
Applied numerical methods lec10
Yasser Ahmed
 
Kertas Percubaan Matematik Tambahan Kedah Skema K2
Kertas Percubaan Matematik Tambahan Kedah Skema K2Kertas Percubaan Matematik Tambahan Kedah Skema K2
Kertas Percubaan Matematik Tambahan Kedah Skema K2
Tuisyen Geliga
 
5th Semeste Electronics and Communication Engineering (June-2016) Question Pa...
5th Semeste Electronics and Communication Engineering (June-2016) Question Pa...5th Semeste Electronics and Communication Engineering (June-2016) Question Pa...
5th Semeste Electronics and Communication Engineering (June-2016) Question Pa...
BGS Institute of Technology, Adichunchanagiri University (ACU)
 
Theoretical and Practical Bounds on the Initial Value of Skew-Compensated Cl...
Theoretical and Practical Bounds on the Initial Value of  Skew-Compensated Cl...Theoretical and Practical Bounds on the Initial Value of  Skew-Compensated Cl...
Theoretical and Practical Bounds on the Initial Value of Skew-Compensated Cl...
Xi'an Jiaotong-Liverpool University
 
DSP.ppt
DSP.pptDSP.ppt
Lecture -Earthquake Engineering (2).pdf
Lecture -Earthquake Engineering (2).pdfLecture -Earthquake Engineering (2).pdf
Lecture -Earthquake Engineering (2).pdf
RayRabara
 
3rd Semester Computer Science and Engineering (ACU - 2022) Question papers
3rd Semester Computer Science and Engineering  (ACU - 2022) Question papers3rd Semester Computer Science and Engineering  (ACU - 2022) Question papers
3rd Semester Computer Science and Engineering (ACU - 2022) Question papers
BGS Institute of Technology, Adichunchanagiri University (ACU)
 
Complete Factoring Rules.ppt
Complete Factoring Rules.pptComplete Factoring Rules.ppt
Complete Factoring Rules.ppt
Jasmin679773
 

Similar to SPSF03 - Numerical Integrations (20)

3rd Semester Electronic and Communication Engineering (2013-June) Question P...
3rd  Semester Electronic and Communication Engineering (2013-June) Question P...3rd  Semester Electronic and Communication Engineering (2013-June) Question P...
3rd Semester Electronic and Communication Engineering (2013-June) Question P...
 
2013-June: 3rd Semester E & C Question Papers
2013-June: 3rd Semester E & C Question Papers2013-June: 3rd Semester E & C Question Papers
2013-June: 3rd Semester E & C Question Papers
 
A successful maximum likelihood parameter estimation in skewed distributions ...
A successful maximum likelihood parameter estimation in skewed distributions ...A successful maximum likelihood parameter estimation in skewed distributions ...
A successful maximum likelihood parameter estimation in skewed distributions ...
 
Block diagram, Transfer Function from block diagram reduction, (8 Rules to re...
Block diagram, Transfer Function from block diagram reduction, (8 Rules to re...Block diagram, Transfer Function from block diagram reduction, (8 Rules to re...
Block diagram, Transfer Function from block diagram reduction, (8 Rules to re...
 
Modern Control - Lec 05 - Analysis and Design of Control Systems using Freque...
Modern Control - Lec 05 - Analysis and Design of Control Systems using Freque...Modern Control - Lec 05 - Analysis and Design of Control Systems using Freque...
Modern Control - Lec 05 - Analysis and Design of Control Systems using Freque...
 
3rd Semester CS and IS (2013-June) Question Papers
3rd  Semester CS and IS  (2013-June) Question Papers 3rd  Semester CS and IS  (2013-June) Question Papers
3rd Semester CS and IS (2013-June) Question Papers
 
2013-June: 3rd Semester CSE / ISE Question Papers
2013-June: 3rd  Semester CSE / ISE Question Papers2013-June: 3rd  Semester CSE / ISE Question Papers
2013-June: 3rd Semester CSE / ISE Question Papers
 
Project final control
Project final controlProject final control
Project final control
 
2013-June: 5th Semester E & C Question Papers
2013-June: 5th Semester E & C Question Papers2013-June: 5th Semester E & C Question Papers
2013-June: 5th Semester E & C Question Papers
 
5th Semester Electronic and Communication Engineering (2013-June) Question Pa...
5th Semester Electronic and Communication Engineering (2013-June) Question Pa...5th Semester Electronic and Communication Engineering (2013-June) Question Pa...
5th Semester Electronic and Communication Engineering (2013-June) Question Pa...
 
Applied numerical methods lec10
Applied numerical methods lec10Applied numerical methods lec10
Applied numerical methods lec10
 
Kertas Percubaan Matematik Tambahan Kedah Skema K2
Kertas Percubaan Matematik Tambahan Kedah Skema K2Kertas Percubaan Matematik Tambahan Kedah Skema K2
Kertas Percubaan Matematik Tambahan Kedah Skema K2
 
5th Semeste Electronics and Communication Engineering (June-2016) Question Pa...
5th Semeste Electronics and Communication Engineering (June-2016) Question Pa...5th Semeste Electronics and Communication Engineering (June-2016) Question Pa...
5th Semeste Electronics and Communication Engineering (June-2016) Question Pa...
 
Theoretical and Practical Bounds on the Initial Value of Skew-Compensated Cl...
Theoretical and Practical Bounds on the Initial Value of  Skew-Compensated Cl...Theoretical and Practical Bounds on the Initial Value of  Skew-Compensated Cl...
Theoretical and Practical Bounds on the Initial Value of Skew-Compensated Cl...
 
3rd Semester Electronic and Communication Engineering (2013-December) Questio...
3rd Semester Electronic and Communication Engineering (2013-December) Questio...3rd Semester Electronic and Communication Engineering (2013-December) Questio...
3rd Semester Electronic and Communication Engineering (2013-December) Questio...
 
DSP.ppt
DSP.pptDSP.ppt
DSP.ppt
 
Lecture -Earthquake Engineering (2).pdf
Lecture -Earthquake Engineering (2).pdfLecture -Earthquake Engineering (2).pdf
Lecture -Earthquake Engineering (2).pdf
 
3rd semester Computer Science and Information Science Engg (2013 December) Q...
3rd  semester Computer Science and Information Science Engg (2013 December) Q...3rd  semester Computer Science and Information Science Engg (2013 December) Q...
3rd semester Computer Science and Information Science Engg (2013 December) Q...
 
3rd Semester Computer Science and Engineering (ACU - 2022) Question papers
3rd Semester Computer Science and Engineering  (ACU - 2022) Question papers3rd Semester Computer Science and Engineering  (ACU - 2022) Question papers
3rd Semester Computer Science and Engineering (ACU - 2022) Question papers
 
Complete Factoring Rules.ppt
Complete Factoring Rules.pptComplete Factoring Rules.ppt
Complete Factoring Rules.ppt
 

Recently uploaded

general properties of oerganologametal.ppt
general properties of oerganologametal.pptgeneral properties of oerganologametal.ppt
general properties of oerganologametal.ppt
IqrimaNabilatulhusni
 
Hemoglobin metabolism_pathophysiology.pptx
Hemoglobin metabolism_pathophysiology.pptxHemoglobin metabolism_pathophysiology.pptx
Hemoglobin metabolism_pathophysiology.pptx
muralinath2
 
NuGOweek 2024 Ghent - programme - final version
NuGOweek 2024 Ghent - programme - final versionNuGOweek 2024 Ghent - programme - final version
NuGOweek 2024 Ghent - programme - final version
pablovgd
 
Mammalian Pineal Body Structure and Also Functions
Mammalian Pineal Body Structure and Also FunctionsMammalian Pineal Body Structure and Also Functions
Mammalian Pineal Body Structure and Also Functions
YOGESH DOGRA
 
DERIVATION OF MODIFIED BERNOULLI EQUATION WITH VISCOUS EFFECTS AND TERMINAL V...
DERIVATION OF MODIFIED BERNOULLI EQUATION WITH VISCOUS EFFECTS AND TERMINAL V...DERIVATION OF MODIFIED BERNOULLI EQUATION WITH VISCOUS EFFECTS AND TERMINAL V...
DERIVATION OF MODIFIED BERNOULLI EQUATION WITH VISCOUS EFFECTS AND TERMINAL V...
Wasswaderrick3
 
THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.
THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.
THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.
Sérgio Sacani
 
Salas, V. (2024) "John of St. Thomas (Poinsot) on the Science of Sacred Theol...
Salas, V. (2024) "John of St. Thomas (Poinsot) on the Science of Sacred Theol...Salas, V. (2024) "John of St. Thomas (Poinsot) on the Science of Sacred Theol...
Salas, V. (2024) "John of St. Thomas (Poinsot) on the Science of Sacred Theol...
Studia Poinsotiana
 
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
University of Maribor
 
Richard's aventures in two entangled wonderlands
Richard's aventures in two entangled wonderlandsRichard's aventures in two entangled wonderlands
Richard's aventures in two entangled wonderlands
Richard Gill
 
GBSN- Microbiology (Lab 3) Gram Staining
GBSN- Microbiology (Lab 3) Gram StainingGBSN- Microbiology (Lab 3) Gram Staining
GBSN- Microbiology (Lab 3) Gram Staining
Areesha Ahmad
 
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATIONPRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
ChetanK57
 
extra-chromosomal-inheritance[1].pptx.pdfpdf
extra-chromosomal-inheritance[1].pptx.pdfpdfextra-chromosomal-inheritance[1].pptx.pdfpdf
extra-chromosomal-inheritance[1].pptx.pdfpdf
DiyaBiswas10
 
Body fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptx
Body fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptxBody fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptx
Body fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptx
muralinath2
 
platelets_clotting_biogenesis.clot retractionpptx
platelets_clotting_biogenesis.clot retractionpptxplatelets_clotting_biogenesis.clot retractionpptx
platelets_clotting_biogenesis.clot retractionpptx
muralinath2
 
GBSN - Biochemistry (Unit 5) Chemistry of Lipids
GBSN - Biochemistry (Unit 5) Chemistry of LipidsGBSN - Biochemistry (Unit 5) Chemistry of Lipids
GBSN - Biochemistry (Unit 5) Chemistry of Lipids
Areesha Ahmad
 
bordetella pertussis.................................ppt
bordetella pertussis.................................pptbordetella pertussis.................................ppt
bordetella pertussis.................................ppt
kejapriya1
 
Leaf Initiation, Growth and Differentiation.pdf
Leaf Initiation, Growth and Differentiation.pdfLeaf Initiation, Growth and Differentiation.pdf
Leaf Initiation, Growth and Differentiation.pdf
RenuJangid3
 
role of pramana in research.pptx in science
role of pramana in research.pptx in sciencerole of pramana in research.pptx in science
role of pramana in research.pptx in science
sonaliswain16
 
GBSN - Microbiology (Lab 4) Culture Media
GBSN - Microbiology (Lab 4) Culture MediaGBSN - Microbiology (Lab 4) Culture Media
GBSN - Microbiology (Lab 4) Culture Media
Areesha Ahmad
 
nodule formation by alisha dewangan.pptx
nodule formation by alisha dewangan.pptxnodule formation by alisha dewangan.pptx
nodule formation by alisha dewangan.pptx
alishadewangan1
 

Recently uploaded (20)

general properties of oerganologametal.ppt
general properties of oerganologametal.pptgeneral properties of oerganologametal.ppt
general properties of oerganologametal.ppt
 
Hemoglobin metabolism_pathophysiology.pptx
Hemoglobin metabolism_pathophysiology.pptxHemoglobin metabolism_pathophysiology.pptx
Hemoglobin metabolism_pathophysiology.pptx
 
NuGOweek 2024 Ghent - programme - final version
NuGOweek 2024 Ghent - programme - final versionNuGOweek 2024 Ghent - programme - final version
NuGOweek 2024 Ghent - programme - final version
 
Mammalian Pineal Body Structure and Also Functions
Mammalian Pineal Body Structure and Also FunctionsMammalian Pineal Body Structure and Also Functions
Mammalian Pineal Body Structure and Also Functions
 
DERIVATION OF MODIFIED BERNOULLI EQUATION WITH VISCOUS EFFECTS AND TERMINAL V...
DERIVATION OF MODIFIED BERNOULLI EQUATION WITH VISCOUS EFFECTS AND TERMINAL V...DERIVATION OF MODIFIED BERNOULLI EQUATION WITH VISCOUS EFFECTS AND TERMINAL V...
DERIVATION OF MODIFIED BERNOULLI EQUATION WITH VISCOUS EFFECTS AND TERMINAL V...
 
THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.
THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.
THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.
 
Salas, V. (2024) "John of St. Thomas (Poinsot) on the Science of Sacred Theol...
Salas, V. (2024) "John of St. Thomas (Poinsot) on the Science of Sacred Theol...Salas, V. (2024) "John of St. Thomas (Poinsot) on the Science of Sacred Theol...
Salas, V. (2024) "John of St. Thomas (Poinsot) on the Science of Sacred Theol...
 
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
 
Richard's aventures in two entangled wonderlands
Richard's aventures in two entangled wonderlandsRichard's aventures in two entangled wonderlands
Richard's aventures in two entangled wonderlands
 
GBSN- Microbiology (Lab 3) Gram Staining
GBSN- Microbiology (Lab 3) Gram StainingGBSN- Microbiology (Lab 3) Gram Staining
GBSN- Microbiology (Lab 3) Gram Staining
 
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATIONPRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
 
extra-chromosomal-inheritance[1].pptx.pdfpdf
extra-chromosomal-inheritance[1].pptx.pdfpdfextra-chromosomal-inheritance[1].pptx.pdfpdf
extra-chromosomal-inheritance[1].pptx.pdfpdf
 
Body fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptx
Body fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptxBody fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptx
Body fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptx
 
platelets_clotting_biogenesis.clot retractionpptx
platelets_clotting_biogenesis.clot retractionpptxplatelets_clotting_biogenesis.clot retractionpptx
platelets_clotting_biogenesis.clot retractionpptx
 
GBSN - Biochemistry (Unit 5) Chemistry of Lipids
GBSN - Biochemistry (Unit 5) Chemistry of LipidsGBSN - Biochemistry (Unit 5) Chemistry of Lipids
GBSN - Biochemistry (Unit 5) Chemistry of Lipids
 
bordetella pertussis.................................ppt
bordetella pertussis.................................pptbordetella pertussis.................................ppt
bordetella pertussis.................................ppt
 
Leaf Initiation, Growth and Differentiation.pdf
Leaf Initiation, Growth and Differentiation.pdfLeaf Initiation, Growth and Differentiation.pdf
Leaf Initiation, Growth and Differentiation.pdf
 
role of pramana in research.pptx in science
role of pramana in research.pptx in sciencerole of pramana in research.pptx in science
role of pramana in research.pptx in science
 
GBSN - Microbiology (Lab 4) Culture Media
GBSN - Microbiology (Lab 4) Culture MediaGBSN - Microbiology (Lab 4) Culture Media
GBSN - Microbiology (Lab 4) Culture Media
 
nodule formation by alisha dewangan.pptx
nodule formation by alisha dewangan.pptxnodule formation by alisha dewangan.pptx
nodule formation by alisha dewangan.pptx
 

SPSF03 - Numerical Integrations

  • 1. 1 1 Programming, Computation, Simulation Applications in Math & Physics Numerical Integrations Syeilendra Pramuditya Department of Physics Institut Teknologi Bandung
  • 2. 2 Physics Problem  Period of Pendulum How Easy! 2 2 ( ) ( ) 2 1 2 d t t SHM dt g f l l T f g             
  • 3. 3 Physics Problem  Large Amplitude Pendulum..?
  • 4. 4 Physics Problem  Large Amplitude Pendulum..? sin g d d l           
  • 6. 6 Large Amplitude Pendulum Legendre Complete Elliptic Integral of the First Kind Trigonometric identities, change of variable, etc…
  • 7. 7 Large Amplitude Pendulum  Input  g, l, 0  Process  Evaluate the integral  Output  Period of the pendulum Small Amplitude 1 2 l T f g    Solution by series expansion Check your result
  • 8. 8 Do The Code  Benchmark your integrator code first 0 1 0 sin(30 ) 0.5 sin (0.5) 30   
  • 9. 9 9 Numerical Integration  Definite integral of f(t) on interval [a,b]  Analytic method: anti- derivative  F where F’(t) = f(t)  Iab = F(b) – F(a) ( ) ( ) ( ) ( ) b ab a F t I f t dt F b F a     
  • 10. 10 Hand Calculation?  Calculate until 2 decimal numbers?  a = 88/17  b = square-root of 23  c = ln(7)
  • 11. 11 11 Numerical Integration  ln7 = .. ?  ln5 = .. ? 7 5 1 ( ) 1 ln 7 ln5 ab f t t I dt t       Need to somehow calculate the numerical value of natural logarithm  Real-world functions don’t have anti derivatives  Direct calculation of definite integrals is needed
  • 12. 12 Numerical Integration  Newton-Cotes Formula  Composite Method  Quadrature Method  Riemann Sum  Etc…
  • 13. 13 13 Numerical Integration  Example: value of ln(1.2) 1 1 ln( ) x x dt t   1.2 1 1 ln(1.2) dt t    Ln(1.2) = area below the curve
  • 14. 14 14 Numerical Integration  General Formula 0 ( ) ( ) b n ab i i i a I f t dt f t w       f(ti) : function f evaluated at ti  wi : weighting factor
  • 16. 16 16 Rectangle Rule ( ) ( ) ( ) ( ) b ab i i a I f t dt f t w f a b a      
  • 17. 17 17 Midpoint Rule ( ) ( ) ( ) 2 b ab i i a a b I f t dt f t w f b a             
  • 18. 18 18 Trapezoid Rule     ( ) ( ) ( ) 2 b ab i i a f a f b I f t dt f t w b a       
  • 19. 19 19 Non-Linear Rule (Simpson) Approx. by 3-point Lagrange interpolation (Quadratic) 2 ( ) p x ax bx c   
  • 20. 20 20 Simpson Rule ( ) ( ) ( ) 4 ( ) 6 2 b ab i i a b a a b I f t dt f t w f a f f b                      Derived using integ. by substitution for 3-point Lagrange interpolation (Quadratic)
  • 21. 21 21 Simpson Rule 1 1 1 ( ) ( ) 4 ( ) 6 2 b N i i ab i i i a x x x I f x dx f x f f x                         Derived using integ. by substitution for 3-point Lagrange interpolation (Quadratic) N partitions
  • 22. 22 More Complex Integral 7.6 3.2 2 ( ) ln( ) ( ) 5 ab I f t dt x f t x    
  • 24. 24 Monte Carlo Integration 1 Average of 2, 8, 5, 12, 4 2 8 5 12 4 Average 5 1 ( ) ( ) ( ) 1 ( ) ( ) N b i a i b b b a b a a a f x f x N f x dx f x f x dx b a dx               Discrete Functions Continuous Functions
  • 25. 25 Monte Carlo Integration ( ) 1 ( ) ( ) b b b a b a a a f x dx f x f x dx b a dx       1 1 ( ) ( ) N b i a i f x f x N    1 ( ) ( ) ( ) ( ) b N b i a i a b a f x dx b a f x f x N         Rectangle of same area with original function
  • 26. 26 Do The Code: Monte Carlo Integration 5.7 1 1 ln(5.7) 1.74 dt t   
  • 27. 27 Do The Code: Monte Carlo Integration N ln(5.7) 10 1.669 20 1.914 40 1.622 80 1.872 160 1.819 320 1.690 640 1.693 1280 1.723 2560 1.739 1.600 1.650 1.700 1.750 1.800 1.850 1.900 1.950 1 10 100 1000 10000 N points Numerical Value 5.7 1 1 ln(5.7) 1.74 dt t   
  • 28. 28 Do The Code: Monte Carlo Integration 5.7 1 1 ln(5.7) 1.74 dt t    N ln(5.7) ln(5.7) ln(5.7) 10 1.669 2.087 1.651 20 1.914 1.936 1.670 40 1.622 2.043 1.901 80 1.872 1.787 1.759 160 1.819 1.675 1.789 320 1.690 1.777 1.653 640 1.693 1.726 1.705 1280 1.723 1.751 1.712 2560 1.739 1.738 1.740 1.500 1.600 1.700 1.800 1.900 2.000 2.100 2.200 1 10 100 1000 10000 N points Numerical value
  • 29. 29 Do The Code: Monte Carlo Integration 5.7 1 1 ln(5.7) 1.74 dt t    1 1.2 1.4 1.6 1.8 2 2.2 2.4 2.6 2.8 0 20 40 60 80 100 N=10 N=160 N=2560
  • 30. 30 Do The Code: Monte Carlo Integration 7.6 3.2 2 ( ) ln( ) ( ) 5 ab I f t dt x f t x    
  • 31. 31 Sample Problem A variable force is applied to an initially stationary box of mass 2.35 kg at x= 0 m. The box moves in +x direction due to the applied force. What is the speed of the box when its position is at x = 7.53 m? The surface is frictionless. 2 ˆ ( ) 5 sin ( rad) F x x x i N    2 2 1 1 2 2 2 2 1 1 ( ) ( )cos(0) 1 ( ) 5 sin ( ) 2 f i x x f x x x x f x x K K K W K F x dx F x dx mv F x dx x x dx               
  • 32. 32 The Integral 2 2 1 5 sin ( ) x x I x x dx    Gnuplot set xrange [0:10] set xrange [0:20] plot x*(sin(x))**2
  • 33. 33 Practice  Develop your integrator code using Simpson rule in Pascal language  The code mainly evaluates numerically:  What is the final speed of the box?  Using 75 partitions 2 2 1 5 sin ( ) x x I x x dx   