1D Bar Element Stiffness Matrix: Derivation and Stepped Bar Examples
Derive the stiffness matrix of a two-node bar element from minimum potential energy, step by step: shape functions, [B], strain energy, consistent loads, assembly, elimination and penalty supports, stresses and reactions. Three worked stepped-bar examples, each checked by a short Python solver.

The stiffness matrix of a two-node bar element is . You get it from the principle of minimum potential energy in four moves: assume the displacement varies linearly between the nodes, so the strain is ; write the strain energy ; subtract the work of the loads; and set the derivative with respect to each nodal displacement to zero.
This post does every step of that derivation, then assembles two elements into a stepped bar, applies the support by elimination and by the penalty method, and recovers stresses and reactions. Three worked examples (a free-ended stepped bar, the same bar held between two walls, and a bar carrying a distributed load) were solved by hand and checked by a Python script Skill-Lync keeps with this post.
New to FEA? Start with our beginner's guide, What is FEA?, which explains the method in plain words and shows how mesh refinement changes the answer. This page is the maths behind it.
Key takeaways
- The result: each bar element contributes to the global stiffness matrix, and a uniform axial load contributes to each of its two nodes.
- Worked example 1: a 300 mm steel element and a 200 mm aluminium element with 15 kN at the step and 10 kN at the tip: the tip moves 0.2080 mm, steel carries 62.5 MPa and aluminium 40 MPa.
- Held between two walls, the same bar under 30 kN splits the load by stiffness: the steel side takes 75.3% (22.6 kN). The penalty method matches elimination to 0.0063%.
- Under a distributed load, linear bar elements give exact nodal displacements but a stepped stress: the root stress is 50% low with one element and 6.25% low with eight.
- A correction: the earlier version of this page wrote the derivatives of the energy with . The correct factor is ; the factor 1/2 cancels when you differentiate a square.
The derivation is examinable in most Indian mechanical FEA syllabi. Skill-Lync's Finite Element Analysis interactive book maps it to Anna University CME367 (Unit V), VTU BME701 (Module 2), SPPU 302050 (Unit 3), Mumbai University MEC504 (Module 3) and KTU MET433 (Module 1), and lets you change the bar and watch the numbers update.
What is the principle of minimum potential energy?
For an elastic body under fixed loads, the total potential energy is the strain energy stored in the body minus the work potential of the loads. Of all displacement fields that satisfy the supports, the one in equilibrium makes this total potential energy a minimum. FEM uses this by restricting the displacement field to a few nodal values and minimising over them.
Written for a bar, with the strain energy and the work done by the loads:
"Satisfy the supports" matters: a fixed node must have zero displacement in every candidate field. In FE language these are kinematically admissible fields. The minimum condition for every free nodal displacement produces exactly one equation per unknown, which is why the method ends in a square system of linear equations.
The same principle drives the Rayleigh-Ritz method, which uses one smooth trial function over the whole bar instead of many simple ones over small elements. The FEA book's Rayleigh-Ritz chapter shows the link if you want the bigger picture.
What problem are we solving?
A stepped bar: a steel segment fixed to a wall, joined end to end to a thinner aluminium segment. Axial loads act at the step and at the free end. We want the displacement of every point, the stress in each segment and the wall reaction.
The inputs, in a consistent unit set (N, mm, MPa = N/mm²):
| # | Material | L, mm | A, mm² | E, MPa |
|---|---|---|---|---|
| 1 | Steel | 300 | 400 | 200,000 |
| 2 | Aluminium | 200 | 250 | 70,000 |
The steel modulus is the 2.0 × 105 N/mm² that IS 800:2007 specifies for structural steel; 70 GPa is a typical value for aluminium alloys. The dimensions are illustrative.
Step 1: How is the bar discretised?
Split the bar into elements wherever the area, material or load changes, and put a node at each element end. Here that gives two elements and three nodes. Each node has one unknown, its axial displacement , so the model has three degrees of freedom; one of them, , is fixed at zero by the wall.
A node must sit at every point load and at every change of section, because an element can only carry one constant area and modulus. More elements are needed only when something varies continuously along the length, such as a taper or a distributed load (example 3 shows what happens then).
Element connectivity is the bookkeeping that records which nodes each element joins: element 1 joins nodes 1 and 2, element 2 joins nodes 2 and 3. That small table is what tells the assembly step where to add each element's numbers.
Step 2: What are the shape functions of a bar element?
Inside one element of length , with a local coordinate running from 0 at its first node to at its second, assume the displacement is a straight line:
The two constants come from the nodal values. At , , so . At , , so . Substituting and grouping by nodal value:
and are the shape functions. Each equals 1 at its own node and 0 at the other, and they add to 1 everywhere, so a rigid shift of both nodes moves the whole element without straining it.
In matrix form, with and . Higher-order bar elements add a midside node and quadratic shape functions; the procedure below stays the same.
Step 3: What is the strain-displacement matrix [B]?
Axial strain is the derivative of displacement along the bar, . Differentiating the interpolation gives the strain in terms of nodal displacements:
So : the change in length divided by the original length, constant along the element. The stress follows from Hooke's law, , and is also constant in each element. This is why a two-node bar element can represent a constant force exactly but only approximates a force that varies along its length.
Step 4: How do you derive the element stiffness matrix?
Integrate the strain energy density over the element volume, substitute , and write the result as a quadratic form in the nodal displacements. The matrix in the middle of that quadratic form is the element stiffness matrix:
With constant strain , the integral is just the integrand times :
A quadratic form with expands to exactly this expression, so:
The same matrix comes out of the general formula used for every element type, : here is , and integrating the constant over the length multiplies it by .
Three properties are worth stating in an exam. The matrix is symmetric. Each row sums to zero, because a rigid-body shift () produces no force. And it is singular on its own: an unsupported bar can float, so you must apply a support before solving.
Step 5: What is the work potential of the loads?
Point loads at nodes do work equal to force times nodal displacement, so their work potential is . A load spread along an element (self-weight, friction, a magnetic body force) must first be converted into equivalent nodal forces using the same shape functions, which gives each node half of a uniform load.
For a uniform load of newtons per millimetre along an element:
These are called consistent nodal loads, because they come from the same assumed displacement as the stiffness. For self-weight, . Putting the whole load at one node instead is a common shortcut that gives the wrong answer; example 3 shows it doubles the tip displacement in a simple case.
In example 1 there are only point loads: (the unknown wall reaction), N and N.
Step 6: How are the element equations assembled?
Add the strain energies of all elements, subtract the work of all loads, and differentiate the total with respect to each nodal displacement. Every derivative that is set to zero gives one row of the global equations. The result is the same as adding each element's 2 × 2 matrix into the rows and columns of its two nodes.
For the stepped bar, with and :
Differentiate once for each node. The factor 2 from the square cancels the 1/2, which is the step the earlier version of this page got wrong:
Collect the coefficients into a matrix and you have the global system :
The pattern is visible in the matrix: element 1 fills the top-left 2 × 2 block, element 2 the bottom-right block, and they overlap at node 2. That is the direct stiffness method, and it is all an FE program does when it assembles a model of millions of elements.
Step 7: How are boundary conditions applied?
The simplest way is elimination: a node fixed at zero displacement contributes nothing to the other equations, so delete its row and column and solve the smaller system. The deleted row is not wasted; you use it afterwards to compute the support reaction. Programs often use the penalty method instead, which keeps the matrix size.
With , removing row and column 1 leaves two equations in two unknowns:
The penalty method adds a very large spring to the diagonal term of each supported node, so the node can move only a tiny amount. A common rule of thumb takes as about times the largest diagonal term of . The reaction is then times that tiny displacement. Example 2 compares both methods on numbers.
A non-zero prescribed displacement (a support that settles by a known amount, or a gap that closes) is handled the same way: move the known terms to the right-hand side under elimination, or add times the prescribed value to the load vector under the penalty method.
Step 8: How do you get stresses and reactions?
Once the nodal displacements are known, each element's strain is and its stress is times that. Reactions come from the rows you removed: multiply the full stiffness matrix by the full displacement vector and subtract the applied loads, .
Two checks catch most mistakes. The reactions and applied loads must add to zero (overall equilibrium). And in a statically determinate bar each stress must equal the internal force divided by the area, which you can get from a free-body diagram without any FEM.
Worked example 1: what are the displacements and stresses?
For the steel-aluminium bar fixed at the wall with 15 kN at the step and 10 kN at the tip, the step moves 0.09375 mm and the tip 0.2080 mm. Steel carries 62.5 MPa, aluminium 40 MPa, and the wall pulls back with 25 kN. Here is the working.
Element stiffnesses:
Reduced system after eliminating :
Adding the two rows gives , so:
Stresses and the reaction:
Both checks pass. The reaction, −25 kN, balances the 15 + 10 kN applied. The bar is statically determinate, so a free-body cut gives the same stresses directly: steel carries 25 kN over 400 mm² = 62.5 MPa, aluminium carries 10 kN over 250 mm² = 40 MPa.
The energy picture confirms the minimum. At the solution the strain energy is 1,743.3 N·mm and the work potential of the loads is twice that, so the total potential energy is −1,743.3 N·mm. The script evaluated 2,000 random admissible displacement pairs around the solution and every one had a higher energy.
Worked example 2: what if both ends are fixed?
Fix the tip to a second wall and push 30 kN at the step. Now the bar is statically indeterminate: equilibrium alone cannot split the load between the two walls. FEM handles it with no extra effort. The step moves 0.08471 mm, steel is in tension at 56.5 MPa, aluminium in compression at 29.6 MPa.
With , only one unknown remains:
The reactions are N and N, which add to −30,000 N as they must. Each wall takes a share of the load in proportion to the stiffness of its segment: goes to the steel side.
The same problem by the penalty method: N/mm added to and , full 3 × 3 system solved. The "fixed" nodes move 6.4 × 10−6 mm and 2.1 × 10−6 mm, the reactions come out as −22,587.95 N and −7,412.05 N, and differs from the elimination result by 0.0063%. That small error is the price of not deleting rows, and a larger shrinks it until round-off takes over.
The FEA book works a similar two-wall bar with different numbers, if you want a second problem to practise on.
Worked example 3: what happens with a distributed load?
Take a 1,000 mm steel bar, 500 mm² in area, fixed at one end and carrying a uniform axial load of 20 N/mm along its length (friction on a pile, or a scaled-up self-weight). The exact tip displacement is mm and the stress falls linearly from 40 MPa at the root to zero at the tip.
The exact solution comes from integrating equilibrium, , with and zero force at the free end:
Model it with 1, 2, 4 and 8 equal elements, with consistent nodal loads on each element's nodes. Two results stand out:
| Elements | Tip u (mm) | Root stress (MPa) | Root error |
|---|---|---|---|
| 1 | 0.1000 | 20.0 | −50% |
| 2 | 0.1000 | 30.0 | −25% |
| 4 | 0.1000 | 35.0 | −12.5% |
| 8 | 0.1000 | 37.5 | −6.25% |
| Exact | 0.1000 | 40.0 | - |
First, every nodal displacement is exact for every mesh (the script's largest error is 10−16 mm, round-off). Between the nodes, though, the elements draw straight lines under a curve. This exactness at the nodes is a special property of one-dimensional problems like this one; in 2D and 3D models nodal values are approximate too.
Second, the stress in each element is constant and equals the exact stress at the element's midpoint. The peak stress at the root is therefore underestimated by half an element's worth of stress gradient, and the error halves each time the element size halves. Stresses converge more slowly than displacements, which is why you always refine the mesh where you read stresses.
And the shortcut warned about in Step 5: putting the whole 20 kN at the tip instead of using consistent loads gives a tip displacement of 0.2 mm, twice the true value, because the load is assumed to act over the full length when on average it acts at mid-length.
Can you check these results with 20 lines of Python?
Yes. The function below builds the global stiffness matrix by adding each element's 2 × 2 block, eliminates the fixed nodes, solves, and recovers stresses and reactions. It reproduced every number on this page; running it for example 1 prints the displacements, stresses and reactions shown underneath.
import numpy as np
def solve_bar(E, A, L, loads, fixed):
"""2-node bar elements in series. E, A, L: one value per element.
loads: {node: force}; fixed: list of nodes with u = 0. Units N, mm, MPa."""
n = len(L) + 1
K = np.zeros((n, n))
for e in range(len(L)):
k = E[e] * A[e] / L[e]
K[e:e+2, e:e+2] += k * np.array([[1, -1], [-1, 1]])
F = np.zeros(n)
for node, f in loads.items():
F[node] += f
free = [i for i in range(n) if i not in fixed]
u = np.zeros(n)
u[free] = np.linalg.solve(K[np.ix_(free, free)], F[free])
stress = [E[e] * (u[e+1] - u[e]) / L[e] for e in range(len(L))]
reactions = K @ u - F
return u, stress, reactions
u, s, r = solve_bar(E=[200e3, 70e3], A=[400, 250], L=[300, 200],
loads={1: 15e3, 2: 10e3}, fixed=[0])
print(u.round(5), np.round(s, 2), r.round(1))
# [0. 0.09375 0.20804] [62.5 40. ] [-25000. 0. 0.]
Nodes are numbered from 0 in the code, so node 1 of the text is index 0. Change fixed=[0] to fixed=[0, 2] and the loads to {1: 30e3} to reproduce example 2. For example 3, pass eight equal elements and add to both nodes of each element.
Writing this solver once is the fastest way to understand what ANSYS, Abaqus or Nastran do inside: the same assembly, the same constraint step and the same solve, with elements that have more nodes and more degrees of freedom. Skill-Lync's 12-week Basics of FEA: explicit and implicit course builds on this foundation with practical examples and 3 projects.
What mistakes do students make in this derivation?
Most lost marks come from five slips: a wrong factor when differentiating the energy, forgetting the support before solving, mixing units, lumping a distributed load at one node, and quoting stress at the wrong point. Each has a quick check.
| Mistake | What goes wrong | Quick check |
|---|---|---|
| Keeping the 1/2 after differentiating | Stiffness half its true value, displacements doubled | |
| Solving before applying the support | Singular [K], no solution | Rows of [K] sum to zero |
| Mixing units (GPa with mm) | Answers off by 1,000 | Use N, mm, MPa throughout |
| Whole distributed load at one node | Wrong displacements | Each node gets |
| Reading peak stress from a coarse mesh | Peak underestimated | Refine and compare |
For a free-body check, the reactions and loads must sum to zero. In a determinate bar, each element stress must equal its internal force over its area.
Where does this lead next?
The bar element is the first rung. Rotate it into 2D and you get the plane truss element; replace the linear shape functions with Hermite cubics and you get the beam element; move to two dimensions and the same gives the constant strain triangle. Each of these is a chapter of the Skill-Lync FEA book, with a worked example and an interactive.
Real parts rarely stay one-dimensional. How to choose between beam, shell and solid elements for one part is shown on a single cantilever in 1D, 2D and 3D FEA in SolidWorks.
To learn the industry tools on top of the theory, compare all 15 Skill-Lync FEA courses, from short courses in ANSYS Workbench, HyperMesh, ANSA, LS-DYNA and Radioss crash to the PG Program in CAE, with fees, duration, projects and placement data in one table. If you are unsure which suits your background, talk to a Skill-Lync counsellor.
Frequently asked questions
What is the stiffness matrix of a bar element?
For a two-node bar element of length , area and modulus , the stiffness matrix is . It relates the two nodal axial forces to the two nodal displacements. It is symmetric, each row sums to zero, and it is singular until a support is applied.
Why is the potential energy method used to derive FEM equations?
Because it turns a differential equation into a minimisation over a few nodal values. You only need an expression for strain energy and the work of the loads, both easy to write for an assumed displacement. Setting the derivative to zero for each unknown gives a symmetric set of linear equations, ready to solve.
What are consistent nodal loads?
They are the nodal forces equivalent to a load spread over an element, found by integrating the load against the same shape functions used for displacement. For a uniform axial load on a two-node bar element of length , each node receives . Self-weight uses .
What is the difference between the elimination and penalty methods?
Elimination deletes the rows and columns of fixed degrees of freedom and solves the smaller system exactly. The penalty method keeps the full matrix and adds a very stiff spring, typically about times the largest diagonal term, at each support. It is easier to program but leaves a tiny error, 0.0063% in example 2.
Why are FEA stresses less accurate than displacements?
Stress comes from the derivative of the displacement, and differentiating an approximation loses accuracy. With linear bar elements, displacement varies linearly but stress is constant in each element, so a varying stress is shown as steps. In example 3 the nodal displacements are exact while the root stress is 50% low with one element.
Is the stiffness matrix derived this way the same as by the direct method?
Yes. For a two-node bar the direct method treats each element as a spring of stiffness and writes nodal equilibrium; the potential energy method minimises energy over a linear displacement field. Both give . The energy route generalises to beams, plates and solids, where the spring analogy runs out.
Sources and further reading
- Klaus-Jürgen Bathe, Finite Element Analysis of Solids and Fluids I (2.092), MIT OpenCourseWare, Fall 2009 (lecture notes and course materials). Accessed 21 Nov 2026.
- Nachiketa Tiwari, Basics of Finite Element Analysis - I, NPTEL online course, IIT Kanpur. Accessed 21 Nov 2026.
- Bureau of Indian Standards, IS 800:2007 General Construction in Steel (modulus of elasticity of steel, E = 2.0 × 105 N/mm²). Accessed 21 Nov 2026.
- Engineering ToolBox, Young's Modulus of Elasticity for metals and alloys (aluminium alloys, 70 GPa). Accessed 21 Nov 2026.
- Skill-Lync, Finite Element Analysis interactive book (bar-element chapter, syllabus mapping, penalty and taper examples), and this post's calc script (all worked numbers, the energy check and the Python solver), kept in the post's run folder.
- Textbooks used for the derivation's notation: T. R. Chandrupatla and A. D. Belegundu, Introduction to Finite Elements in Engineering; D. L. Logan, A First Course in the Finite Element Method; P. Seshu, Textbook of Finite Element Analysis.


