Path Integrals

For my multivariable calculus class, I wanted an easy-to-call suite of symbolic integrators for path integrals of the form

\int_C f(x,y) dr,

\int_C {\bf F}(x,y)\cdot d{\bf r} = \int_C \langle P(x,y), Q(x,y) \rangle\cdot \langle dx, dy \rangle, or

\int_C {\bf F}(x,y,z)\cdot d{\bf r} = \int_C \langle P(x,y,z), Q(x,y,z), R(x,y,z) \rangle\cdot \langle dx, dy, dz \rangle.

My overarching design idea was that the input arguments needed to look the way they do when I teach the course:

  • a scalar field f(x,y):R^2 \rightarrow R or a vector field  {\bf F}(x,y): R^2 \rightarrow R^2 or {\bf F}(x,y,z): R^3 \rightarrow R^3
  • a curve C defined by a vector-valued function {\bf r}(t): R \rightarrow R^n, a\le t \le b where n=2,3 as appropriate.

It took me a while to work out how to evaluate the integrand along the path within my function.  Things that worked fine on the command line failed when embedded into a batch file to which I passed functions as arguments.  I ended up using subst, one variable at a time.  I’d like to be able to do this in a single command which can detect whether we’re in 2 or 3 dimensions so that I don’t need separate commands.

For now, here’s what I came up with along with some illustrative examples taken from Paul’s online math notes, that show how to call these new commands I, I2 and I3.

/* path integral of a scalar integrand f(x,y) on path r(t) in R^2, t from a to b */
 I(f,r,t,a,b):=block(
 [f1,f2,dr,Iout],
 f1:subst(x=r[1],f),
 f2:subst(y=r[2],f1),
 dr:sqrt(diff(r,t).diff(r,t)),
 Iout: integrate(f2*dr,t,a,b),
 Iout
 );
/* path integral of a vector integrand F(x,y) on path r(t) in R^2, t from a to b */
 I2(H,r,t,a,b):=block(
 [H1,H2,I],
 H1:subst(x=r[1],H),
 H2:subst(y=r[2],H1),
 I: integrate( H2.diff(r,t),t,a,b),
 I
 );
/* path integral of a vector integrand F(x,y,z) on path r(t) in R^3, t from a to b */
 I3(H,r,t,a,b):=block(
 [H1,H2,H3,I],
 H1:subst(x=r[1],H),
 H2:subst(y=r[2],H1),
 H3:subst(z=r[3],H2),
 I: integrate( H3.diff(r,t),t,a,b),
 I
 );

PathIntegrals

Here’s an update:  a related maxima function for evaluating a complex integral

\int_\Gamma f(z) dz

where f: C \rightarrow C and the curve \Gamma is given by r: R \rightarrow C.

/* path integral of a complex integrand f(z): C --> C, on path z(t): R --> C, t from a to b */
IC(f,r,t,a,b):=block(
[f1,dz,Iout],
f1:subst(z=r,f),
dz:diff(r,t),
Iout: integrate(f1*dz,t,a,b),
Iout
);

ComplexIntegral

Advertisements

One thought on “Path Integrals”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s