01
Second-order axial strain
Consider a straight, prismatic two-node truss element. Although the displacements are small, the terms of second degree in the nodal displacements are retained.

With,, and initial element angle, the exact engineering strain is:
This expression can be written as:
The binomial expansion [1] is:
For , the first three terms are required because itself already contains terms of second degree:
After discarding terms of degree three and higher in and,
02
Compact matrix form
Introduce the element displacement vector:
The second-order strain can then be written as:
Using the column vector:
the symmetric matrix in the quadratic term is:
03
Element deformation energy
For a linear elastic truss element,
Substitution of the second-order strain would generate terms up to degree four. Neglecting terms of degree four gives:
Since displacements are small, the axial force obtained from the preliminary linear analysis is:
Therefore,
04
Elastic and geometric stiffness matrices
Define
The two element matrices are:
This decomposition is the usual stress-stiffening formulation [2] [3]
The element matrices are assembled in the usual way to obtain the structural elastic stiffness matrix and geometric stiffness matrix.
05
The buckling eigenproblem
Let the axial forces and correspond to a reference load. At a load factor, the tangent stiffness becomes singular:
With the program convention in tension and in compression, the corresponding generalized eigenproblem is:
Here is the buckling load factor and is the buckling mode. Usually, the smallest positive eigenvalue is the quantity of interest.
The minus sign is required by the signed axial-force convention used in the MATLAB files and produces positive critical load factors for compression.
06
MATLAB implementation
The calculation has two stages:
truss2d.msolves the small-displacement linear problem, andstress2d.mcomputes the signed axial forces.buckling.massembles and solves the generalized eigenproblem.
% Solve for the free degrees of freedom
fixedDofs=2*(cond(:,1)-1)+cond(:,2);
freeDofs=setdiff((1:neq)',fixedDofs);
Kff=K(freeDofs,freeDofs);
KGff=KG(freeDofs,freeDofs);
[Vfree,lambda]=eig(Kff,-KGff,'vector');
valid=isfinite(lambda) & real(lambda)>0;
lambda=sort(real(lambda(valid)));Tested in MATLAB R2017b and MATLAB R2026a. In both versions the package solves only for the unconstrained degrees of freedom, removes nonphysical infinite eigenvalues, and returns the same positive critical load factors. The code uses standard MATLAB syntax and is expected to be compatible with intermediate and newer MATLAB versions.
07
Example 1 — eigenvalue buckling
The geometry, material data, constraints, and reference loads are specified in gen.m. The first two buckling modes are shown below.

| Solution | First buckling load | Second buckling load |
|---|---|---|
| MATLAB R2026a and R2017b | 940,978.7131 | 6,181,251.434 |
| ANSYS | 9.4098 × 105 | 6.1813 × 106 |
08
Example 2 — nonlinear response near buckling
The same structure is analysed with the nonlinear program from Section 1.1. The vertical force increases from zero to, while a small horizontal force increases from zero to.
With the residual convention used in the Section 1.1 program, downward and rightward loads are entered with negative signs:
forze=[11 1 -H
11 2 -470490
12 2 -470490];

For , and , the load-displacement curves tend asymptotically to the first buckling load, as expected.
The negative signs are included so that the data agree with the coordinate directions, the arrows in the figure, and the residual convention implemented in stiff.m.
09
Why the third binomial term matters
If the expansion is stopped after only two terms,
the resulting strain is:
This is not the complete second-order expansion of the exact engineering strain: the orientation-dependent quadratic terms, including the mixed term, are lost.
The corresponding alternative geometric matrix would be
This matrix is invariant under a rotation of the global axes, but it is not identical to the consistent geometric stiffness obtained from the complete second-order expansion above. It should therefore be regarded as an alternative formulation, not as an algebraically equivalent form of.
10
Program files
11
References
- Wikipedia contributors, “Binomial theorem”
- Ansys, Inc., Ansys Mechanical APDL Theory Reference, Release 2026 R1, sections “Stress Stiffening,” “Eigenvalue and Eigenvector Extraction,” and “Buckling Analysis,” 2026. The supplied comparison macro uses syntax compatible with ANSYS Release 12.0.
- I. Němec, M. Trcala, I. Ševčík, and H. Štekbauer, “New Formula for Geometric Stiffness Matrix Calculation”, Journal of Applied Mathematics and Physics, 4 (2016), 733–748.