AI Lagrangian Mechanics Calculator

AI-Powered Step-by-Step Lagrangian & Hamiltonian D3 Animations Free · No Signup

Describe a system in plain English ("pendulum hanging from a spring", "mass on a cone") and AI fills in the kinetic energy T, potential V, coordinates, and initial conditions — or type them yourself. Our symbolic engine derives Euler-Lagrange equations, the Hamiltonian, and conservation laws, runs RK45 integration, and animates the motion with phase portraits and energy plots. AI only writes the strings; every calculation is ours.

Lagrangian Mechanics

AI writes T, V, coords, and initial conditions. All physics (Euler-Lagrange, Hamiltonian, conservation laws, integration) is computed by our engine.

Use dq for time derivative of q (e.g. dtheta for θ̇)
Comma-separated for multiple DOF
Enter T and V above…

Coordinates: theta, r, x, phi
Velocities: dtheta, dr, dx (prefix d for time derivative)
Powers: x^2, dtheta^2
Trig: sin(theta), cos(phi)
Multiplication: Use * explicitly: m*g*l not mgl
Parameters: m=1, g=9.8, l=1, k=5
Initial conditions: theta(0)=0.3, dtheta(0)=0

L = Lagrangian = T − V
T = Kinetic energy
V = Potential energy
q, q̇ = Generalized coordinate, velocity
p = Conjugate momentum = ∂L/∂q̇
H = Hamiltonian = Σpii − L
EOM = d/dt(∂L/∂q̇) − ∂L/∂q = 0

Euler-Lagrange Derivation

Enter T and V, then click Compute

Derive Euler-Lagrange equations, Hamiltonian, conservation laws, and numerical solutions.

Compute a system to see plots.

t = 0.00 s

Compute a system to see the animation.

Hamiltonian Mechanics

Compute a system to see the Hamiltonian formulation.

What is Lagrangian Mechanics?

Lagrangian mechanics is a reformulation of classical mechanics introduced by Joseph-Louis Lagrange in 1788. Instead of forces and accelerations (Newton), it uses energy as the fundamental quantity. The Lagrangian L = T − V (kinetic minus potential energy) encodes all the dynamics of a system.

By applying the principle of least action (Hamilton's principle), we derive the Euler-Lagrange equations — the equations of motion — which are equivalent to Newton's second law but far more powerful for constrained systems, curved geometries, and systems with many degrees of freedom.

Key Concepts

Euler-Lagrange Equation

d/dt(∂L/∂q̇) − ∂L/∂q = 0. This second-order ODE gives the equation of motion for each generalized coordinate q.

Noether's Theorem

Every continuous symmetry of the action yields a conservation law. Time invariance → energy conservation, spatial invariance → momentum conservation.

Hamiltonian Mechanics

H = Σpii − L. Hamilton's equations q̇ = ∂H/∂p and ṗ = −∂H/∂q give first-order equations in phase space.

Generalized Coordinates

Any independent variables that fully describe a system's configuration. Constraints are built into the coordinates, eliminating constraint forces entirely.

Applications

🎨

Celestial Mechanics

Kepler orbits, three-body problem, and orbital mechanics are naturally expressed in Lagrangian form with polar coordinates.

Robotics

Multi-link robot arms are modeled with joint angles as generalized coordinates. Lagrangian methods handle complex constraints elegantly.

📈

Quantum Mechanics

The Lagrangian formulation underlies Feynman's path integral approach and the Standard Model of particle physics.

📚

Coupled Oscillations

Normal modes of vibration in molecules, crystals, and mechanical systems are found systematically using the Lagrangian approach.

Frequently Asked Questions

The Lagrangian L is defined as the difference between kinetic energy T and potential energy V: L = T - V. It is a scalar function of generalized coordinates, their time derivatives, and time. The Lagrangian formulation provides an elegant alternative to Newtonian mechanics for deriving equations of motion.
The Euler-Lagrange equation is d/dt(dL/dq_dot) - dL/dq = 0, where q is a generalized coordinate and q_dot is its time derivative. This equation yields the equations of motion for the system. For a system with n degrees of freedom, there are n Euler-Lagrange equations.
The Hamiltonian H is obtained from the Lagrangian via a Legendre transformation: H = sum(p_i * q_dot_i) - L, where p_i = dL/dq_dot_i are the conjugate momenta. For conservative systems where L does not depend explicitly on time, H equals the total energy T + V.
Noether's theorem states that every continuous symmetry of the Lagrangian corresponds to a conserved quantity. For example, time translation symmetry gives conservation of energy, spatial translation symmetry gives conservation of momentum, and rotational symmetry gives conservation of angular momentum.
Generalized coordinates are any set of independent parameters that completely describe the configuration of a mechanical system. Unlike Cartesian coordinates, they can be angles, distances, or any convenient variables. For a simple pendulum, the angle theta is a natural generalized coordinate instead of x and y.
The double pendulum is a classic example of a chaotic system. Its equations of motion are nonlinear coupled differential equations. For small oscillations it behaves predictably, but for larger amplitudes, tiny differences in initial conditions lead to dramatically different trajectories over time.
A phase portrait plots a system's generalized coordinate q against its conjugate momentum p (or velocity q_dot). Each point represents a complete state of the system. Trajectories in phase space reveal the system's qualitative behavior: closed orbits indicate periodic motion, fixed points indicate equilibria.
Yes, this calculator is completely free with no signup required. You get symbolic derivation of Euler-Lagrange equations, Hamiltonian mechanics, conservation laws, numerical integration, interactive D3 animations, and Plotly phase portraits.

🔥 Explore More Physics

y'

ODE Solver Calculator

Solve first & second-order ODEs with steps and direction fields

Inclined Plane Calculator

Forces, acceleration & friction on inclined planes

Laplace Transform Calculator

Forward & inverse Laplace transforms with steps

Support This Free Tool

Every coffee helps keep the servers running. Every book sale funds the next tool I'm dreaming up. You're not just supporting a site — you're helping me build what developers actually need.

500K+ users
200+ tools
100% private
Privacy Guarantee: Private keys you enter or generate are never stored on our servers. All tools are served over HTTPS.