Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

need matlab code for these questions, make sure it works on r2016a 4.6 The thmet

ID: 3850653 • Letter: N

Question

need matlab code for these questions, make sure it works on r2016a


4.6 The thmetic geometric mean process is a means that can be used to evaluate elliptic integrals. For a the arithmetic-geometric mean process to obtain the complete elliptic integral is as follows cos a When CAl to. where to 1 is the tolerance to which the process is said to have converged to. K(a) where Koa) the complete elliptic integral of the first kind. For a 4 and to 10 s. that this process produces the same value as that obtained from e sin a Use format long e to verify your result

Explanation / Answer

Matlab code:

format long;
clear all;
clc;
a0 = 1;
alpha = pi/4;
b0 = cos(alpha);
t0 = 10^-5;
c0 = sin(alpha);
a = [a0];
b = [b0];

while(true)
anext = 0.5*(a(1,size(a,2)) + b(1,size(b,2)));
bnext = sqrt(a(1,size(a,2)) * b(1,size(b,2)));
a = [a, anext];
b = [b, bnext];
cnew = 0.5*(a(1,size(a,2)) - b(1,size(b,2)));
if(abs(cnew) < t0)
break;
end
end

an = a(1,size(a,2));
k_alpha = pi/(2*an)
ellipk = ellipke(sin(alpha)*sin(alpha))
fprintf('Value of K(aplpha) = %d ', k_alpha);
fprintf('Value of ellipke(sin^2(alpha)) = %d ', ellipke(sin(alpha)*sin(alpha)));

Sample Output: