GENERAL VECTOR SPACES
11.1. VECTORS IN FUNCTION SPACES 183
11.1.6. Write symbolic code that will, all as a single procedure,
(a) Obtain the coefficients that describe the expansion of an arbitrary explicit expression f (x) on the interval 0≤ x ≤ 1 in terms of the four functions Ziof Exercise 11.1.1, using the scalar product defined in that exercise.
(b) Combine the coefficients and the Zito obtain an expression that represents the expan-sion of f (x).
(c) Plot f (x) and its expansion on the same graph, for the interval 0≤ x ≤ 1. The maple command for getting these two plots on the same graph is plot([f1,f2],x=0 .. 1); in mathematica, use Plot[{f1,f2},{x,0,1}].
In addition, provide an alternative version of your procedure that plots the single function f1− f2so that if the error is small you will still be able to see its behavior.
Use your procedures to examine the four-term expansions of exand x/(x + 1), and comment on the qualitative behavior of the error in the expansion. In any case where the difference between the function and its expansion is not apparent when both are plotted, examine this difference directly before making your comments.
Solution:
First set up the normalized z[i] and the procedure ScalProd as in the solution to Exercise 11.1.1 and then load the plotting procedure plot3. In maple,
> z[0]:=1: z[1]:=2*x-1: z[2]:=6*x^2-6*x+1:
> z[3]:=20*x^3-30*x^2+12*x-1:
> for i from 0 to 3 do z[i]:=z[i]*sqrt(2*i+1) end do:
> ScalProd := proc(u,v); int(u*v, x=0 .. 1); end proc:
> plot3 := proc(f) local a,i,fexp;
> for i from 0 to 3 do a[i]:=ScalProd(z[i],f); end do;
> fexp := a[0]*z[0]+a[1]*z[1]+a[2]*z[2]+a[3]*z[3];
> plot([fexp,f], x = 0 .. 1);
> end proc;
maple will plot f in green and its expansion fexp in red. To use this procedure, enter a command such as
> plot3(exp(x));
To plot the difference between f (x) and its expansion, change the plot com-mand in the above coding to
> plot(fexp-f, x = 0 .. 1);
In mathematica, the corresponding code is
z[0]=1; z[1]=2*x-1; z[2]=6*x^2-6*x+1; z[3]=20*x^3-30*x^2+12*x-1;
Do[z[i] = z[i]*Sqrt[2*i+1], {i, 0, 3}]
ScalProd[u_, v_] := Integrate[u*v, {x, 0, 1}]
plot3[f_] := Module[{a,i,fexp}, Do[a[i]=ScalProd[z[i],f],{i,0,3}];
fexp := a[0]*z[0]+a[1]*z[1]+a[2]*z[2]+a[3]*z[3];
Plot[{fexp,f},{x,0,1}] ]
184 CHAPTER 11. GENERAL VECTOR SPACES
mathematica will plot f in purple and its expansion fexp in blue. To use this procedure, enter a command such as
plot3[x/(x+1)]
To plot the difference between f (x) and its expansion, change the Plot com-mand to
Plot[fexp-f,{x,0,1}]
The plots produced for ex(in either symbolic language) are (Left, fexp and f;
right, fexp-f):
The plots for x/(x + 1) are (Left, fexp and f; right, fexp-f):
11.2 GRAM-SCHMIDT ORTHOGONALIZATION
Exercises
11.2.1. Carry out the symbolic computations of Example 11.2.1 and thereby verify that the procedure of that Example produces the Legendre polynomials at their conventional scaling (see Table 11.1). Check your result against the Legendre polynomials as given in Table 14.1.
Solution:
Execute the symbolic code.
11.2.2. Carry out the symbolic computations of Example 11.2.2 and thereby verify that the procedure of that Example produces the Hermite polynomials at their conventional scaling (see Table 11.1). Check your result against the Hermite polynomials as given in Table 14.4.
Solution:
Execute the symbolic code.
11.3. OPERATORS 185 11.2.3. Carry out symbolic computations in which the function set un= xn(starting with n = 0) is orthogonalized using the scalar product defined for the Chebyshev I polynomials and brought to their conventional scaling (see Table 11.1). Check your result against those obtained by symbolic computing.
Solution:
Enter the un, define the scalar product, define the first orthonormal function Q[0], and run the recursive procedure to get additional orthonormal Q[n]. In maple,
> for n from 0 to nmax do u[n]=s^n end do:
> ScalProd := proc(u,v); int(u*v*(1-s^2)^{-1/2},s=-1 .. 1)
> end proc;
> Q[0] := u[0]/sqrt(ScalProd(u[0],u[0]));
> for n from 1 to nmax do
> QQ := u[n]-add(ScalProd(u[n],Q[j])*Q[j], j=0 .. n-1);
> Q[n] := QQ/sqrt(ScalProd(QQ,QQ))
> end do;
In mathematica,
Do[ u[n] = s^n, {n, 0, nmax} ]
ScalProd[u_,v_] := Integrate[u*v, {s, -1, 1}]
Q[0] = u[0]/Sqrt[ScalProd[u[0],u[0]] ]
Do[ QQ = u[n]-Sum[ ScalProd[ u[n], Q[j] ]*Q[j], {j,0,n-1}];
Q[n] = QQ/Sqrt[ ScalProd[QQ,QQ] ], {n, 1, nmax} ]
We complete this Exercise by rescaling the Q[n], which is accomplished by multiplying Q0 by√
π and Qn (n̸= 0) by √
π/2. Do this (and simplify and sort the result) by executing one of the following code sequences:
> T[0] := sqrt(Pi)*Q[0];
> for n from 1 to nmax do
> T[n] := sort(sqrt(Pi/2) * Q[n]) end do;
T[0] = Sqrt[Pi] * Q[0]
Do[ T[n] = Expand[Simplify[Sqrt[Pi/2]*Q[n]]],{n,1,nmax}]
11.3 OPERATORS
Exercises
11.3.1. Show that linear operators A and B have the following properties in common with matrices.
Assuming the existence of the quantities involved,
(a) (AB)−1= B−1A−1, (b) (AB)†= B†A†.
(c) If A and B are Hermitian, identify the conditions under which AB is also Hermitian.
(d) If U and V are both unitary, show that U V is also unitary.
186 CHAPTER 11. GENERAL VECTOR SPACES Solution:
(a) A−1 is an operator such that A−1Af = f for all members f of the Hilbert space. This means that A−1A can be removed from any sequence of operators. To verify that (AB)−1 = B−1A−1, rewrite the formula (AB)−1AB = 1 as B−1A−1AB = B−1B = 1.
(b) Note that ⟨f|ABg⟩ = ⟨A†f|Bg⟩ = ⟨B†A†|g⟩, which shows that B†A† is the adjoint of AB.
(c) Using the result of part (b) and the fact that A† = A and B† = B, we establish that (AB)†= BA. Thus AB is not Hermitian unless BA = AB, i.,e., AB is Hermitian only if A and B commute.
(d) U V is unitary if (U V )† = (U V )−1 = V−1U−1. This equation is satisfied because (U V )† = V†U†, with V†= V−1 and U†= U−1.
11.3.2. The time-independent Schr¨odinger equation of an electron in a one-dimensional quantum mechanics problem has (in hartree atomic units) the form Hψ = Eψ, where
H =−1 2
d2
dx2 + V (x),
where V is a real multiplicative operator (i.e., it is a real function of x that contains no derivatives or integrals). Show that the operator H is Hermitian if the Hilbert space is for a finite or infinite interval in x, with its members required to vanish at the ends of the interval, and with a scalar product of definition
⟨χ|φ⟩ =∫
χ∗φ dx .
The integral in the scalar product is over the interval relevant to the Hilbert space.
Solution:
First note that V is Hermitian, because it is a real multiplicative operator and
⟨χ|V φ⟩ =
∫
χ∗V φ dx =
∫
(V χ)∗φ dx =⟨V χ|φ⟩.
Next note that, because χ and φ both vanish at the ends of the interval on which the scalar product is defined, we can integrate by parts twice
∫
This equation shows that d2/dx2is also Hermitian for the Hilbert space presently under discussion.
11.3.3. Explain why A†as given by Eq. (11.32) is the adjoint of A for the vector space defined in the first paragraph of Example 11.3.2.
Solution:
If we insert A†from Eq. (11.32) into the left member of a scalar product, we get (evaluating the delta functions, assuming them to contribute fully even though they are at the endpoints of the integration interval),
⟨A†f|g⟩ = which was shown in the Example to be equal to⟨f|Ag⟩.