t=Function[n,t0+n*h]

t[2]

p=Function[x,f[t[n-1],ynm1]*(x-t[n])*(x-t[n+1])/((t[n-1]-t[n])*(t[n-1]-t[n+1]))
   +f[t[n],yn]*(x-t[n-1])*(x-t[n+1])/((t[n]-t[n-1])*(t[n]-t[n+1]))
   +f[t[n+1],ynp1]*(x-t[n-1])*(x-t[n])/((t[n+1]-t[n-1])*(t[n+1]-t[n]))]

Simplify[p[x]]

Integrate[p[x],{x,t[n],t[n+1]}]

Quit