Write a program integral.c that calculates rectangular and trapezoidal integral approximations for a function. Your program will ask the user for the starting and ending time-points of the integration and the number of time points (polygons) to use in the approximation. In addition to printing out the estimated integral, the program will provide the error in the approximation. In the figure on the left, when we integrate a function we are taking the area under the curve between t = a and t = b (in blue), with the caveat that areas calculated for ranges of t for which f(t) < 0 are subtracted from areas calculated for ranges of t for which f(t) > 0. Thus, in the figure, the integral of f(t) over the range a to b is equal the blue area labeled 2 subtracted from the blue area labeled 1. We can approximate this integral computationally (instead of using analytical integration for an exact answer, i.e. what you learn in calculus) by using a number of methods. Two straightforward methods of approximation are the rectangle and trapezoid methods. With these methods, the integration range is split into n segments and the area of these segments is approximated with a simple polygon. The estimated areas of all of the n segments are signed as either positive or negative (based upon whether they are above or below the t-axis) and are summed. The center figure (green) demonstrates the rectangle method for n = 4. The width of the rectangle is 4t = (b − a)/n. The height of the rectangle is f(t) evaluated at the midpoint of the rectangle, so for the first rectangle, the height is f(a + 4t/2). Thus, the area of the first rectangle (with the appropriate +/- sign) is f(a + 4t/2) 4 t. The right figure (yellow) demonstrates the trapezoid method for n = 4. Each trapezoid has two dif- ferent heights (h1 and h2) and one width (w). The width, w, is also 4t = (b − a)/n. The heights are found by evaluating f(t) at the vertical edges of the trapezoid. So for the first trapezoid, heights are h1 = f(a) and h2 = f(a + 4t). For the second trapezoid the heights are h1 = f(a + 4t) and h2 = f(a + 2 ∗ 4t) (shown on figure). Thus, the area of each trapezoid (with the appropriate +/- sign) is (h1 + h2) ∗ w/2 For this program you will calculate these approximations for the function f(t) = t3 − 2t2 − 10t + 10, you’ll ask the user for the integral range (a and b) and the number of polygons (n) to use. To calculate the error, evaluate the analytical integral of f(t) and subtract each approximation from it. The integral is: R b a f(t)dt = (b4 4 − 2b3 3 − 10b2 2 + 10b) − (a4 4 − 2a3 3 − 10a2 2 + 10a) (plug in a and b to calculate the integral over the range a to b). Your program must include the following functions:• double calcTrap(double t, double dt) – Calculates and returns the area of the trapezoid between t and t+dt.• double f(double t) – Calculates and returns the value of f(t) evaluated at t and might be useful for implementing the above functions!• double fIntegral(double a, double b) – Calculates and returns the integral of f(t) over the range a to b using the analytical integral described above (used to check the error in the approximations).We suggest that you build and debug the basic functionality of these functions before using them to complete the full program. Example execution:(˜)$ a.out Enter the integral range (a,b): 0,1 Enter the number of polygons to use: 1 Rectangle Estimate of 4.625000 is off by 0.041667 Trapezoidal Estimate of 4.500000 is off by -0.083333 (˜)$ a.out Enter the integral range (a,b): 0,1 Enter the number of polygons to use: 10 Rectangle Estimate of 4.583750 is off by 0.000417 Trapezoidal Estimate of 4.582500 is off by -0.000833 (˜)$ a.out Enter the integral range (a,b): -1,1 Enter the number of polygons to use: 100 Rectangle Estimate of 18.666800 is off by 0.000133 Trapezoidal Estimate of 18.666400 is off by -0.000267 (˜)$ a.out Enter the integral range (a,b): 5,7 Enter the number of polygons to use: 100 Rectangle Estimate of 198.665600 is off by -0.001067 Trapezoidal Estimate of 198.668800 is off by 0.002133 (˜)$ a.out Enter the integral range (a,b): 10,100 Enter the number of polygons to use: 10000 Rectangle Estimate of 24282899.900980 is off by -0.099020 Trapezoidal Estimate of 24282900.198047 is off by 0.198047

Why Choose Us

  • 100% non-plagiarized Papers
  • 24/7 /365 Service Available
  • Affordable Prices
  • Any Paper, Urgency, and Subject
  • Will complete your papers in 6 hours
  • On-time Delivery
  • Money-back and Privacy guarantees
  • Unlimited Amendments upon request
  • Satisfaction guarantee

How it Works

  • Click on the “Place Order” tab at the top menu or “Order Now” icon at the bottom and a new page will appear with an order form to be filled.
  • Fill in your paper’s requirements in the "PAPER DETAILS" section.
  • Fill in your paper’s academic level, deadline, and the required number of pages from the drop-down menus.
  • Click “CREATE ACCOUNT & SIGN IN” to enter your registration details and get an account with us for record-keeping and then, click on “PROCEED TO CHECKOUT” at the bottom of the page.
  • From there, the payment sections will show, follow the guided payment process and your order will be available for our writing team to work on it.