Fourier Method PDE Solver
The Fourier Method PDE Solver solves the 1D heat equation \\( \frac{\partial u}{\partial t} = \alpha \frac{\partial^2 u}{\partial x^2} \\) with boundary conditions \\( u(0,t) = u(L,t) = 0 \\) and initial condition \\( u(x,0) = f(x) \\), using the Fourier series method, visualizing the solution with p5.js and displaying steps with MathJax.
Fourier Method PDE Solver
The Fourier Method PDE Solver computes the solution to the 1D heat equation \\( \frac{\partial u}{\partial t} = \alpha \frac{\partial^2 u}{\partial x^2} \\) with boundary conditions \\( u(0,t) = u(L,t) = 0 \\) and initial condition \\( u(x,0) = f(x) \\), using the Fourier series method (separation of variables). Input the domain length, thermal diffusivity, initial condition (as a function like sin(pi*x)), time, number of Fourier terms, and grid points. The solution is visualized with p5.js, and steps are shown with MathJax. Results can be shared or embedded.
Example 1: Single Sine Wave
Parameters: \\( L = 1 \\), \\( \alpha = 0.1 \\), \\( f(x) = \sin(\pi x) \\), \\( t = 0.5 \\), \\( N = 10 \\), \\( M = 100 \\).
Step 1: Compute Fourier coefficients.
Step 2: Form solution \\( u(x,t) = \sum_{n=1}^N b_n \sin(n \pi x / L) e^{-\alpha (n \pi / L)^2 t} \\).
Result: A decaying sine wave.
Example 2: Higher Diffusivity
Parameters: \\( L = 1 \\), \\( \alpha = 0.5 \\), \\( f(x) = \sin(\pi x) \\), \\( t = 0.2 \\), \\( N = 10 \\), \\( M = 100 \\).
Higher \\( \alpha \\) causes faster decay of the solution.
Example 3: Multiple Sine Terms
Parameters: \\( L = 1 \\), \\( \alpha = 0.1 \\), \\( f(x) = \sin(\pi x) + 0.5 \sin(3 \pi x) \\), \\( t = 0.3 \\), \\( N = 10 \\), \\( M = 100 \\).
The solution includes multiple Fourier modes.
Example 4: Longer Domain
Parameters: \\( L = 2 \\), \\( \alpha = 0.1 \\), \\( f(x) = \sin(\pi x / 2) \\), \\( t = 0.5 \\), \\( N = 10 \\), \\( M = 100 \\).
A larger \\( L \\) stretches the solution spatially.
Example 5: Later Time
Parameters: \\( L = 1 \\), \\( \alpha = 0.1 \\), \\( f(x) = \sin(\pi x) \\), \\( t = 1.0 \\), \\( N = 10 \\), \\( M = 100 \\).
At later times, the solution decays significantly due to the exponential term.