****
The line integral in two dimensions is:
/
|
| P(x, y)dx + Q(x, y)dy
|
/ C
where x, y are the coordinates along the integration path C. The integration path itself can be specified by the coordinates of its points in terms of a parameter t:
x = f(t), y = g(t)
For three dimensions, we have:
/
|
| P(x, y, z)dx + Q(x, y, z)dy + R(x, y, z)dz
|
/ C
where x, y, z are the coordinates along the integration path C. The integration path itself can be specified by the coordinates of its points in terms of a parameter t:
x = f(t), y = g(t), z = h(t)
We consider this integrand:
integrand: x^2*y*diff(x) + y*z*diff(y) + z*x*diff(z);
2
x z del(z) + y z del(y) + x y del(x)
and this integration path:
path: [x = cos(t), y = sin(t), z = sin(t)];
[x = cos(t), y = sin(t), z = sin(t)]
The coordinates of this path are substituted into the integrand:
sublis(%, integrand);
We obtain:
2
sin (t) del(sin(t))
+ cos(t) sin(t) del(sin(t))
2
+ cos (t) sin(t) del(cos(t))
Now we have to evaluate the derivatives:
ev(%, diff);
2 2 2 2
- cos (t) sin (t) del(t) + cos(t) sin (t) del(t) + cos (t) sin(t) del(t)
To integrate this expression, we remove the del(t):
%, del(t) = 1;
2 2 2 2
- cos (t) sin (t) + cos(t) sin (t) + cos (t) sin(t)
Now we can integrate
integrate(%, t, 0, 2*%pi);
and obtain:
%pi
- ---
4
The computation of the line integral requires four steps:
To simplify this computation and to reduce the risk of typing errors, it is convenient to put these four steps into a function definition:
lineIntegral(fn, path, param, p0, p1) :=
block ( [substitutedFn, x, xx],
substitutedFn: sublis(path, fn),
x : ev (substitutedFn, diff),
xx: subst(1, diff(param), x),
integrate(xx, param, p0, p1)
)$
You find this definition in file lineInt.mc.
Here is the above example again:
lineIntegral(x^2*y*diff(x) + y*z*diff(y) + z*x*diff(z),
[x = cos(t), y = sin(t), z = sin(t)],
t, 0, 2*%pi);
%pi
- ---
4
An example from Spiegels book "Theory and Problems of the Laplace Transforms":
lineIntegral ((x^2 - y)*diff(x) + (y^2 + x)*diff(y),
[x = t, y = t^2 + 1],
t, 0, 1);
2