Chapter 1
Introduction

1.4 Mathematical Preliminaries

Example 1.3

The evaluation of the Wronskian is straightforward if only two functions are involved, but can become quite cumbersome for a larger number of functions.  Mathematica can be used to carry out the required operations.  The array of functions fk[x] is first defined as the vector F. In the example below, this is carried out for three functions, though the procedure can be extended to any number of functions.

F={f1[x],f2[x],f3[x]}

The functions f1[x], f2[x], and f3[x] are generic; specific functions will be used below.  The Wronskian is then assembled as a Table:

Wronskian[F_]:=Table[D[F,{x,i-1}],{i,3}]

This table of terms can be displayed as a matrix using MatrixForm:

MatrixForm[Wronskian[F]]

and the determinant can be evaluated with Det.

To carry out a specific evaluation, we take as an example the three functions
f1[x]=Sin[x], f2[x]=Cos[x] and f3[x]=Exp[x].  Then,

Simplify[Det[Wronskian[{Sin[x],Cos[x],Exp[x]}]]]

which clearly does not vanish over any finite part of the real line.  As a second example, suppose the trigonometric functions in the preceding example are replaced with their hyperbolic counterparts: f1[x]=Sinh[x], f2[x]=Cosh[x] and f3[x]=Exp[x].  The corresponding evaluation yields:

Simplify[Det[Wronskian[{Sinh[x],Cosh[x],Exp[x]}]]]

The Wronskian vanishes because Exp[x]=Cosh[x]+Sinh[x].

Example 1.4

This Gauss test is most easily applied by making the transformation k->1/n, 
expanding the resulting expression to second order in n and then comparing with (1.28).  The first step is carried out as follows:

Simplify[((n+a)(n+b))/((n+c)(n+1))/.n->1/m]

The expansion in powers of m can now carried out with Series and the substitution m->1/n made afterwards:

Series[%,{m,0,2}]/.m->1/n

This expression is readily seen to be of the form (1.28), with the identifications

delta=-(a+b-c-1)

beta=1-a+(a-1)b-(a+b-1)c+c^2


and with delta=1.  Thus, we conclude that the series (1.29) converges for x=1 if c-a-b>0 and diverges otherwise.

Cauchy Product of Infinite Series

The structure of the product of two series can be determined symbolically in 
Mathematica.  We first define the partial sums A[n] and B[n]:

A[n_]:=Sum[a[k]x^k,{k,0,n}];

B[n_]:=Sum[b[k]x^k,{k,0,n}]

The product in (1.34) is now constructed using Expand and the coefficients of powers of x are assembled with Coefficient.  The results for the first four terms are shown below:

Do[Print[Coefficient[Expand[A[4]B[4]],x^j]],{j,1,4}]

These coefficients are precisely of the form shown on the right-hand side of
Equation (1.37).

Example 1.7

The results obtained in this section can be used to write a few simple commands
in Mathematica to determine various vector operations for any orthogonal 
curvilinear coordinate system.  The package VectorAnalysis.m could also be used to obtain these quantities directly, but the explicit constructions carried out below are a useful illustration of the interplay between scalar and vector quantities in Mathematica.

We consider the spherical polar coordinates as an example.  We first define the 
vectors u and h, whose entries u[[i]] and h[[i]] are the coordinates, u_i, and the scale factors, h_i, respectively:

u:= {r,theta,phi};

h:= {1,r,r Sin[theta]}

The entries of h must be in the same order as those of u, i.e. h[[1]]=h_r, 
h[[2]]=h_theta and h[[3]]=h_phi.  We then calculate the Jacobian using Equation (1.58) and construct the expressions for, say, the gradient of a scalar function in Equation (1.66) and the divergence of a vector function obtained in Problem 12:

J=h[[1]]h[[2]]h[[3]];

Grad[f_]:=Table[D[f,u[[i]]]/h[[i]],{i,1,3}];

Div[f_]:=(1/J)Sum[D[(J f[[i]])/h[[i]],u[[i]]],{i,1,3}];

Notice that Grad returns a vector function, as indicated by the construction of a Table, and that Div operates on vector functions with components given by f[[i]].  The expression for the gradient of a function in spherical polar coordinates is then obtained as

Grad[f[r,theta,phi]]

which is the expression obtained in (1.74).

We can also combine Div and Grad to obtain the Laplacian of a scalar function f by taking the divergence of the gradient of f:

Expand[Div[Grad[f[r,theta,phi]]]]

which agrees with (1.75) when the derivatives are carried out.