Clear["Global`*"];
Off[General::spell, General::spell1];

Beam-column/buckling using Ritz method

1) Seek approximate solutions of the form:

Ck[n_] :=  Table[ck[i], {i, n}]
ϕk[n_]  :=  
      Table[Sin[π i (x/L)], {i, n}]
(Subscript[W, 0])[n_]  :=  Ck[n] . ϕk[n]

(Subscript[W, 0])[2]

2) Define the approximate potential Π(Ck) for this problem

dWdx[n_]  :=  
      D[(Subscript[W, 0])[n], x]  // Simplify
d2Wdx[
        n_]  :=  D[(Subscript[W, 0])[n], {x, 2}]  // Simplify
Π[n_] :=(1/2) ym im (∫_0^L)  d2Wdx[
                      n]^2 \[DifferentialD]x -  ((ρgArea )/2) (∫_0^L) (L - x) dWdx[n]^2 \[DifferentialD]x // 
        Expand

Π[2]

3) Minimize the potential to find the value of the coefficients that best approximate this problem

gradΠ[n_]  :=  
      Table[D[Π[n], ck[i]], {i, n}]

gradΠ[2] // Simplify

Buckling length

matrix[n_]  := 
      Table[Coefficient[gradΠ[n][[i]], Ck[n]], {i, 
          n}]

matrix[1]

Solve[Det[matrix[2]] == 0,  ρgArea] // N // 
      Chop