Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Mentioned codes: Receiving your integrand To allow your code to take arbitrary integrands that follow the type signature (pattern of input types and output type)
Mentioned codes:
Receiving your integrand To allow your code to take arbitrary integrands that follow the type signature (pattern of input types and output type) your integration functions will take a function pointer. In the lab repository under the example sub-dir, there is a version of the funcp.c code split between two files. The file main.c has the square function removed. Instead, on the third line is double ext_func(double); This is called a forward declaration, it tells the compiler that "there exists some function 'ext func' that takes a double and returns a double". If you look in the other file, ext_func.c you will find the definition of this function (Note: the name of the C file doesn't have to match the name of the function - this is just a coinci- dence, but the name of the function prototype in main does have to match the name of the actual function). Compile the program by providing both files to the compiler: gcc main.c ext_func.c Run the resulting binary, it should work identically to the single file version. For your project, the autograder will supply its own main and integrand functions and use your integration functions. All 4 of your integration functions should be in a file called integration.c in the base of your lab repo. Make sure you name your functions exactly as named in the template/main.c file and follow the argument order described in the template integration file. You may test your code by copying the template/main.c file to the base of your lab repository, adding the forward declarations of the functions, and compiling the main.c and integration.c files together. 7.7.1 Exercises Each method will be worth 40 points with the following breakdown: 10 Points: Correctly compiling code 20 Points: Correct implementation of the listed integration method 10 Points: Complexity analysis in your report (see the report section below) Each should take any univariate integrand as well as the bounds of the definite integral with all numbers being of type double. In addition, the Gauss Quad function must take an integer specifying the order between 1 and 10 inclusive. Exercise 1. Midpoint Rule (also known as the Rectangle Rule): b sm)dx = (b a)s (67") Exercise 2. Simps Ssayde ar 653 [s(a) + (1974) + s(m) f () dx = f(a) + 4f1 Exercise 3. Simpson's : flode z 6 ay [r(+ 35 () + 31 (52) +50)] Exercise 4. Gauss Quad: f(x) dx = m) wif(c + mt.) Ja [lede z m ms(+ mt) = c+mt c= }(+a) m = 5(6 a) Where: And the values of t and w can be found at http://www.public.iastate.edu/"akmitra/ aero361/design_web/quad.html and n is the order. Note that the provided constants are indexed starting at 1, but Carrays begin at 0. #includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started