Question: Using c++ Trapezium function: double trapezium(int trapezoids, double interval_start, double interval_end) { double span = (interval_end - interval_start) / trapezoids; int iter = 0; double

Using c++  Using c++ Trapezium function: double trapezium(int trapezoids, double interval_start, double interval_end)
Trapezium function:
double trapezium(int trapezoids,
double interval_start,
double interval_end) {
double span = (interval_end - interval_start) / trapezoids;
int iter = 0;
double sum = 0;
double x_0 = interval_start;
while (iter
sum += (span / 2) * (f(x_0) + f(x_0 + span));
//prep next iter: move x_0, increment iter
x_0 = x_0 + span;
iter++;
}
return sum;
}
B. (20 points) Approximating the Value of the Fresnel Integral, Cx) The Fresnel integrals: appear in a number of areas of science and engineering Write a C+ program that has the user input a positive value (of type double) and a positive value MaxTrapezoids (of type int), and then approximates C) using the Trapezium integration method First appeoximate Cr) using the Trapezium method with 1 trapezoid thee with 2 trapezoids, and so on, each time increasing the number of trapezoids by one until the last estimate uses MaxTrapeziods trapezoids. For each approximation, the program should print out the number of rapezoids used in that estimate and the result of the estimate This process should be in a user-controlled coetinuation loop, as shown in the following example (user input is in Bold foet): Enter x: 3.14159265 Enter of Estimates (trapezoids) C(x) 0.03283499 1-14969834 0.71268699 0-72872487 0.05055231 Continue? (y/a): y Ester of Estinates eeapezolds):5 C(x) 0480969 0-49096596 49156568 499 Continue7 (y) Additienal Constraints le addinion to the coestints implis ily specified in the peoblem speciScation abovE, your progran should ohere to following constnm i Use the trapeziun sumerical ine function in your solution You should opy the urapeziutm function bom the class Moodle site, and use it eacly a This awigement does ask you to write ert odify thi!nction, only 10 uie MasTrapenoids from the user. The values should be a positive real value Sor x and a pesitive tieger value fr MasTrapnoidThe faction should check tocmureach value ctered is function should conninue in this will be called by the traperium function to approsimate the intiegral of C v. Print out the approxmation oraz) with dlph tothe ngofthe decimal vi Your solution should inclade a continuation loop that anks the user if they would bke to continu er a value for Clr) is saccessfully compuled and peined out only asks y to compne the Note that although tw are t Fresnel functions, tis rog values of one of then, nanely Ca vil Define a global conslant amed Pl in your progam and set it to the value: 3.14199265

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!