Question: 1. Write a function that computes the value of the mathematical constant z. The value of can be approximately computed using the infinite series

1. Write a function that computes the value of the mathematical constant . The value of can be approximately

1. Write a function that computes the value of the mathematical constant z. The value of can be approximately computed using the infinite series = 4(1-1/3+1/5 - 1/7 + 1/9 - 1/11+1/13 - 1/15 + . . . . ..) The function prototype is double compute_pi(int n). The function computes the value of using the first n terms of the infinite series and returns the value. 2. Write a function that computes the square root of a number. The square root of a number x can be approximately computed as follows. First guess that the square root of x is 1. Then repeatedly get the next guess from the last guess using the rule next = 0.5(last +x/ last) where last is the last guess and next is the next guess. Repeat ten times using a loop and the tenth guess will be approximately the square root. The function prototype is double compute_sqrt (double x). The function computes the square root of x and returns the square root.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Here are the implementations for both functions Function to compute the value of using the given inf... View full answer

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 Programming Questions!