Linear Methods of Applied Mathematics

  Selected solutions for Chapter II

(c) Copyright 1994-1997 by Evans M. Harrell II and James V. Herod. 
     All rights reserved.

Notes for the instructor.

This contains calculations and examples which correlate with chapter 2 of the WWW text by Harrell and Herod.

Students can be encouraged to cut and paste from this notebook to do homework.

Instructions

This notebook uses Mathematica  to perform calculations for Harrell and Herod's hypertext book, Linear Methods of Applied Mathematics.   The student needs only a basic knowledge of Mathematica  to use the notebook, which is designed both to show how to work problems in the text and to provide a template for using Mathematica  to work other problems of the student's own design.  

Calculations will be performed when the reader presses enter in a given calculation cell (bold print).  It is best to activate the cells in order, so that Mathematica  will be able to call on operators and functions defined in earlier cells.  Red color coding is used to warn the reader when a given calculation relies on an earlier one.

Exercise II.1

II.1.  Find the norms of and "angles" between the following functions defined for -1<x<1.  (In the case of complex quantities, the "angle" is not so meaningful, but you can still define the cosines of the angles.)  Use the standard inner product:
	1, x, x^2, cos(pi x), exp(i pi x)

Solution

The idea here is that   <f,g> = ||f||  ||g||  cos(q), where q is the angle requested.  We can automate this whole problem by defining commands in Mathematica  for operations such as the inner product <f,g>, etc.  Since one of the functions involved is complex-valued, we need to remember that one of the functions in the inner product must be complex conjugated.  (Unfortunately, Mathematica is not very clever about manipulating functions which have neen complex conjugated, so it is best to make a special identity to use when needed.)

ConjId = Exp[I Pi x] -> Exp[- I Pi x];

InnerP[f_,g_, {x_,a_,b_}] := Integrate[f (g /. ConjId), {x, a, b}]

FunNorm[f_, {x_,a_,b_}] := Sqrt[InnerP[f,f,{x,a,b}]]

FunCos[f_,g_, {x_,a_,b_}] := InnerP[f,g,{x,a,b}]                          / (FunNorm[f,{x,a,b}] FunNorm[g,{x,a,b}])

We'll calculate some representative cosines and angles from the exercise:

FunCos[1,x,{x,-1,1}]

I.e., these functions are orthogonal; the angle is Pi/2.

FunCos[x^2,Cos[Pi x],{x,-1,1}]

To get the angle in radians:

ArcCos[%] //N

FunCos[x,Exp[I Pi x],{x,-1,1}]

Simplify[%]

FunCos[x^2,Exp[I Pi x],{x,-1,1}]

Simplify[%]

Exercise II.7

In  each case below, find 

a) the multiple of g which is closest in the mean-square sense to f, and 

b) a function of the form f - a g which is orthogonal to f.  If for some reason this is not possible, interpret the situation geometrically.

(i)	f(x) = sin(pi x), g(x) = x, 0 < x < 1
(ii)	f(x) = sin(pi x), g(x) = x, -1 < x < 1
(iii)	f(x) = cos(pi x), g(x) = x, -1 < x < 1
(iv)	f(x) = x^2 - 1, g(x) = x^2 + 1, -1 < x < 1

Solution for part a)

The closest multiple of g would be the projection of f onto g.  We may automate this just as in the notebook ch2.ma:

Projf[f_,g_, {x_,a_,b_}] := g Integrate[(f g /. x -> intvar), {intvar,a,b}]                              / Integrate[(g^2 /. x -> intvar), {intvar,a,b}]

Thus the answers are:

Projf[Sin[Pi x], x, {x,0,1}]

Projf[Sin[Pi x], x, {x,-1,1}]

Projf[Cos[Pi x], x, {x,-1,1}]

Projf[x^2 - 1, x^2 + 1, {x,-1,1}]

Solution for part b)

If f - a g  is orthogonal to f, then 
	          0 = <f - a g, f> = <f,f> - a <g, f>, 
so
           a = <f,f> / <g, f>

Alpha[f_,g_, {x_,a_,b_}] := InnerP[f,f,{x,a,b}]                                /InnerP[f,g,{x,a,b}]

Answers:

Alpha[Sin[Pi x], x, {x,0,1}]

Alpha[Sin[Pi x], x, {x,-1,1}]

Alpha[Cos[Pi x], x, {x,-1,1}]

The difficulty in (iii) is that the two functions are orthogonal.

Alpha[x^2 - 1, x^2 + 1, {x,-1,1}]