Try using finite element analysis methods. The stiffness Matrix(K) is determined by the formula:
K=EAL/2*B*BTRANS
E is modulus of Elasticity
A is Cross sectional area
L is length of the element
B is directional vector matrix (1, -1)/L
BTRANS is the transpose of B.
This simplifies to...