Quick answer. For a prismatic beam element of length \(L\) and bending stiffness \(EI\), with end displacements \((v_1,\theta_1,v_2,\theta_2)\), the element stiffness matrix is
$$\mathbf{k}=\frac{EI}{L^3}\begin{bmatrix}12 & 6L & -12 & 6L\\ 6L & 4L^2 & -6L & 2L^2\\ -12 & -6L & 12 & -6L\\ 6L & 2L^2 & -6L & 4L^2\end{bmatrix},$$so the individual stiffness terms are \(12EI/L^3\), \(6EI/L^2\), \(4EI/L\) and \(2EI/L\). A uniform load \(w\) on the member enters through its fixed-end forces \(wL/2\) and \(wL^2/12\).
1. Degrees of freedom and sign convention
A plane beam element has two nodes and two degrees of freedom at each: a transverse deflection \(v\) and a rotation \(\theta\). StiffStruct orders them \(\mathbf{u}'=[v_1,\theta_1,v_2,\theta_2]^T\). Deflections are positive upward (local \(+y\)), rotations positive counter-clockwise, and the matching end forces \(\mathbf{q}'=[V_1,M_1,V_2,M_2]^T\) are the shears and moments acting on the member in those same positive directions. The internal bending moment drawn in the diagrams is a different quantity: it is sagging-positive, so at the right end of a member it equals \(M_2\) and at the left end it equals \(-M_1\). The full conventions are in the theory notes, sections 2 and 3.
2. What each entry means: unit displacement columns
Column \(c\) of \(\mathbf{k}\) is the set of end forces that holds the element in a shape where displacement \(c\) equals one and the other three are zero. Reading the matrix column by column gives each term a physical meaning:
| Imposed displacement | End forces (one column of k) | What it says |
|---|---|---|
| \(v_1=1\) | \(\tfrac{12EI}{L^3},\ \tfrac{6EI}{L^2},\ -\tfrac{12EI}{L^3},\ \tfrac{6EI}{L^2}\) | Sliding one end sideways with both ends kept level needs equal and opposite shears and two equal end moments. |
| \(\theta_1=1\) | \(\tfrac{6EI}{L^2},\ \tfrac{4EI}{L},\ -\tfrac{6EI}{L^2},\ \tfrac{2EI}{L}\) | Rotating one end needs \(4EI/L\) there and induces \(2EI/L\) at the fixed far end: a carry-over factor of one half. |
| \(v_2=1\) | \(-\tfrac{12EI}{L^3},\ -\tfrac{6EI}{L^2},\ \tfrac{12EI}{L^3},\ -\tfrac{6EI}{L^2}\) | The mirror image of the first column. |
| \(\theta_2=1\) | \(\tfrac{6EI}{L^2},\ \tfrac{2EI}{L},\ -\tfrac{6EI}{L^2},\ \tfrac{4EI}{L}\) | The mirror image of the second column. |
Every column is in equilibrium on its own: the two shears cancel, and \(M_1+M_2+V_2L=0\). The matrix is symmetric (Maxwell’s reciprocal theorem) and singular, because a rigid translation \([1,0,1,0]\) or a rigid rotation \([0,1,L,1]\) needs no force at all. That singularity is why supports must be applied before a beam can be solved.
3. Derivation from Hermite shape functions
Inside the element the deflection is interpolated with cubic polynomials, the lowest order that can match a deflection and a slope at each end. With \(s=x/L\):
$$v(x)=N_1v_1+N_2\theta_1+N_3v_2+N_4\theta_2,\qquad \begin{aligned}N_1&=1-3s^2+2s^3, & N_2&=L(s-2s^2+s^3),\\ N_3&=3s^2-2s^3, & N_4&=L(s^3-s^2).\end{aligned}$$Each \(N_a\) equals one for its own degree of freedom and zero for the other three. The curvature is \(v''=\mathbf{N}''\mathbf{u}'\), and the bending strain energy \(U=\tfrac12\int_0^L EI\,(v'')^2\,dx\) becomes \(\tfrac12\,\mathbf{u}'^T\mathbf{k}\,\mathbf{u}'\) with
$$\mathbf{k}=\int_0^L EI\,\mathbf{N}''^{T}\,\mathbf{N}''\,dx,\qquad\text{for example}\quad k_{22}=\int_0^L EI\left(\frac{-4+6s}{L}\right)^{2}dx=\frac{4EI}{L}.$$Carrying out all sixteen integrals reproduces the matrix in the quick answer. We checked this two ways: symbolically, and numerically with a three-point Gauss rule for \(L=5\), which matched the closed form to \(2\times10^{-16}\). The same shape functions give the work-equivalent loads: \(\int_0^L\mathbf{N}\,dx=[L/2,\ L^2/12,\ L/2,\ -L^2/12]\), which is where the uniform-load terms in section 5 come from. Because the cubics are the exact solution of \(EI\,v''''=0\), one element per span is exact for an Euler–Bernoulli beam; there is no mesh to refine.
4. Assembling a global stiffness matrix for a beam
Take a beam with nodes A, B and C and two elements, AB of length \(L_1\) and BC of length \(L_2\). The structure has six degrees of freedom, \([v_A,\theta_A,v_B,\theta_B,v_C,\theta_C]\). Element 1 maps to global positions 1 to 4 and element 2 to positions 3 to 6, so the two matrices overlap in the \(2\times2\) block at node B, where their entries add:
$$\mathbf{K}=\begin{bmatrix}k^{(1)}_{11} & k^{(1)}_{12} & k^{(1)}_{13} & k^{(1)}_{14} & 0 & 0\\ & k^{(1)}_{22} & k^{(1)}_{23} & k^{(1)}_{24} & 0 & 0\\ & & k^{(1)}_{33}+k^{(2)}_{11} & k^{(1)}_{34}+k^{(2)}_{12} & k^{(2)}_{13} & k^{(2)}_{14}\\ & & & k^{(1)}_{44}+k^{(2)}_{22} & k^{(2)}_{23} & k^{(2)}_{24}\\ & \text{sym.} & & & k^{(2)}_{33} & k^{(2)}_{34}\\ & & & & & k^{(2)}_{44}\end{bmatrix}.$$For example, the rotational stiffness at B is \(4EI/L_1+4EI/L_2\): both spans resist a rotation of the shared joint. Supports are applied next. A roller or pin fixes \(v\) at that node; a fixed end fixes \(v\) and \(\theta\). Partitioning \(\mathbf{K}\) into free (f) and supported (s) degrees of freedom leaves the system that is actually solved, \(\mathbf{K}_{ff}\mathbf{U}_f=\mathbf{P}_f-\mathbf{FEF}_f-\mathbf{K}_{fs}\mathbf{U}_s\). The last term is zero unless a support settles.
5. Fixed-end forces and equivalent nodal loads
The stiffness matrix only knows about forces at nodes, so a load along a member is handled in two steps. First, clamp both ends and find the end forces that hold the loaded member: the fixed-end forces \(\mathbf{q}_F\). For a downward uniform load \(w\) over the whole length,
$$\mathbf{q}_F=\left[\ \frac{wL}{2},\ \ \frac{wL^2}{12},\ \ \frac{wL}{2},\ \ -\frac{wL^2}{12}\ \right]^T\quad(\text{upward shears, counter-clockwise moment at node 1}).$$Second, release the clamps. The joints receive the reversed forces \(-\mathbf{q}_F\), the equivalent nodal loads, and the structure is solved for the joint displacements. The real member end forces are the sum of the two stages:
$$\mathbf{q}'=\mathbf{k}\,\mathbf{d}+\mathbf{q}_F .$$Forgetting \(\mathbf{q}_F\) in this last step is the most common error in hand solutions. The displacements come out right, but every end moment is wrong by exactly the fixed-end moment. Closed forms for point, triangular and moment loads are listed in section 7.2 of the theory notes.
6. Worked example: a two-span beam solved by hand
The beam of the example “Two-span beam: UDL and settlement” has spans \(L_1=5\) m (A to B) and \(L_2=6\) m (B to C), simple vertical supports at A, B and C, and a downward load \(w=20\) kN/m on both spans. The section is an IPE 360 in S275 steel: \(E=210\) GPa and \(I=1.627\times10^{-4}\ \mathrm{m^4}\), so \(EI=34\,167\ \mathrm{kN\,m^2}\).
Free degrees of freedom. All three deflections are supported, so the unknowns are \(\theta_A,\theta_B,\theta_C\). Their rows and columns of the assembled matrix are
$$\mathbf{K}_{ff}=EI\begin{bmatrix}\tfrac45 & \tfrac25 & 0\\ \tfrac25 & \tfrac45+\tfrac46 & \tfrac26\\ 0 & \tfrac26 & \tfrac46\end{bmatrix}=EI\begin{bmatrix}0.8 & 0.4 & 0\\ 0.4 & 1.4667 & 0.3333\\ 0 & 0.3333 & 0.6667\end{bmatrix}.$$Load vector. The fixed-end moments are \(wL_1^2/12=41.667\) kN·m and \(wL_2^2/12=60\) kN·m. At A only span AB contributes \(+41.667\); at B the two spans give \(-41.667+60=18.333\); at C span BC gives \(-60\). With no joint loads the right-hand side is \(-\mathbf{FEF}_f=[-41.667,\ -18.333,\ 60]^T\) kN·m.
Solve. \(EI\,\theta_A=-39.583\), \(EI\,\theta_B=-25.0\), \(EI\,\theta_C=102.5\) kN·m², that is \(\theta_A=-0.001159\), \(\theta_B=-0.000732\), \(\theta_C=+0.003000\) rad.
Member end forces from \(\mathbf{q}'=\mathbf{k}\mathbf{d}+\mathbf{q}_F\):
| Member | \(\mathbf{k}\mathbf{d}\) (kN, kN·m) | \(\mathbf{q}_F\) | \(\mathbf{q}'=[V_1,M_1,V_2,M_2]\) |
|---|---|---|---|
| AB, 5 m | \([-15.5,\ -41.667,\ 15.5,\ -35.833]\) | \([50,\ 41.667,\ 50,\ -41.667]\) | \([34.5,\ 0,\ 65.5,\ -77.5]\) |
| BC, 6 m | \([12.917,\ 17.5,\ -12.917,\ 60]\) | \([60,\ 60,\ 60,\ -60]\) | \([72.917,\ 77.5,\ 47.083,\ 0]\) |
The end moments at A and C are zero, as they must be at simple end supports. The moment over B is \(-77.5\) kN·m (hogging), the same as the three-moment equation \(M_B=-w(L_1^3+L_2^3)/[8(L_1+L_2)]\). The reactions are \(R_A=34.5\) kN, \(R_B=65.5+72.917=138.417\) kN and \(R_C=47.083\) kN, which add up to the total load \(20\times11=220\) kN. The largest span moments are 29.76 kN·m at 1.725 m from A and 55.42 kN·m at 2.354 m from C. These numbers were checked with a short numpy script that assembles the full \(6\times6\) matrix.
The same model has a second load case, a 12 mm settlement of B. There \(\mathbf{U}_s\) is no longer zero and the \(-\mathbf{K}_{fs}\mathbf{U}_s\) term drives the solution; it changes the moment over B by \(+41.0\) kN·m, which relieves the hogging moment.
Solving the example in your browser…
7. Frame elements, shear deformation and 3D beams
Adding an axial bar \((EA/L)[1,-1;-1,1]\) to the beam matrix gives the 6×6 plane frame element \([u_1,v_1,\theta_1,u_2,v_2,\theta_2]\), which is rotated into global axes for inclined members; a portal frame example shows it in use. For a deep, short member, shear deformation adds flexibility. The Timoshenko version uses \(\Phi=12EI/(\kappa GAL^2)\): the \(12\) and \(6L\) terms are divided by \(1+\Phi\) and the \(4L^2\) and \(2L^2\) terms become \((4+\Phi)L^2\) and \((2-\Phi)L^2\), also over \(1+\Phi\). It reduces to the matrix above when \(\Phi\to0\). StiffStruct uses the Euler–Bernoulli form, which is accurate for ordinary span-to-depth ratios. A 3D beam has six degrees of freedom per node and a 12×12 matrix built from an axial bar, a torsion bar and the bending matrix about each principal axis.
See the matrices of a real beam
Open this beam in the calculator to see the element matrices, the assembled stiffness matrix, the fixed-end forces and the solved displacements in the step-by-step report, or build a beam of your own.
Frequently asked questions
What is the stiffness matrix of a beam element?
It is the 4x4 matrix that relates the end deflections and rotations of a prismatic beam (v1, θ1, v2, θ2) to the end shears and moments needed to hold them. Each column is the set of end forces produced by a unit value of one displacement with the other three held at zero.
Where do 12EI/L³, 6EI/L², 4EI/L and 2EI/L come from?
They are the integrals of EI times the products of the second derivatives of the four Hermite cubic shape functions over the element length. Physically, 4EI/L is the moment needed to rotate one end by one radian with the other end fixed, and 2EI/L is the moment that this rotation carries over to the far end.
How do you assemble the global stiffness matrix of a beam?
Number every node's deflection and rotation, then add each 4x4 element matrix into the rows and columns of the global degrees of freedom it connects. Entries at a shared node add up. Supports are applied afterwards by removing (or prescribing) the restrained degrees of freedom.
What is the difference between fixed-end forces and equivalent nodal loads?
Fixed-end forces are the end shears and moments a member load produces when both ends are clamped, for a uniform load wL/2 and wL²/12. Equivalent nodal loads are the same values with the sign reversed, applied to the joints. After solving, the member end forces are k times d plus the fixed-end forces.
Is the beam element stiffness matrix exact?
For a prismatic Euler-Bernoulli beam, yes. The cubic shape functions solve the beam equation exactly between loads, so one element per span gives exact nodal displacements and, with the fixed-end forces added back, exact member forces. It ignores shear deformation, which matters only for deep, short members.
What is the 3D beam stiffness matrix?
A 3D beam (space frame) element has six degrees of freedom per node and a 12x12 matrix. It combines an axial bar, a torsion bar and two copies of the 4x4 bending matrix, one for each principal axis, and is rotated into global axes with the direction cosines of the member.