WOLFRAM NOTEBOOK

WOLFRAM|DEMONSTRATIONS PROJECT

Checking Finite Difference Errors

number of points
5
parameter
0
The exact solution of the boundary value problem
2
f(x)
2
x
+mf(x)=0
,
f(x)
x
=0
at
x=0
, and
f(x)=1
at
x=1
with parameter
m
is
f(x)cos(
m
x)sec(
m
)
.
The second-order discretization for the discrete variable
F(j)=f(x)
at points
j=1,,n
with step size
h
gives the recurrence equation
F(j-1)+m
2
h
F(j)+F(j+1)=2F(j)
, where
3F(1)+F(3)=4F(2)
,
F(n)=1
, which is solved exactly using Mathematica's RSolve function.
The difference between the finite difference and exact solutions in the region
0x1
is dynamically plotted in the solution region
0x1
for 3 to 300 discretization points and parameter
m
between
-10
and
10
.
By using DSolve and RSolve, a numerical solution is completely avoided.
Wolfram Cloud

You are using a browser not supported by the Wolfram Cloud

Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.


I understand and wish to continue anyway »

You are using a browser not supported by the Wolfram Cloud. Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.