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
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:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.