% FILE d015hlp.m begins. % MME08 harj 1 teht 5 % Use random numbers such that the RHS series converge % Choose mmax terms for each sum, mmax large % Use terms a_k = rand *1/k, b_k = rand *1/k close all for tst=1: 10 % counter for test number mmax=1000+fix(10000*rand); a= (1:mmax); a=(1./a).*rand(1,mmax); b= (1:mmax); b=(1./b).*rand(1,mmax); rhs1=sum(a.^2); rhs2=sum(b.^2); lhs=0; %The values of the left hand side % will be accumulated in this variable for ii=1:mmax for jj=1:mmax lhs= a(ii)*b(jj)/((ii-1)+(jj-1) +1); end % end of jj loop end % end of ii loop rhs=pi*sqrt(rhs1*rhs2); % The right hand side of the inequality fprintf('%2d. Test with %6d terms: RHS-LHS = %g\n',tst,mmax,rhs-lhs) end % end of tst loop % FILE d015hlp.m ends.