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

Other questions on the subject: Engineering

image
Engineering, 04.07.2019 18:10, viicborella
Steel is coated with a thin layer of ceramic to protect against corrosion. what do you expect to happen to the coating when the temperature of the steel is increased significantly? explain.
Answers: 1
image
Engineering, 04.07.2019 18:20, kendrawalraven
The characteristic roots of a dynamic system are: 1.7920 1.8160 i, -1.7920 1.8160 i, -0.4160 what is the order of this system? what are the settling time and damping ratio of the system?
Answers: 3
image
Engineering, 04.07.2019 19:10, babas97
What is a monomer? how do they form a ploymer from the view point of chemical bonding?
Answers: 1
image
Engineering, 06.07.2019 03:20, cherkaouinazihp387bk
Figure out the odd statement about ceramics in the following (a) good insulators of heat and electricity (b) usually less desire than metals (c) ductile in nature (d) contains both metallic and nonmetallic elements
Answers: 3
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 in other subjects:

Konu
Mathematics, 05.03.2020 23:28
Konu
Mathematics, 05.03.2020 23:29