In solving Stoke's Theorem problems, I have developed a step by step method. I'm now trying to write a MMA script to help me solve these problems. But I'm a little stuck.
Here's my step by step method, which works well if tediously by hand.
So imagine this problem:
Using Stoke's Theorem, solve the surface integral $F(x,y,z) = Cos(z)i + x^2j + 2yk$ where $C$ is the intersection of the plane $z = 2-x$ and $x^2 + y^2 = 4$. The answer is 8$pi$.
I started my step by step with this code, but bogged down in how to make each vector element from the curl into the $P, Q, R$ of Step 2 and how then to multiply the partial derivatives by $P,Q,R$ in Step 5.
F = {Cos[z], x^2, 2 y}
C = Curl[F, {x, y, z}] (*Step 1*)
g = 2 - x (*Step 3 solving for z of the curve*)
g1 = D[g, x] )(*Step 4*)
g2 = D[g, y]
Thanks for any help.
UPDATE:
Daniel was kind enough to supply some code, which looks great. But I'm trying to reconcile answers from books with how this code solves problems. So his code gives -8pi to a problem where the book says 8 pi. That could be an orientation issue. But here's an example from a UPenn math class (see 1example 1 where Daniel's code says the answer is -4pi, but the professor says "pi." Here's the code I used to evaluate Example 1. Perhaps I misunderstood the application.
f[x_, y_, z_] = {y^2 z, x z, x^2 y^2};
curl[x_, y_] = Curl[f, {x, y, z}];
surf[x_, y_] = {x, y, x^2 + y^2};
surfelem[x_, y_] =
Cross[D[surf[x0, y], x0], D[surf[x, y0], y0]] /. {x0 -> x,
y0 -> y};
reg = ImplicitRegion[x^2 + y^2 == 1, {x, y}];
Integrate[curl[x, y].surfelem[x, y], {x, y} \[Element] reg]
{Pi, Qj, Rk}
format, so it should be no issue to recognize that the output of C is in this format. Then you have a trivial application of this recognition for step 5. The issue I see is how you can find g (I myself would want to see this done within the code, such that I know the method is solid & usable for other cases). $\endgroup$Curl[f, {x, y, z}]
it should readCurl[f[x,y,z], {x, y, z}]
. Then you get 8Pi. However, the integral is independent of how you parametrize the surface. Parametrizing using a region is much more general than an explicite parametrizing. An explicit parametrizing is often hard or impossible to find. $\endgroup$