Problem: Solving a Differential Equation with Boundary Conditions
In applied mathematics, differential equations model physical systems such as heat transfer, population dynamics, or mechanical vibrations.
This example demonstrates solving a second-order differential equation using boundary conditions.
Problem Statement
Solve the differential equation:
$$
\frac{d^2y}{dx^2} - y = 0
$$
with the boundary conditions:
$$
y(0) = 1, \quad y(1) = 2
$$
Python Code
1 | import numpy as np |
Explanation of the Code
Equation Definition:
- The second-order equation is converted into a system of first-order equations:
$$
y_1 = y, \quad y_2 = y’
$$
Resulting in:
$$
y_1’ = y_2, \quad y_2’ = y_1
$$
- The second-order equation is converted into a system of first-order equations:
Boundary Conditions:
- The boundary conditions $y(0) = 1$ and $y(1) = 2$ are applied.
Numerical Solution:
- The
scipy.integrate.solve_bvp
function numerically solves the boundary value problem ($BVP$).
- The
Visualization:
- The computed solution is plotted as a smooth curve.
- The boundary conditions are highlighted as red dots.
Results and Insights
The plot shows the solution $y(x)$ that satisfies the differential equation and the boundary conditions.
The method used is efficient for solving linear and nonlinear boundary value problems commonly encountered in engineering and applied sciences.