104
Xnumbers Tutorial
153
Sampling the function y(x) and F(x) with h = 0.25 for 0 ≤ x ≤ 6, we have the following data
sets (xi, y(xi)) and (xi, F(xi))
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
0
1
2
3
4
5
6
y
∫ y dx
As we can see, the function y(x), always linear, has no derivative at the points x = 2, and x = 4.
If we integrate the data set (xi, yi) with the 1st degree formula (IntType = 1) the result coincides
with the exact solution (error = 0). But if we try with the other higher formulas the average error
is, surprisingly, about 0.005
Integral function of a symbolic formula
When we have the function f(x) written in a symbolic formula we can obtain the plot of its
integral function in two ways.
• Sampling the given function f(x
i
) for x
i
= x
0
+ i⋅h with a suitable step h
• Solving the associated ODE equation
• Integrating f(x) from x
0
to x
i
for x
i
= x
0
+ i⋅h with a suitable step h
The first method is simple and it is already shown in the previous chapter; the second way
need some more explanation.
The function y(x) that we want to plot is defined as
∫
=
x
x
f x x dx
y x
0
( )
( )
Taking the derivatives of both sides and remebering Leibniz's rule, we have
( )
'( )
f x
y x
=
,
( ) ) 0
0
y x x =
y
As we can see, the computing of any integral function is equivalent of solving an ODE.
Therefore we can use any method that we have used for solving ODE: Runge-Kutta, Predictor-
Corrector, Taylor, etc. (see chap. ODE for further details)
The third method, less efficient then the others, may be successfully used when the function
f(x) or its derivatives f'(x) has some singularities in the integration range.
The following example explain better the concept. Assume to have to plot the integral function
of the following function
∫
=
x
dx
x
y x
0
2
)
ln(
( )
We note that,.
=−∞
→
)
lim ln(
2
0
x
x
Therefore, x = 0 is a singular point. From theory we know that the integral exists, thus we can
project to tabulate the given integral for several points x
i
= i⋅h with a suitable step h, for
example h = 0.1
For this scope we may use the function integr_de or Integr that are more suitable for such
singularities