In: Math
Create a Matlab program that can evaluate Green Theorem
The vector field is F = ( -y*(1-x-y)+x/4, 2-x^2+y/4 ), the region R consists of the points (x,y) with x^2+y^2<=1. Let C be the boundary curve (counterclockwise). We will find a parametrization of C. We plot the vector field together with C.
Consider a 2D vector field in a circle:
syms x y z t real
Pi = sym('pi');
F = [ -y*(1-x-y)+x/4, 2-x^2+y/4 ];       % vector field F
vectorfield(F,-1:.2:1,-1:.2:1); hold on  % plot vector field
X = cos(t); Y = sin(t);                  % parametrization r=[X,Y] of curve
P = ezplot(X,Y,[0,2*pi]);                % plot curve
set(P,'Color','black','LineWidth',2)     % make curve black, thicker
hold off
Find the work integral W by using Green's theorem:
G = curl([F,0],[x y z])                 % need vector field of 3 components for curl
g = G(3)                                % 3rd component of curl
syms r theta real
X = r*cos(theta); Y = r*sin(theta);     % polar coordinates
gr = subs(g,{x,y},{X,Y})                % substitute polar coordinates for x,y in g
W2 = int(int(gr*r,r,0,1),theta,0,2*Pi)  % integrate gr*r*dr*dtheta
                                        % gives same result as (2a)!
vectorfield(F,-1:.2:1,-1:.2:1); hold on % plot vector field
P = ezplot(cos(t),sin(t),[0,2*pi]);     % plot curve
set(P,'Color','black','LineWidth',2)
ezpcolor(g,[-1.2 1.2 -1.2 1.2]); hold off % plot 3rd curl component
colorbar; colorposneg
title('colors show curl: blue is clockwise, red is counterclockwise')
