Checking Stokes' Theorem for ageneral triangle in 3D
Given the positions of three poins $\vec{p}_{0}, \vec{p}_{1}, \vec{p}_{2}$ where $\vec{p}_{j} = x_{j}\hat{x} + y_{j}\hat{y}+z_{j}\hat{z}$ for $ j = 0, 1 , 2 $, they define an oriented plane segment $S$. This plane segment is the triangle with the points as its vertices and oriented by the order $[\vec{p}_{0},\vec{p}_{1},\vec{p}_{2}]$ which means that we go around the boundary visiting the vertices in that order. This order corresponds to the choice of normal vector field $\vec{N} = (\vec{p}_{1}\vec{p}_{0})\times (\vec{p}_{2}\vec{p}_{0})$ The Fundamental Theorem of (all) Calculus says that: $$\int_{\partial S}\, \omega = \int_{S}\, d\omega$$ where $\omega = f_{1}(x,y,z) dx + f_{2}(x,y,z) dy + f_{3}(x,y,z) dz$ is any 1form with the scalar functions $f_{1},f_{2},f_{3}$ smooth functions defined on a region that contains $S$ and where $\partial S$ is the oriented boundary of $S$ and the differential is simply, $$ d\omega = d f_{1}\wedge dx + d f_{2}\wedge dy + d f_{3}\wedge dz $$ A 1form, like $\omega$ is just a linear function of (tangent) vectors or if we define the concatenation of two curves as their sum we can think of $\omega$ as a linear function on curves. Give a one dimensional oriented smooth thingee (a parameterized curve) to $\omega$ and it will give you back a number independent of the way in which you choose to parameterized the curve. This number is the line integral of the 1form along the curve and the maping from curves to numbers is linear. From this point of view the purely algebraic fact that $d^{2}\omega = 0$ (i.e. taking the differential twice) is just the purely geometrical fact that $\partial^{2}S = \phi$ (i.e. the boundary of a boundary is empty; In math lingo taking the boundary is the adjoint to taking the differential).
The algebra of differential forms unifies all the scattered around fundamental theory like theorems including: The standard fundamental theorem of calculus (I), i.e., $$\int_{[a,b]} df(x) = f(a) + f(b)$$ The fundamental theorem for line integrals, i.e., $$\int_C dV(x,y,z) = V(\vec{A}) + V(\vec{B})$$ where $C$ is any smooth curve from $\vec{A}$ to $\vec{B}$ and $V(x,y,z)$ is a scalar field (the scalar potential). Green's theorem on the plane, i.e. $$ \int_{\partial D} P(x,y) dx + Q(x,y) dy = \int_{D} \left(\frac{\partial Q}{\partial x}  \frac{\partial P}{\partial y}\right)\, dA $$ Stokes' theorem, $$\int_{\partial S} \vec{F}\cdot d\vec{r} = \int_{S} (\nabla\times\vec{F}) \cdot d\vec{S} $$ and Gauss' divergence theorem, $$\int_{\partial V} \vec{F}\cdot d\vec{S} = \int_{V} \nabla\cdot \vec{F}\, dV $$ In this notebook we show that Stokes' theorem is in fact true for a general triangle in 3D. Now, if you think about it a little, by noticing that any smooth surface can be well approximated by splitting it into little triangles (a.k.a. triangulation duh!) we are (allmost) proving that Stokes Theorem is true for any (at least triangulatable (is that a word?)) surface. So here is the surface $S$. We are going to need line and surface integration so we "attach" the functions SurfInt.sage defined on our web site. 
Start by defining the points $(p_{0},p_{1},p_{2})$ by their general coordinates and the boundary segments $C_{01},C_{02},C_{12}$ connecting the points (e.g. $C_{12}$ is the straight line segment from $p_{1}$ to $p_{2}$). 
Since we have already defined all these goodies, let's not miss the opportunity to check that the area of the triangle computed with the aid of the geometric definition of the cross product (i.e., A0), coincides with the value given by integration over the surface $S$ (what we call "Area"). 
nice!
{{{id=10 F(x,y,z)=(0,0,2*x+y) cF(x,y,z)=curl(F) Flux1 = surf_int(cF,S,(u,0,1v),(v,0,1)) Flux1 /// \newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{2} \, {\left(z_{0}  z_{2}\right)} {\left(y_{0}  y_{1}\right)} + {\left(z_{0}  z_{2}\right)} {\left(x_{0}  x_{1}\right)}  \frac{1}{2} \, {\left(z_{0}  z_{1}\right)} {\left(y_{0}  y_{2}\right)}  {\left(z_{0}  z_{1}\right)} {\left(x_{0}  x_{2}\right)} }}} {{{id=11 L1 = line_int(F,C01,(t,0,1)) L2 = line_int(F,C12,(t,0,1)) L3 = line_int(F,C02,(t,1,0)) L1;L2;L3 /// \newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{2} \, {\left(z_{0}  z_{1}\right)} {\left(2 \, x_{0} + 2 \, x_{1} + y_{0} + y_{1}\right)} \newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{2} \, {\left(z_{1}  z_{2}\right)} {\left(2 \, x_{1} + 2 \, x_{2} + y_{1} + y_{2}\right)} \newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{2} \, {\left(z_{0}  z_{2}\right)} {\left(2 \, x_{0} + 2 \, x_{2} + y_{0} + y_{2}\right)} }}} {{{id=12 (Flux1  (L1+L2+L3)).full_simplify() /// \newcommand{\Bold}[1]{\mathbf{#1}}0 }}}In the next cell we try something a bit more general for the field. Notice that every vector field in a region of $R^{3}$ can be written as, $F = f \hat{x} + g\hat{y} + h\hat{z}$ where $f,g,h$ are smooth functions of $(x,y,z)$ in the region where $F$ is defined. We have that $$\nabla \times F = \nabla\times (f\hat{x}) + \nabla\times (g\hat{y}) + \nabla\times (h\hat{z})$$ Therefore, if we can show that Stokes' theorem is true for any smooth vector field parallel to one of the axis then by linearity it will be true for every vector field. Moreover, every smooth enough scalar function can be well approximated by a (multivariate) power series. With these considerations, the fact that Stokes' theorem holds for the vector fields of the form $$F = x^{i}y^{j}z^{k}\hat{z},$$ as we check in the cell below, makes it very likely that it will hold for all vector fields. 
