Solution (source code)

= Solution

For a slender <elastic beam> undergoing small bending, cross-sections remain approximately plane and perpendicular to the centreline. At distance $z$ from the <neutral axis>, longitudinal <strain> is $\epsilon_{xx}=-z\kappa$, where $\kappa$ is <curvature>. <Linear elasticity> gives $\sigma_{xx}=E\epsilon_{xx}$, so the <bending moment> has magnitude
$$
M=EI\kappa,\qquad I=\int_A z^2\,dA.
$$
Here $I$ is the second moment of cross-sectional <area>, not a <mass> <moment of inertia>. For width $b$ and depth $h$ in the bending direction, $I=bh^3/12$. The cubic depth dependence explains why a deep beam resists bending more effectively than the same material spread sideways.

For a uniform beam with transverse <displacement> $y(x)$, $\kappa\simeq y''$ and bending <energy> is $\tfrac12\int EI(y'')^2dx$. Balancing transverse load $q(x)$ yields the <Euler-Bernoulli beam equation> $EIy''''=q$ under a consistent sign convention. Supports specify values of deflection, slope, moment or shear; the equation alone does not fix the response.

Now apply a compressive end load $P>0$. A small deflection shortens the axial projection by $\tfrac12\int(y')^2dx$, so the total <potential energy> relative to the straight configuration is
$$
\Pi[y]=\frac12\int_0^\ell\left[EI(y'')^2-P(y')^2\right]dx.
$$
Its stationary equation is
$$
EIy''''+Py''=0.
$$
For pinned ends, $y(0)=y(\ell)=0$ and the end moments vanish, so $y''(0)=y''(\ell)=0$. The candidate shapes $y=A\sin(n\pi x/\ell)$ require $P=EI(n\pi/\ell)^2$. The first loss of stability is consequently
$$
\boxed{P_{\mathrm{cr}}=\frac{\pi^2EI}{\ell^2}\quad\text{for a pinned–pinned strut}.}
$$
At smaller $P$, the quadratic <energy> is positive; beyond this threshold the straight configuration no longer minimizes it. End restraint changes the threshold: clamped–clamped gives $4\pi^2EI/\ell^2$ and clamped–free gives $\pi^2EI/(4\ell^2)$, equivalently an effective-length correction. A column buckles in the direction of smaller flexural rigidity. Euler buckling is a geometric instability within elastic response; yielding or crushing can occur first for a short thick strut. Large deflections, shear deformation and imperfections require refinements of the ideal slender-beam model.