The article presents an approximate method of solving direct and inverse problems described by Bernoulli-Euler inhomogeneous equation of vibrations of a beam. A semianalytical solution is approximated by a linear combination of the Trefftz functions (T-functions, solving functions), which satisfies identically the homogenous equation describing the vibrations of a beam. In the paper, the properties of the solving functions have been investigated, theorems concerning their linear independence have been formulated and proved. A method of obtaining the particular solution of the inhomogeneous equation has been shown. To get this solution, recurrent formulas enabling us to determine the inverse operator for monomials have been derived. The paper discusses two kinds of inverse problems. The first one is a boundary inverse problem, in which the boundary conditions are to be determined, based on known displacements within the area. In the second one, the load on the beam needs to be found (identification of the source). The solving functions can be used as a finite element method base functions. This approach is tested for solving inverse problems. The paper includes examples which illustrate the usefulness of the method.