subject
Engineering, 04.04.2020 01:34 jordan8037

The value of a can be estimated from the following equation: 173 (-1) - = (2n + 1)3 n=0 (15 pts) Write a MATLAB program in a script file HW7P1.m that does the following: i. determines the sum in the previous equation by adding terms until the value of the Nth term is less than a specific tolerance or the number of added terms exceeds 30, whichever is reached first. Use a for loop with a break statement to solve this problem. The script must prompt the user to enter the required tolerance. The program must determine the number of terms added to reach the given tolerance taking into account that term 1 is that corresponding to n = 0. This can be done by generating a counter for the loop that determines the number of passes the loop takes until it ends. determines (Pi) from the previous equation. Use upper case (Pi) to distinguish between the calculated it and the MATLAB built in (pi). creates a variable called Err pi that refers to the absolute difference between the value of your n (Pi) and the value of the MATLAB variable (pi). uses fprintf inside the loop to display the calculated Pi variable in each pass with 8 decimals in f format and the Err pi with 5 decimals in E format as: The first 3 iterations when you run your script will be: For n = 1, Pi = 3.1351129170, and Err_pi= 6.47974E-03 For n = 2, Pi = 3.1437708364, and Err_pi= 2.17818E-03 For n = 3, Pi = 3.1406211449, and Err_pi= 9.71509E-04 if the program needs more than 30 terms to reach the required tolerance, the program must display: vi. The program failed to reach the required tolerance in the allowable number of terms. Where is a line of asterisks displayed using the disp function. vii. Run your script with tolerances 10-5 and 10-10. The program must display the message in Part vi for the 2nd tolerance. (10 pts) Write another version of your program as a function file PI. m that does not take any input arguments and returns the value of from the previous equation. The function PI must use a while loop to determine the sum and terminates once the value of the nth term is less than a tolerance of the 10-10. To avoid infinite loop, the number of terms added must not exceed 1000 terms. The function must not display anything. You must check the value of your function by verifying that abs (PI-pi)<=le-10.

ansver
Answers: 1

Another question on Engineering

question
Engineering, 03.07.2019 19:30
When using the ohmmeter function of a digital multimeter, the leads are placed in what position relative to the component being tested? a. parallel b. control c. series d. line
Answers: 3
question
Engineering, 04.07.2019 18:10
Slip occurs via two partial dislocations because of (a) the shorter path of the partial dislocation lines; (b) the lower energy state through partial dislocations; (c) the charge balance.
Answers: 1
question
Engineering, 04.07.2019 18:20
Inspection for bearing condition will include: (clo4) a)-color b)-smell c)-size d)-none of the above
Answers: 1
question
Engineering, 04.07.2019 18:20
For a gate width of 2 m into the paper, determine the force required to hold the gate abc at its location.
Answers: 1
You know the right answer?
The value of a can be estimated from the following equation: 173 (-1) - = (2n + 1)3 n=0 (15 pts) Wri...
Questions
question
English, 11.02.2021 03:20
question
Mathematics, 11.02.2021 03:20
question
Social Studies, 11.02.2021 03:20
question
Mathematics, 11.02.2021 03:20
question
Biology, 11.02.2021 03:20
Questions on the website: 13722362