mathematical functions

mathematical functions
Write a program, my_math.cpp, that defines 5 mathematical function and calculates the summation or integration of that function. You are creating your own library of commonly used mathematical functions and analyzing the different methods, rectangle vs. trapezoid methods, for solving integration problems to gain experience writing a short program, which uses selection, repetition, and functions/procedures. Your program should define these 5 functions: f1(x) = 2x 5 + x3 – 10x + 2 f2(x) = 6×2 – x + 10 f3(x) = 5x + 3 f4(x) = 2×3 + 120 f5(x) = 2×2 Summation Function Explanation: We will use the functions specified above, where x=a to b. ∑𝑓5(𝑥) 𝑏 𝑥=𝑎 ï‚· The summation needs a and b values for the beginning and ending values for x. ï‚· Calculate the summation of the function, f5(x)=2x 2 , with a user specified a and b value ï‚· Return the sum. Integration Functions Explanation: Your program should determine the area under the functions specified above. You will calculate the area under a curve using the rectangle and trapezoid method. Therefore, you need integrate_rectangle() and integrate_trapezoid() functions.

Here is an example run of your my_math.cpp program: Choose a function (1, 2, 3, 4, 5, other(quit)): 5 Which operation do you want (summation(1) or integration(2)): 2 Would you like to calculate the area using the rectangle, trapezoid, or both (1, 2, 3): 2 How many trapezoids do you want? 1000 Please select a starting point, a = 1 Please select an ending point, b = 2 The area under 2×2 between 1 and 2 is 4.667 Program Input: – Mathematical operation to perform – Starting and ending points for the area or summation – Function to calculate the area or summation, i.e. f1, f2, f3, f4, f5 – Function/Procedure(s) for calculating the area, i.e. rect, trap, both – Number of rectangles and/or trapezoids to use Program Output: – The function being evaluated – Starting and ending points for the integral or summation – For integration: Number of rectangles and/or trapezoids used – The area or summation calculated by the method(s) Program Description in more detail: Your program needs to adhere to the following guidelines: ï‚· If the user chooses to see the area calculated by both methods, each method should receive their own number of rectangles or trapezoids as input and return the value from the calculation. ï‚· Your program should continue running until the user no longer wants to perform more calculations. ï‚· You should use procedural decomposition and have functions for f1(x), f2(x), f3(x), f4(x), and f5(x), as well as functions for calculating the summation and area using the rectangle vs. trapezoid method. (10 pts) Extra Credit: Handle ALL erroneous input by the user associated with each of the options

READ ALSO :   Academic help online