1. Write a function that computes the value of the mathematical constant z. The value of...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. 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.
Expert Answer:
Answer rating: 100% (QA)
Here are the implementations for both functions Function to compute the value of using the given inf... View the full answer
Related Book For
Numerical Methods With Chemical Engineering Applications
ISBN: 9781107135116
1st Edition
Authors: Kevin D. Dorfman, Prodromos Daoutidis
Posted Date:
Students also viewed these programming questions
-
The Julian calendar was a reform of the Roman calendar introduced by Julius Caesar in 46 BC (708 AUC). It took effect in 45 BC (709AUC). It was the predominant calendar in most of Europe, and in...
-
During a semester, a class of n=50 students took two exams: a midterm and a final. The mean score for the midterm exam is 80 points with the standard deviation of 6 points. The mean score for the...
-
A. Determine the cost of the goods sold for the September 30 sale. B. Determine the inventory on September 30. Beginning inventory, purchases, and sales for an inventory item are as follows: 31 units...
-
Find the total distance between Grove City and Jerome. 6.7 miles Grove City amid 19.9 miles 15.1 miles Jerome Coin Alanthus 10.9 miles
-
In Exercise 57, approximately how long will it take to use up the account? Exercise 57 A retirement savings account contains $300,000 and earns 5% interest compounded continuously. The retiree makes...
-
An electron that has a kinetic energy of \(7.5 \times 10^{-17} \mathrm{~J}\) moves in a circular orbit perpendicular to a uniform magnetic field of magnitude 0. 35 T. For this electron, determine...
-
Wingler Communications Corporation (WCC) produces premium stereo headphones that sell for $28.80 per set, and this years sales are expected to be 450,000 units. Variable production costs for the...
-
What two different types of firmware may be used on motherboards? a. POST b. UEFI c. CMOS d. BIOS
-
Bong, Harry and Mallu formed a partnership to carry on the business of an ethnic store in Bangkok. They are to receive equal shares of the profits and can make drawings during a year, not exceeding...
-
Students have a right to have their case heard within a reasonable amount of time. True False
-
Answer each of the following questions. Model each problem with input cells to allow for flexibility in answering similar questions. Interest rates are stated as simple annual rates. 1. If you invest...
-
An annuity certain is payable monthly in advance for 40 years. The annuity is to be paid at the rate of 100 pa for the first 20 years, 120 pa for the next 5 years and 200 pa for the last 15 years....
-
After graduating from college in May 2018, Ryan Crews started his career in finance at the W&T Corporation, a small- to medium-sized warehouse distributor in Nashville, Tennessee. The company was...
-
What an example STAR (Situation, Task, Action, Result.) question for a Accounting example on how there was a time when you had a disagreement with someone. As for context use a excel project?
-
Find a trade (amount of wine exchanged for amount cheese) that makes both countries better off in both goods relative to when no trade was allowed. What is the consumption point in each country with...
-
3. What was the issue and holding in Epic Systems v Lewis? 4. What was the issue and holding in Keller v. Miri Microsystems?
-
Suppose Green Network Energy needs to raise money to finance its new manufacturing facility, but their CFO does not think the company is financially capable of making the periodic interest payments...
-
Write a MATLAB program that uses RK4 to solve the ODE subject to the initial conditions y(0) = 1 and y(0) = 0. You should compute the solution for the step size h = 0.01. Make a plot of the function...
-
Answer the following questions about this code: (a) What mathematical problem is being solved? (b) What numerical method is used to solve the problem? (c) What is the significance of the value of n...
-
What is the determinant of the following matrix? 4-3 0 1 0 0 0 0 4 2 -0.25 0 2 1 3 10
-
Classic LEGO plastic bricks have been fixtures in homes around the world for more than 70 years. Just 15 years ago, The LEGO Group (TLG) was near bankruptcy, spiraling downward and losing money at a...
-
For a sample of data where n = 7 given below: a. Calculate the mean, median, and mode. b. Calculate the range, variance, standard deviation, and coefficient of variation. c. Calculate the Z score....
-
For a sample of data where n = 6 given below: a. Calculate the mean, median, and mode. b. Calculate the range, variance, standard deviation, and coefficient of variation. c. Calculate the Z scores....
Study smarter with the SolutionInn App