The inverse of the mathematical constant e can be approximated as follows: 1/e =
ID: 3818952 • Letter: T
Question
The inverse of the mathematical constant e can be approximated as follows: 1/e = (1 - 1/n)^n Write a script that will loop through values of n until the difference between the approximation and the actual value is less than 0.0001. The script should then print out the built-in value of e^-1 and the approximation to four decimal places, and also print the value of n required for such accuracy. Write a script using for loop to compute the following summation: S = sigma^10_k = 1 1/k^2 Write a script to compute the following equation and print out the results y(x) = {15 Squareroot 4x + 10 x greaterthanorequalto 9 10x + 10 0 lessthanorequalto xExplanation / Answer
%matlab code 1
actualValue = 1/exp(1);
n = 1;
while true
approxValue = power((1- (1/n)),n);
if (actualValue - approxValue) < 0.0001
break
end
n = n + 1;
end
fprintf('Approx value: %0.5f ',approxValue);
%output:
%Approx value: 0.36778
%matlab code 2
sum = 0;
n = 10;
for k=1:n
sum = sum + 1/(k*k);
end
fprintf('Sum: %0.5f ',sum);
%output:
%Sum: 1.54977
%matlab code 3
for x=(-5):30
fprintf('x: %d ',x);
if x >= 9
y = 15*sqrt(4*x)+10
elseif x >= 0
y = 10*x + 10
elseif x < 0
y = 10
end
end
%{
output:
x: -5 y = 10
x: -4 y = 10
x: -3 y = 10
x: -2 y = 10
x: -1 y = 10
x: 0 y = 10
x: 1 y = 20
x: 2 y = 30
x: 3 y = 40
x: 4 y = 50
x: 5 y = 60
x: 6 y = 70
x: 7 y = 80
x: 8 y = 90
x: 9 y = 100
x: 10 y = 104.87
x: 11 y = 109.50
x: 12 y = 113.92
x: 13 y = 118.17
x: 14 y = 122.25
x: 15 y = 126.19
x: 16 y = 130
x: 17 y = 133.69
x: 18 y = 137.28
x: 19 y = 140.77
x: 20 y = 144.16
x: 21 y = 147.48
x: 22 y = 150.71
x: 23 y = 153.87
x: 24 y = 156.97
x: 25 y = 160
x: 26 y = 162.97
x: 27 y = 165.88
x: 28 y = 168.75
x: 29 y = 171.55
x: 30 y = 174.32
%}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.