Greens theorem
$$M(x,y), N(x,y)\text{ be continuous in a region} R\text{ of }xy\text{ plane bounded by a closed curve }c\text{ then}$$ $$\oint Mdx+Ndy=\int \int_R \frac{\partial N}{\partial x}-\frac{\partial M}{\partial y} dxdy$$
Algorithm
$$\text{Create a function for LHS: Evaluate }\oint Mdx+Ndy\text{ along the curve using Line integral}$$
$$\text{Create a function for RHS: Evaluate }\int \int_R \frac{\partial N}{\partial x}-\frac{\partial M}{\partial y} dxdy\text{ using multiple integrals}$$
$$\text{Check whether LHS=RHS or not}$$
%%%%%%%%%%%%%%%% Main Program %%%%%%%%%%%%%%%%%%
clc
clear
syms
x y
LHS=0;
%Get the number of sub path in the curve C
n=input("How many sub curves are ther in the curve C?
:")
%Calculate the line integral along each path (LHS)
for i=1:n
line(i)=LineIntegral(x,y);
LHS=vpa(LHS+line(i))
end
%Calculate the double integral (RHS)
RHS=vpa(MultiIntegral(x,y))
%%%%%%%%%%%%%%%% Main Program ends %%%%%%%%%%%%%%%%%%
%Define function for Line integral
function line
= LineIntegral(x,y)
option=input("1: y=f(x)\n2: x=g(y)\n")
switch option
case 1
y=input("Enter
the function f(x): \n")
r=[x y];
F=input("Enter the vector function
F(x,y)=[F1 F2]: F(x,y)=")
dr=diff(r,x);
integrand1=dot(F,dr);
xL=input("Enter
the lower limit of x:");
xU=input("Enter
the Upper limit of x:");
line=int(integrand1,x,xL,xU)
case 2
x=input("Enter
the function g(y): \n")
r=[x y];
F=input("Enter
the vector function F(x,y)=[F1 F2]: F(x,y)=")
dr=diff(r,y);
integrand1=dot(F,dr);
yL=input("Enter
the lower limit of y:");
yU=input("Enter
the Upper limit of y:");
line=int(integrand1,y,yL,yU)
otherwise
fprintf("Give
the proper input")
end
end
%%%%%%%%%%%%%%%% Line Integral definition ends %%%%%%%%%%%%%%%%%%
%Define function for Double integral
function d
= MultiIntegral(x,y)
M=
input("Enter the M(x,y): ");
N=
input("Enter the N(x,y): ");
f=diff(N,x)-diff(M,y);
disp('f(x,y) :');
disp(f);
xL=input("Enter lower limit of x: ");
xU=input("Enter Upper limit of x: ");
yL=input("Enter lower limit of y: ");
yU=input("Enter Upper limit of y: ");
d
= int(int(f,y,yL,yU),x,xL,xU);
end
%%%%%%%%%%%%%%%% Double Integral definition ends %%%%%%%%%%%%%%%%%%
Output
How
many subcurves are ther in the curve C? :3
n
=
3
1:
y=f(x)
2:
x=g(y)
1
option
=
1
Enter
the function f(x):
0
y
=
0
Enter
the vector function F(x,y)=[F1 F2]: F(x,y)=[y-sin(x) cos(y)]
F
=
[-sin(x),
1]
Enter
the lower limit of x:0
Enter
the Upper limit of x:pi/2
line
=
-1
LHS
=
-1.0
1:
y=f(x)
2:
x=g(y)
2
option
=
2
Enter
the function g(y):
pi/2
x
=
1.5708
Enter
the vector function F(x,y)=[F1 F2]: F(x,y)=[y-sin(x) cos(y)]
F
=
[-
1 + y, cos(y)]
Enter
the lower limit of y:0
Enter
the Upper limit of y:1
line
=
sin(1)
LHS
=
-0.1585290151921034933474976783697
1:
y=f(x)
2:
x=g(y)
1
option
=
1
Enter
the function f(x):
2*x/pi
y
=
(2*x)/pi
Enter
the vector function F(x,y)=[F1 F2]: F(x,y)=[y-sin(x) cos(y)]
F
=
[(2*x)/pi - sin(x), cos((2*x)/pi)]
Enter
the lower limit of x:pi/2
Enter
the Upper limit of x:0
line
=
1
- sin(1) - pi/4
LHS
=
-0.78539816339744830961566084581988
Enter
the M(x,y): y-sin(x)
Enter
the N(x,y): cos(y)
f(x,y)
:
-1
Enter
lower limit of x: 0
Enter
Upper limit of x: pi/2
Enter
lower limit of y: 0
Enter
Upper limit of y: 2*x/pi
RHS
=
-0.78539816339744830961566084581988
No comments:
Post a Comment