Exercise 3.4.21. Given the function on the interval
, what is the closest function
to
? What is the closest line
to
?
Answer: To find the closest function to the function
we first project
onto the function
on the given interval to obtain
, and then project
onto
to obtain
.
We project onto
by taking the dot product of
with
and then normalizing by dividing by the dot product of
with itself:
The numerator is
where we used the trigonometric identity .
To integrate we substitute the variable so that
. We then have
We then have
Since the numerator in the expression for is zero, we have
.
(Note that we do not need to calculate the denominator in the expression for . We know it must be positive, and thus the quotient is defined. See below for a sketch of a proof of this.)
We next project onto
by taking the dot product of
with
and then normalizing by dividing by the dot product of
with itself:
The numerator is
where we used the trigonometric identity .
To integrate we substitute the variable so that
. We then have
We then have
Since the numerator in the expression for is zero, we have
. (Again, we are guaranteed that the denominator is positive and the quotient defined.)
So the closest function to
is
.
To find the closest function to the function
we first project
onto the constant function with the value 1 on the given interval to obtain
, and then project
onto the function
to obtain
.
We project onto the constant function with value 1 by taking the dot product of
with 1 and then normalizing by dividing by the dot product of 1 with itself:
The numerator is
To integrate we substitute the variable so that
. We then have
We then have
Since the numerator in the expression for is zero we have
. (Recall that the denominator is guaranteed to be positive.)
We project onto the function
by taking the dot product of
with
and then normalizing by dividing by the dot product of
with itself:
The numerator is
To integrate this we use integration by parts, taking advantage of the formula . (The following is adapted from a post on socratic.org.) We let
and
. Then
is simply
, and
(the integrand of
, as discussed above).
We then have
The second integral we can evaluate by substituting and
so that
Substituting for the second integral above we then have
We then have
The denominator in the expression for is
We then have
The straight line closest to the function
is thus the line
.
ADDENDUM: Suppose that is a continuous function defined on the interval
and
for some
. Then we want to show that the inner product
.
The basic idea of the proof is as follows: The function is always nonnegative, and thus its integral over the interval
is nonnegative as well. If
is nonzero for some
then since
is continuous
will also be nonzero for some interval
that includes
, with
. This implies that the integral of
over that subinterval
will be positive.
But we also have since
and
is contained within
. So if
then we also have
and the inner product
is positive.
NOTE: This continues a series of posts containing worked out exercises from the (out of print) book Linear Algebra and Its Applications, Third Edition by Gilbert Strang.
If you find these posts useful I encourage you to also check out the more current Linear Algebra and Its Applications, Fourth Edition, Dr Strang’s introductory textbook Introduction to Linear Algebra, Fifth Edition
and the accompanying free online course, and Dr Strang’s other books
.