In this paper, the problem of a nonlinear beam equation involving an integral term of the deformation energy, which is unknown before the solution, under different boundary conditions with simply supported, 2‐end fixed, and cantilevered is investigated. We transform the governing equation into an integral equation and then solve it by using the sinusoidal functions, which are chosen both as the test functions and the bases of numerical solution. Because of the orthogonality of the sinusoidal functions, we can find the expansion coefficients of the numerical solution that are given in closed form by using the Drazin inversion formula. Furthermore, we introduce the concept of fourth‐order and fifth‐order boundary functions in the solution bases, which can greatly raise the accuracy over 4 orders than that using the partial boundary functions. The iterative algorithms converge very fast to find the highly accurate numerical solutions of the nonlinear beam equation, which are confirmed by 6 numerical examples.