Heat Equation
Heat Equation
The 1D heat equation describes how temperature diffuses through a material:
where is the thermal diffusivity.
Separation of Variables
For the rod with Dirichlet boundary conditions and initial condition , the solution is:
Fourier Coefficients
The Fourier sine coefficients are determined by projecting the initial condition onto the sine basis:
Each mode decays exponentially in time with rate . High-frequency modes decay fastest — this is why heat smooths out sharp features rapidly.
Numerical Integration
Given sampled on a uniform grid of interior points for , approximate the integral with the rectangle rule:
where .
Example
For , only is nonzero (all other ), giving:
The temperature profile maintains its sinusoidal shape but decays uniformly.
Your Task
Implement heat_coefficient_Bn(f_values, L, n, N_grid=100) where f_values is a list of interior sample values. Implement heat_solution(x, t, alpha, L, Bn_list) that evaluates the series given a precomputed list . Implement heat_series(x, t, alpha, L, f_values, N_terms=10) that computes coefficients and evaluates the solution in one call.