(a)
Trapezoid
(1/2)*(exp(2)/2+exp(1)+ 1+exp(-1)+exp(-2)/2)
The absolute relative error is
percent
(b) Simpson's method:
(1/6)*(exp(2)+4*exp(1)+ 2+4*exp(-1)+exp(-2)/2)with the relative error of
(c) Hermit's rule, or corrected trapezoid rule gives
(1/2)*(exp(2)/2+exp(1)+ 1+exp(-1)+exp(-2)/2)+1/(4*12)*(-2*exp(2)+2*exp(-2))with the absolute relative error of
(d)
Since
, and
on an interval from
to
we have
, we obtain
(c) Since
we have, for this problem,
(a)
This problem was solved in class, see the lecture notes.
There is a misprint in the book. The correct formulation of this problem is
Suppose . Then the trapezoid method will give for
,
and
with
:
Results for arbitrary are obtained by trivial generalization.
(b) There is a misprint in this problem as well, it should be
Now consider with the two intervals
and
with
We now have composite trapezoid method
for two intervals
to be given by
Results for arbitrary are obtained by trivial generalization.
(a)
Assume
. Since
Then
(b) Similarly, if
(c)
The above equations are now supplemented with
(a) The value of obtained by Matlab is given by
. Interestingly, the “correct”
result is
To use trapezoid rule, we need to calculate We have
(b)We need to know , which is equal to
(e) The following code in Mathematica plots the required curve:
Plot[Erf[x], {x, 0, 10}, PlotRange -> All]
To obtain this in Matlab, one can use composite Simson's method, as explained above, with
(a) Since the problem is symmetric with respect to and
, the curves
are symmetric with respect to mirrowing over both
and
axis, so therefore it is sufficient
to consider only positive
and
and multiply the result by
.
(b)
To evaluate the area under the curve
We are therefore integrating
We now obtain
Solving for and integrating over
will lead to the same
problems. This can be observed by changing variables
and
.
(c)
After using adaptive quadrature we otain the result
(d)
We now calculate
To compare this result with the (c) we need to subtract
from it
(e) In the point (d) the issue of infinite second derivative was avoided by reformulating a problem in a way that no infinite second derivative was present. This is a result of cutting the domain in two, as described in the Holmes 2023.
(a)
We studied in class how to construct a system of equations to obain the solution to this problem.
We require that this quadrature rule integrates correctly ,
and
.
The resulting equations are
(b)
To find we need to integrate the
and calculate the error. We therefore calculate
Since we obtain that the constant
is equal to