Question: Matlab questions Function Name: getPumpkinPi Inputs: 1. (double) Number of terms to use in approximation Outputs: 1. (double) Result of the approximation Background: Fall is

Matlab questions

Function Name: getPumpkinPi

Inputs:

1. (double) Number of terms to use in approximation

Outputs:

1. (double) Result of the approximation

Background:

Fall is in the air, which means that it's time for pumpkin! While your friends practice their

pumpkin carving skills and drink some pumpkin spice lattes, you decide to bake a pumpkin pie.

You want your pie to be perfectly circular, of course, and for that you need to calculate !

Function Description:

There are many ways to calculate the mathematical constant . One of the ways to do it

is based on the series expansion of the inverse tangent function. This fact will allow you to

calculate :

Matlab questions Function Name: getPumpkinPi Inputs: 1. (double) Number of terms to

This equation relates pi/4 to the sum of 1 for every other odd integer n starting with 3 (so

3,7,11,etc.) subtracted from the sum of 1 for every other odd integer n starting with 1 (so

1,5,9,etc). Write a function that approximates (pi) using this sum, with the number of terms

specified by the input. Round your answer to the sixth decimal place.

For example, if the input was 5, your answer should be:

4*(1-(1/3)-(1/5)-(1/7)-(1/9)= 3.339683

Notes:

The input is guaranteed to be a positive integer greater than 1.

This can and should be done entirely using vector math.

Remember that putting a dot before an operation ( ./, .*, .^ ) performs the operation

element-by-element on a vector.

Do not attempt to simply output MATLAB's built in pi constant; it will not work.

Hints:

Try typing the namesake of this series into the function for a fun easter egg!

tan-1(1)--1)n-12n-12n -1-1-1/3-1/5 -pi/4 7l

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!