Home > Python > Introduction to Scipy

Ch. 10.1 Integration

Chapters Index
Program 1

Integration

Python 3.11 Ready

                                
Click "Run Code" to execute script and render figures.

Mathematical Problem Formulation

Single Definite Integral

Integrating a simple function \( f(x) = x^2 \) over the interval [0, 1]:

\[ \int_0^1 x^2 \, dx \]

Program 2

Integration

Python 3.11 Ready

                                
Click "Run Code" to execute script and render figures.

Mathematical Problem Formulation

Indefinite Integral Example

Let the function be defined as:

\[ f(x) = e^{-x^2} \]

The indefinite integration of this function over the range \( [0, \infty] \) is:

\[ \int_0^{\infty} e^{-x^2} \, dx \]

This integral has a known solution, which is \( \frac{\sqrt{\pi}}{2} \).

Program 3

Integration

Python 3.11 Ready

                                
Click "Run Code" to execute script and render figures.

Mathematical Problem Formulation

Double Integral

Integrating a function \( f(x, y) = x \cdot y \) over the region \([0, 1]\) for both \( x \) and \( y \), we have:

\[ \int_0^1 \int_0^1 x \cdot y \, dx \, dy \]

In this case, the result of the double integral is:

\[ \left( \int_0^1 x \, dx \right) \cdot \left( \int_0^1 y \, dy \right) = \frac{1}{2} \cdot \frac{1}{2} = \frac{1}{4} \]

Program 4

Integration

Python 3.11 Ready

                                
Click "Run Code" to execute script and render figures.

Mathematical Problem Formulation

Triple Integral

Triple integration of the function \( f(x, y, z) = x \cdot y \cdot z \) over the range \([0, 1]\) for all three variables is expressed as:

\[ \int_0^1 \int_0^1 \int_0^1 x \cdot y \cdot z \, dx \, dy \, dz \]

To solve this triple integral, we first evaluate the integrals for each variable:

\[ \left( \int_0^1 x \, dx \right) \cdot \left( \int_0^1 y \, dy \right) \cdot \left( \int_0^1 z \, dz \right) = \frac{1}{8} \]

Program 5

Integration

Python 3.11 Ready

                                
Click "Run Code" to execute script and render figures.

Mathematical Problem Formulation

Double Integral with Custom Range

Let the function be defined as:

\[ f(x, y) = \sin(x) \cdot \cos(y) \]

We can perform double integration of this function over the range:

\[ \int_0^{\pi} \int_0^{\frac{\pi}{2}} \sin(x) \cdot \cos(y) \, dy \, dx \]

Program 6

Integration

Python 3.11 Ready

                                
Click "Run Code" to execute script and render figures.

Mathematical Problem Formulation

Double Integral Example

Let the function be defined as:

\[ f(x, y) = x^2 y + xy^2 \]

We can perform double integration of this function over the following ranges:

  • For \( x \) from 0 to 1
  • For \( y \) from 0 to 2 (with the bounds depending on \( x \))

The double integral can be expressed as:

\[ \int_0^1 \int_0^2 (x^2 y + xy^2) \, dy \, dx \]

Theoretical Principles & Computational Physics Guide

Integration: Computational Physics Modeling & Analysis

Dr. Alorika Chatterjee & Dr. Anirban Shaw Science & Physics Learners Python 3 / NumPy / SciPy

1. Core Principles & Theoretical Framework

Core Concept: Computational formulation and simulation of Integration within the study of Introduction to Scipy.
Algorithmic Translation: Translates theoretical governing equations into clean, discrete Python procedures and verified numerical solvers.
Numerical Verification: Evaluates numerical accuracy, parameter sensitivity, and error bounds for reliable computational results.

2. Mathematical Formulation & Algorithmic Pipeline

Governing computational formulation for Integration:

$$ \mathcal{F}_{\text{model}}(\mathbf{x}, t; \mathbf{p}) = 0 \implies \mathbf{y}_{n+1} = \mathcal{S}(\mathbf{y}_n, \Delta t, \mathbf{p}) $$
1. Define Physical Parameters & Boundaries → 2. Execute Numerical Simulation Steps → 3. Evaluate Observables & Plot Results

3. Numerical Mechanics & Implementation Logic

  • Parameter Initialization: Set physical constants, initial states, and coordinate boundary bounds for Integration.
  • Step Execution: Advance the computational state using optimized vector operations and scientific libraries.
  • Convergence Control: Monitor stability and ensure simulation metrics remain physically meaningful.

4. Relevant Computational Practice Exercises

Exercise 1
Implement Integration and observe how the output responds to variations in primary physical parameters.
Exercise 2
Refine the calculation grid or step size to observe convergence and reduction in numerical approximation error.
Exercise 3
Compare the simulated computational results against an analytical benchmark or limiting physical case.
Standard Literature & References:
  • Mark Newman, "Computational Physics", University of Michigan (2013).
  • Hans Petter Langtangen, "A Primer on Scientific Programming with Python", Springer (2016).