What is the code for this problem, problem4? ne8e1. .The script should compare t
ID: 3888781 • Letter: W
Question
What is the code for this problem, problem4?
ne8e1. .The script should compare the chosen weapons and determine whether the human player won, lost, or tied. The result should be displayed using correct terminology, eg. "Rock crushes Scissors (you lose)", or "Lizard poisons Spock (you win)" . Title your m-file hmk3 3.m 4. Write two scripts to compute the value of pi using the following series: 16 2 (21-1)2 (2i + 1)2 Each of your scripts should print to screen the answer to the following questions: a. (While loop) How many terms are needed to obtain an accuracy of le- 12? b. (For loop) How accurate is the sum of 100 terms of this series? . Title your while loop m-file hmk3 4a.m and the for loop hmk3 4b.m 5. Consider the given algorithmic flowchart: STARTExplanation / Answer
2751 iteration required
CODE:
sum = 0;
i = 0;
while abs(sum - ((pi^2 - 8)/16)) > 1e-12
i = i + 1;
sum = sum + 1/((2*i + 1)^2 * (2*i - 1)^2);
end
i
usin for loop
sum = 0;
for i = 1:100
sum = sum + 1/((2*i + 1)^2 * (2*i - 1)^2);
end
disp( abs(sum - ((pi^2 - 8)/16)))
answer is 2.0524e-08