In Matlab write a script to evaluate the following integral
Solution
Part a) matlab program
clc;clear all;
f = @(z) exp(z); %The part a function
F1 = @(z) f(z)./z; % define the function to be integrated
v = @(theta) exp(1i*theta); % the parameterized unit curve
vprime = @(theta) 1i*exp(1i*theta); % the derivative of v
La = integral(@(t) F1(v(t)).*vprime(t),0,2*pi);% Evaluating the integration
Lc = 1i*2*pi*f(0+0i); % evaluating the cauchy integral formula
% printing the results
fprintf(\'The result of integration = \');
disp(La);
fprintf(\'The result using Cauchy integral formula = \');
disp(Lc);
OUTPUT of the code
The result of integration = 0.0000 + 6.2832i
The result using Cauchy integral formula = 0.0000 + 6.2832i
Part b) matlab program
clc;clear all;
f = @(z) sin(z).^2; %The part b function
F1 = @(z) f(z)./z; % define the function to be integrated
v = @(theta) exp(1i*theta); % the parameterized unit curve
vprime = @(theta) 1i*exp(1i*theta); % the derivative of v
La = integral(@(t) F1(v(t)).*vprime(t),0,2*pi);% Evaluating the integration
Lc = 1i*2*pi*f(0+0i); % evaluating the cauchy integral formula
% printing the results
fprintf(\'The result of integration = \');
disp(La);
fprintf(\'The result using Cauchy integral formula = \');
disp(Lc);
OUTPUT of the code
The result of integration = 1.0755e-16 - 4.4409e-16i
The result using Cauchy integral formula = 0
Part c) matlab program
clc;clear all;
f = @(z) exp(z); %The part b function
F1 = @(z) f(z)./z; % define the function to be integrated
v = @(theta) (-4-4i)+exp(1i*theta); % the parameterized unit curve
vprime = @(theta) 1i*exp(1i*theta); % the derivative of v
La = integral(@(t) F1(v(t)).*vprime(t),0,2*pi);% Evaluating the integration
Lc = 1i*2*pi*f(0+0i); % evaluating the cauchy integral formula
% printing the results
fprintf(\'The result of integration = \');
disp(La);
OUTPUT of the code
The result of integration = -3.2526e-18 + 3.1442e-18i
Remarks
From part a and part b we found that the result of integration and the result of Chausy integral formula are same. The result of integration for part b and c are almost zero only. For part c, If the center shifted to -4-4i the curve is no more contains any poles hence the result of integration will be zero. the result is different from the part a answer.

