Determine the area under the functions

Assignment Help Engineering Mathematics
Reference no: EM131225711

Assignment - Repetition and Decomposition/Functions

Problem Statement:

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) = 2x5 + x3 - 10x + 2 f2(x) = 6x2 - x + 10

f3(x) = 5x + 3 f4(x) = 2x3 + 120

f5(x) = 2x2

Summation Function Explanation:

We will use the functions specified above, where x = a to b.

bΣx=af5(x)

- The summation needs a and b values for the beginning and ending values for x.
- Calculate the summation of the function, f5(x)=2x2, 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. Don't freak out!!! Programming integration into the computer doesn't consist of calculus. It is simple math, and these two methods only require summing the area of a certain number of rectangles or trapezoids under a specific curve, f(x).

For Example, if your f(x) = 2x:

310_Figure.jpg

Basic Numerical Methods (Rectangle vs. Trapezoid):

2138_Figure1.jpg

n = number of rectangles and/or trapezoids

a = beginning x value

b = boundary for rectangles

width = width of each rectangle/trapezoid, (b-a)/n

f(x) = height of rectangle

(f(x1)+f(x2))/2 = height of trapezoid Area = width * height

The functions are bounded by any interval on the x-axis, including both positive and negative values!!!.

You can check your answers to these functions using

https://www.wolframalpha.com/widgets/view.jsp?id=8ab70731b1553f17c11a3bbc87e0b605

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 2x2 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.

Program Style/Comments
In your implementation, make sure that you include a program header in your program, in addition to proper indentation/spacing and other comments! Below is an example header to include. Make sure you review the style guidelines for this class, and begin trying to follow them, i.e. don't align everything on the left or put everything on one line! https://classes.engr.oregonstate.edu/eecs/fall2015/cs161-001/161_style_guideline.pdf

/******************************************************
** Program: my_math.cpp
** Author: Your Name
** Date: 10/20/2015
** Description:
** Input:
** Output:
******************************************************/

Testing

Report any checking/self-reflection you did while solving the problem. For instance, how did you make sense of the output from the implementation? This includes things such as using a calculator to make sure the output is correct, testing to make sure your code executes correctly and behaves the way you expect under specific circumstances, using external sources of information such as the internet to make sense of the results, etc. In addition, you will provide us a test plan!

You will be graded on how thorough your test plan is. Make sure you think about input you hope works and input that won't work. Your program doesn't have to handle input that doesn't work!!!

Reference no: EM131225711

Questions Cloud

Which societies is more likely to focus on building relation : Which of the following societies is more likely to focus on building long-term relationships in business? In which of the following societies is a professor ore likely to be called by his/her first name?
Attribute the behavior of others to personality factors : Most computer software carries a warning against copying, yet many people feel the warning is unreasonable. They believe that if they buy a program, it is theirs to do with as they wish, and that includes giving or selling a copy to someone else. Are..
Improve organizational processes and outputs : Within your research paper, explain how the following tasks can be accomplished at your chosen organization using competency or case-based decision making training methods:  improve productivity (efficiency and effectiveness), improve employee sati..
Financial reporting practices and ethical standards : Question 1: Find two or three articles that address financial reporting practices and ethical standards in health care finance, including the following topics:
Determine the area under the functions : 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.
Prioritize the issues with personnel and project attributes : Prioritize the issues with personnel and project attributes listed above, as to which are most urgent. Develop a strategy for addressing the issues listed above. If your strategy is not to address an issue, that too must be clearly stated. Also, in..
Identify the top communication challenge from your survey : Administer the communication audit in your organization. Analyze and synthesize the results of the data from the communication audit. Based on the communication audit identify one critical communication challenge that needs to be addressed within y..
Design a entity tables for small college department library : Design a database (entity and relationship tables in Access) for a small college department library. You should have the entities and relationships you need to support Purchase books.
Discussing briefly describe what issues : A 4-page (double-spaced) paper discussing briefly describe what issues led up to Delta going bankrupt and what they did to recover Please utilize at least 3 textbook citations and 3 other scholarly citations to support the discussion. And a 3 slid..

Reviews

Write a Review

Engineering Mathematics Questions & Answers

  Definitions for the relative coordinate and reduced mass

What general conclusions can you reach about the relationship between the relative sizes of the two masses and the corresponding reduced mass?

  Develop simulations that can be readily tested in matlab

BE101 Engineering Mathematics - Is your implementation exactly the same as the algorithm described in the paper? If they are not exactly the same, why did you make those changes?

  Runge-kutta method

Use 4th order Runge-Kutta Method with step size h =0.2 and h =0.1 to find y(2) and sketch all the solutions on the interval [1, 2] with appropriate legend for comparison.

  Derive autocorrelation function of the ma process

How to test stationarity of an empirically given time series - Derive a formula for the autocorrelation function of a MA(n) process (you can use textbooks and lectures with references).

  Function of a gaussian process of zero

The sample function of a Gaussian process of zero mean and unit variance is uniformly sampled and then applied to a uniform quantizer having the input-output amplitude characteristic shown in Figure. Calculate the entropy of the quantizer output.

  Perform an initial exploratory data anlysis using plots

Perform an initial exploratory data anlysis using plots and the usual descriptive statistical methods. This should include individual plots of FFD against the three continuous variables, with the data grouped by the two categorical variables.

  Formulate and test the appropriate hypothesis

At the 1% level of significance, can it be concluded that there is a relationship between an employees age and an employees opinion about the new wage incentive plan? Formulate and test the appropriate hypothesis. Use the critical value approach.

  Structure of equilibrium as a function

Sketch a phase diagram corresponding to each of these cases. Try to make some general statements about the structure of equilibrium as a function of the parameters.

  Determine the general solution of the differential equation

Use Euler's Method or Euler's improved method, find the particular solution of the differential equation, and By using the separation of variables method, find the particular solution of differential equation.

  Find the power developed across a load

Find the power developed across a load of 100 ohms due to this AM wave and find the power developed across a load of 100 ohms due to this AM wave.

  Present value of lottery winnings

You just won the Publisher's Clearing House Sweepstakes and the right to 20 after-tax ordinary annuity cash flows of $163,291.18. Assuming a discount rate of 7.50%, what is the present value of your lottery winnings? Use a calculator to determine ..

  Confidence interval for the proportion of patients

Generate a 95% confidence interval for the proportion of patients on the new medication who report pain relief. Generate a 95% confidence interval for the difference in proportions of patients who report pain relief.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd