The one-dimensional heat equation governs how temperature evolves along a thin rod. The parameter represents thermal diffusivity. With fixed temperatures at both ends of the rod, the solution illustrates diffusion and smoothing phenomena that appear across physics and engineering.
Analytic solutions exist for simple boundary conditions, often using Fourier series expansions. However, many real-world scenarios require numerical methods. This calculator employs an explicit finite difference scheme, updating the temperature at each interior point using where . Stability demands . By discretizing space and time, we approximate how heat diffuses from the initial temperature profile.
We divide the interval into segments with spacing . Time advances in steps of chosen so that satisfies the stability condition. The algorithm starts by sampling the initial temperature at each grid point. At each time step, boundary values remain zero (or more generally, fixed), while interior points are updated via the explicit formula above. After steps, the resulting array approximates .
Because depends on both and , finer spatial grids require smaller time steps for stability. The explicit scheme is conceptually simple but not the most efficient for stiff problems; still, it provides an excellent introduction to numerical PDEs and is adequate for moderate resolutions, as implemented here.
If the rod starts with temperature distribution and zero boundary conditions, the analytic solution separates into exponentially decaying Fourier modes. Our calculator can reproduce this behavior numerically. You will see that the sinusoidal shape flattens over time as energy dissipates through the boundaries. By experimenting with different initial functions, you can explore how diffusion smooths sharp features and transports heat from hotter regions to cooler ones.
The same equation also models other processes, from pollutant diffusion in soil to the pricing of certain financial derivatives. As such, learning to approximate solutions has wide-reaching applications. Understanding stability conditions and discretization error builds foundational skills for computational science. This calculator aims to make the subject approachable by providing instant numerical results alongside a concise explanation of the underlying method.
Real rods rarely have both ends locked at zero temperature. Sometimes one end is held at a fixed nonzero value, while the other might be insulated or exposed to ambient air. To explore such scenarios the solver allows custom boundary values. Enter the temperatures for the left and right ends and observe how they influence the interior profile over time. Because the explicit scheme updates interior points using neighbors, the boundaries act like anchors that gradually pull the solution toward their values. If both ends differ, a steady linear gradient eventually forms after the initial transients dissipate.
The algorithm automatically picks a time step small enough to satisfy the stability constraint 0.4 Δx²/α. Rather than overshoot the requested final time, it divides the total time into an integer number of steps and recomputes the actual Δt so that the simulation ends exactly at t. This subtle adjustment prevents the solution from drifting past the target horizon, a common pitfall in naive implementations. The choice of 0.4 is conservative; the theoretical limit is 0.5, but leaving extra margin guards against rounding error and variations in α or Δx.
The result list reports temperatures at each grid point from left to right. Interpreting the numbers is easier if you imagine plotting them: peaks flatten, valleys rise, and the curve gradually smooths. For pedagogical purposes, consider exporting the array to a spreadsheet or plotting library to visualize the diffusion. Seeing the evolution as a movie reinforces the idea that heat flow equalizes differences over time.
Suppose a one-meter rod begins with temperature u(x,0) = sin(πx), the left end is held at 10°C, and the right end at 0°C. Set L = 1, α = 1, t = 0.1, initial function sin(pi*x), and boundary values 10 and 0. The computed array might start with a value near 10 at the left, decrease according to the sine curve, and end near 0 on the right. After running the solver, you will notice the peak around the center shift downward as heat drains toward the cooler right boundary while the left end remains warm. Increasing t to 1.0 reveals the long-term trend: the interior approaches a straight line connecting 10 and 0 as the sine component decays.
Explicit finite difference schemes are easy to implement but can suffer from numerical error if parameters are poorly chosen. If you halve the spatial step while keeping α and t fixed, the time step also decreases, increasing computational cost. However, the finer grid produces a solution closer to the true analytic answer. Users can experiment by doubling the number of spatial steps and comparing outputs; the difference between successive refinements gives a practical sense of discretization error.
The heat equation embodies energy conservation: the rate of temperature change at a point equals the net flux of heat into that point. Our discrete update mirrors this principle. Each interior node receives contributions from its neighbors and loses some of its own heat proportionally, ensuring that no energy is magically created or destroyed within the model. If the boundaries are equal and the initial profile has zero integral, the sum of all grid values remains approximately zero throughout the simulation, up to rounding errors.
The one-dimensional solver is a stepping stone to more complex scenarios. Two-dimensional diffusion on a plate or three-dimensional conduction in a block follow similar patterns but require updating each point based on more neighbors. Extensions might incorporate spatially varying diffusivity, internal heat sources, or nonlinear terms modeling phase changes. By grasping the simple case, you lay the groundwork for tackling these advanced systems.
Jean-Baptiste Joseph Fourier introduced the heat equation in the early 1800s while studying how heat spreads through solids. His groundbreaking work on trigonometric series provided the analytic tools that still underpin modern solution techniques. Numerical approaches like the one in this calculator became practical only with the rise of digital computers in the twentieth century. Today finite difference and finite element methods solve enormous heat transfer problems in engineering, climate science, and even finance, where similar equations govern option pricing.
To get the most from this calculator, start with simple cases where analytic solutions are known, such as sine or cosine initial profiles, and verify the numerical output matches expectations. Then move to custom functions using math.js syntax—polynomials, exponentials, or piecewise definitions. If results seem erratic, check that your diffusivity and step counts produce a stable Δt; the caution message will appear otherwise. Finally, remember that units matter: if L is measured in meters and α in m²/s, then t is seconds and the boundary values are in degrees Celsius or Kelvin consistently.
Although this page focuses on a one-dimensional rod, similar diffusion processes govern everyday phenomena like the spread of aromas in a room or groundwater contamination in soil. Computational tools scale up by arranging grid points in matrices and applying analogous update rules in both x and y directions. Mastery of the simple rod therefore unlocks an understanding of much richer diffusion dynamics.
With customizable boundaries, automatic time-step control, and a clear report of grid-point values, this enhanced solver offers a practical laboratory for diffusion problems. The extended explanation walks through theory, computation, and historical context, inviting you to experiment and build intuition. Whether you are a student checking homework, an engineer prototyping a concept, or a curious reader exploring partial differential equations for the first time, the tool aims to make the mathematics of heat flow tangible.
Once solved, copy the temperature array into a spreadsheet or plotting tool to visualize diffusion. Saving datasets from multiple runs helps students explore stability and convergence.
Numerically solve the 2D Poisson equation on a unit square with zero boundary conditions.
Solve the one-dimensional wave equation with fixed ends using a finite difference method.
Solve one-variable linear equations of the form ax + b = c with step-by-step results.