# Checking Finite Difference Errors

Checking Finite Difference Errors

The exact solution of the boundary value problem f(x)+mf(x)=0, =0 at , and at with parameter is .

2

∂

∂

2

x

∂f(x)

∂x

x=0

f(x)=1

x=1

m

f(x)cos(

m

x)sec(m

)The second-order discretization for the discrete variable at points with step size gives the recurrence equation , where , , which is solved exactly using Mathematica's RSolve function.

F(j)=f(x)

j=1,…,n

h

F(j-1)+mF(j)+F(j+1)=2F(j)

2

h

3F(1)+F(3)=4F(2)

F(n)=1

The difference between the finite difference and exact solutions in the region is dynamically plotted in the solution region for 3 to 300 discretization points and parameter between and .

0≤x≤1

0≤x≤1

m

-10

10

By using DSolve and RSolve, a numerical solution is completely avoided.