On Series — An Addendum

Plus, a little primer on writing packages.

On Variables

Suppose we have a Lagrangian that contains two parts: the "kinetic" term and the "potential" term. In scientific literature, we'd write this as \(TraditionalForm\`L = \(m\/2\) \((\(x\& . \))\)\^2 - λ\/\(cosh(x)\)\). Just for the fun of it, let's plot the potential:

Plot[-1/Cosh[x], {x, -5, 5}];

OK, so this is a potential well, and a system governed by this Lagrangian may have bound states. Of interest is the also the Hamilton-Jacobi action functional, \(TraditionalForm\`S := \(∫dt\ L = ∫d\(t(\(m\/2\) \((\(x\& . \))\)\^2 - λ\/\(cosh(x)\))\)\)\).

Now, examine this functional: on what precisely does it depend?

Interal vs. External Variables

Most obviously, it depends on the choice of values of the parameters m and  λ—whatever the physical interpretation of those. That is—everything else held fixed—we vary the value of, say, m and the value of S changes too. Thus, S is a non-trivial function of m. By the same token, it is also a nontrivial function of λ.

Now: does S depend on time?

That depends: I have not specified the limits on the integral. But, depending on the use of S, we may wish to integrate from some specified (Subscript[t, 0]), to a variable time, t. If so, then S:=(∫_(Subscript[t, 0])^t)\(d\(τ(\(m\/2\) \((d\ \(x(τ)\)\/d\ τ)\)\^2 - λ\/\(cosh(x(τ))\))\)\) depends on both of the limits, (Subscript[t, 0]) and t.

Thus, S is really an "ordinary" function of m,  λ,  (Subscript[t, 0]) and t.

…and S does not depend on τ! That is to say, we can set τ to be whatever we please, the instructio for integrating in S:=(∫_(Subscript[t, 0])^t)\(d\(τ(\(m\/2\) \((d\ \(x(τ)\)\/d\ τ)\)\^2 - λ\/\(cosh(x(τ))\))\)\) will (must, in fact) be unaffected by this: within the integral, the dummy variable τ is simply a completely separate placeholder for that variable which we use to compute the integral. It is a local or internal variable.

By contrast, m,  λ,  (Subscript[t, 0]) and t are all global or external variables.

When writing a Module or a Package, you must distinguish betwee the two kinds of variables. Both in your mind, and in the program.

Internal variables are declared within the Module or Package, so Mathematica would know to assign to them a separate interal place-holder (memory/storage location). External variables must not be declared, so that Mathematica would keep using the same place-holder (memory/storage location)—in case this variable is being addressed externally.

Internal variables are "private" to the Module or Package, and there is no way to interfere with them from outside. External variables are a common the the innards of the Module or Package and the outside computations, and are a way to pass values back and forth.

What's With the -al in Name Functional?

We've established that S:=(∫_(Subscript[t, 0])^t)\(d\(τ(\(m\/2\) \((d\ \(x(τ)\)\/d\ τ)\)\^2 - λ\/\(cosh(x(τ))\))\)\) depends on m,  λ,  (Subscript[t, 0]) and t just as "ordinary" functions do: you change the value of, say, m, and the value of S changes too.

But, how does it depend on x?

It is not the value of x upon what S depends—for, x doesn't even have a value, per se, much as sin, log, exp, tanh have no particular value either! They are functions. You need to specify a choice of—not a value, but—a functional dependence of x upon its argument, and that is upon what S depends. So, since S does not depend upon a choice of a value of x, but upon the choice of a functional dependence, it is a function of a 2nd order: a function that depends on a function, which in turn depends on a value. We call such "2nd level functions"—functionals. Clearly, you can make this ridiculous by defining functions of functions of⋯of functions of values, i.e., functionalal⋯als, and at that point we rather call then nth level/order/type functions, or somesuch.

Now, for our purposes, we need to tell a Module or a Package designed to compute S[x(t); m, λ, (Subscript[t, 0]), (Subscript[t, 1])]:=(∫_(Subscript[t, 0])^(Subscript[t, 1]))\(d\(τ(\(m\/2\) \((d\ \(x(τ)\)\/d\ τ)\)\^2 - λ\/\(cosh(x(τ))\))\)\) that it depends on the choice of the function x: what I just wrote is a common abuse of notation—there is no variable t! What we mean is that x is a function of a variable, which—according to the specification of the integration—is going to be substituted by the strictly internal variable of the integration itself. And, since this, τ, is an internal variable, we must not use it externally. An external τ has nothing to do with the internal, local, dummy integration τ. So, some authors prefer to write S[x(·); m, λ, (Subscript[t, 0]), (Subscript[t, 1])] instead. We also tend to separate the types of variables by a semicolon rather than by a comma.

Passing Variables

Now, you may decide to fix the value of m once and for all, or leave it an unspecified symbol.

In that case, m need not be specified as an argument of S[x(·); λ, (Subscript[t, 0]), (Subscript[t, 1])].

The remaining variables, x(·), λ, (Subscript[t, 0]) and (Subscript[t, 1]) are being passed between the external computation and the functional S, like the batton in relay-running.

Expansions

Finally, what does this have to do with series?

Well, a typical theoretical physics computation would be to determine the equation of motion stemming from the Lagrangian, and then solve it, if possible.

To this end, we write something like \(TraditionalForm\`\(d\/d\ 
                t\) \((∂\ L\/∂\ \((\(x\& . \)(t))\))\) = ∂\ L\/∂\ \((x(t))\)\). The partial derivative on the left-hand side, with respect to \(TraditionalForm\`\(x\& . \)(
          t) := ∂\ \(x(t)\)\/∂\ t\) is independent from the lartial derivative with respect to x(t).

So the next question is (supposing you have already defined a Module or a Package to compute S[x(·); λ, (Subscript[t, 0]), (Subscript[t, 1])]—or a correspondingly similar Module or Package to compute L[x(t); λ, t]), how do you tell Mathematica to compute the left-hand side of the Euler-Lagrange equations of motion?

Bu, more importantly: we routinely need to do things like expand the potential into a Taylor series, and approximate the Lagrangian and the Action with only a couple of initial terms. So, how do you tell Mathematica to expand S[x(·); λ, (Subscript[t, 0]), (Subscript[t, 1])] or L[x(t); λ, t] so that the result is no more than, say, fourth order in x(t) and/or its derivatives?

Note that in this case, the "kinetic" and the "potential" terms are exclusive functions of either \(TraditionalForm\`\(x\& . \)(t)\) or x(t), but not both. (Of course, this need not be the case in your research; you may well encounter a more general case!)

Here's how: substitute your functional F[x(·); ⋯] -> 
        F[ξ x(·); ⋯], and expand it in ξ to the desired order, and then "normalize" it, using Normal[
          Series[F[ξ x(·); ⋯], {ξ, 0, 
              4}]] /. {ξ -> 1}.

Eh?

Happy Thanksgivings!