Write a script file to determine the smallest integer n such

Write a script file to determine the smallest integer n such that n to the negative 3 power is less than 10^-7, that is, n^-3

Solution

% matlab code, Question 14.2

n = 1;
while true
if power(n,-3) < power(10,-7)
break
end
n = n + 1;
end
fprintf(\"Value of n is %d\ \",n);
% output: Value of n is 216


% matlab code question 14.3
sum = 1;
k = 2;
while true
if (abs(sum - log(2))) < power(10,-4)
break
end
sum = sum + power(-1,k-1)/k;
k = k + 1;
end
fprintf(\"The number of required terms are %d\ \",k);
% output: The number of required terms are 5001

 Write a script file to determine the smallest integer n such that n to the negative 3 power is less than 10^-7, that is, n^-3 Solution% matlab code, Question 1

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site