## 1 Introduction  
Ordinary differential equations (ODEs) of second order are used throughout engineering, mathematics and science. It is well known that of all differential equations, only a little of them have analytic solutions. Most of them, especially for these with variable coefficients are very difficult to solve. Very often, the solving techniques are difficult to deal with complicated equations in practice. In this paper, we consider the numerical solutions for second order linear differential equations of the form  
\[y^{\prime\prime}(x)+P(x)y=Q(x),\quad x\in[a,b], \tag{1}\]  
with the boundary conditions  
\[y(a)=A,y(b)=B, \tag{2}\]  
where \(A,B\) are constants and \(P(x),Q(x)\) are sufficiently smooth functions. We remark that Equation (1) doesn't contain the first derivative term \(y^{\prime}(x)\), because we can eliminate it by proper transformation.  
How to solve the differential equations effectively has gain great attentions in recent years, researchers have been putting forth effort on obtaining stable algorithms with less float operations and higher accuracy. Numerical methods for differential equations are well developed and some of them are widely used, such as [PERSON]'s method, the linear multi-step method, Runge-Kutta Method and so on. For more detailed researches on this topic, we refer the reader to read [1].  
Recently, solving differential equations by spline functions have been investigated by more and more researchers and a large of spline functions have been exploited to solve these equations. [PERSON] [2] derived an uniform quartic polynomial spline at mid-knots. [PERSON] et al. [3, 4] presented some quadratic, cubic polynomial and nonpolynomial spline functions to find the approximate solutions. They also shown that the nonpolynomial splines could yield better approximations and have lower computational cost than the polynomial ones. By using the nonpolynomial quintic splines, [PERSON] et al. developed a numerical algorithm [5]. In [6], a quadratic non-polynomial spline functions based method was proposed by [PERSON] et al. [PERSON] and [PERSON] studied the singularly perturbed semi-linear boundary value problem with exponential spline [7]. [PERSON] and [PERSON] exploited the numerical method to solve second order singularly perturbed two-point linear and nonlinear boundary value problems [8]. In [9], [PERSON] proposed the exponential spline functions consisting of a polynomial part of degree three and an exponential part to find approximation of linear and nonlinear fourth order two-point boundary value problems. By solving a algebraic system, [PERSON] and [PERSON] proposed the optimized multigrid methods [10]. [PERSON] and [PERSON] investigated the collocation method with linear/linear rational spline for the numerical solution of two-point boundary value problems [11]. By using B-spline, [PERSON] and [PERSON] developed a numerical method which can solve the general nonlinear two-point boundary value problems up to order 6 [12].  
Despite the fact that there are a large number of spline functions to approximate the solutions to the equations, most of them are not constructed based on the differential equations to be solved, and can not achieve satisfying results. To the best of our knowledge, there is still no any research about the construction of spline functions based on the differential equations. It is known to all that second order linear differential equations with constant coefficients can be solved analytically. This leads us to think that whether we can use the analytic solutions to solve these with variable coefficients. The spline function based on analytic solutions can achieve better approximation performance. Therefore, we put forth effort on constructing a spline function based on analytic solutions of equations with constant coefficients.