Question: Complete this program in C: integrate the function f(x) = 4.0 (1.0+ x 2 ) between [0, 1]. The true answer is exactly PI. You

Complete this program in C:

integrate the function f(x) = 4.0(1.0+ x2) between [0, 1]. The true answer is exactly PI. You should know math.h has a constant, M_PI.

We really want to exercise the machine on this, so you should approximate the value for 512 subintervals. Then double the number of subintervals until you exceed one billion.

At each step, you should print: #intervals, approximation, error from true answer. For the error, we want absolute value, and were really just interested in the power of 10 of the error (so the %e format specification is perfect). For example:

#intervals approximation error

512 3.14159201780692 6.36e-07

1024 3.14159249464407 1.59e-07

2048 3.14159261385336 3.97e-08

268435456 3.14159265358987 8.04e-14

536870912 3.14159265358994 1.52e-13

1073741824 3.14159265359012 3.31e-13

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!