Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Matlab There are a variety of methods for calculating pi. These all involve computing an infinite series, so you can't calculate the exact value of

Matlab

image text in transcribed

There are a variety of methods for calculating pi. These all involve computing an infinite series, so you can't calculate the exact value of pi, but the more terms you compute, the better the approximation. Below are two different ways of calculating pi:~' 1 3 5 7 4 4 4 4. 23 4 456 678 89 10 a) Calculate pi using the first equation. Stop when your answer is within 1e-5 of MATLAB's value of pi. Print out your value of pi and MATLAB's value of pi using 12 digits. Also a. Hint1: Use mod(k,2) to determine if you should be adding or subtracting each b. Hint2: It's helpful to have two counter variables, one that keeps track of even or print out the number of iterations (loops) it took. ~' loop iteration. mod(k,2) returns 0 if k is even, 1 if k is odd. + odd, one that keeps track of where the denominator starts. + b) Repeat a), but using the second equation. c) Which converges faster/took fewer iterations?-' d) Can you represent the actual value of pi in MATLAB? Why or why not? Put your answer in the Word document e) Extra credit, 1096: For each equation count how many operations you needed. An operation is any one of: adding two numbers, multiplying two numbers, assigning to a variable, checking a conditional statement. +J Self-check: First method: xxx,xxx iterations, second method: xx iterations

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions