# calculus and analysis – Right code for solving Stoke’s Theorem problem

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.