Introduction In this assignment you will write a small C program to read the coefficients of...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Introduction In this assignment you will write a small C program to read the coefficients of a third degree equation, and use a numerical integration method for calculating a numerical value of a definite integral in the range x= a to x=b using N intervals. The C program should be submitted as a standard C source code file. You can submit your files separately or zipped together into one file. Please note that the computer program should comply with the commenting and formatting rules as has been done in class. For example, there should be a header for the whole program that gives the author's name, class name, date, and description. End braces should be commented, and there are alignment and indenting requirements as discussed. Please ask if you have any questions. Program Background: A third-degree polynomial equation is represented as f(x) = mx³ + nx² + px + q. Where m, n, p and q are real values. f(x) = mx³ + nx² + px + q; vm, n, p, q ER Numerical integration consists of finding numerical approximation for the value S in Figure 1. To find the value of S, you will implement and compare two different solutions: f(x) S b x Figure 1: Numerical Integration 1) Midpoint rule: Also known as the rectangle rule; is used to compute an approximation to a definite integral. This is achieved by finding the area of rectangles whose height is determined by the value of a function. The interval [a,b] over which the function is to be integrated is divided into N equal subintervals of length Ax = (b-a)/N. The approximation to the integral is then calculated by : [F(x) • Σf(a + ² -* Ax) 2k-1 2 f(x) dx Ax * k=1 2) Trapezoidal rule: Similar to 1), but in this case the height of the rectangle, requires to evaluate f(x) at two different points. The general formula: Ax [ f(x) dx = = = * (f(x) + 2 + f (x₁) + 2 * ƒ (x₂) + ... + 2 + ƒ (xx-1) + ƒ (x₂)) Where Ax is the same as in 1), and x = a + k * Ax; for k=0 to N; Assignment: Your first program is a simple mathematical calculation. You will write a C program that shows a menu to get 4 real values from the user, namely m, n, p and q(20 points); once these values are provided, the user can enter the integration range and intervals(i.e. the values for a, b and M) (10 points). A third option will calculate the value of S, using methods 1 (midpoint) (20 points) and 2(trapezoidal) (20 points) explained above and display the results as well as the difference between the value of Si obtained with method 1, and the value of S₂ obtained with method 2. A function MUST be written for each method (midpoint and trapezoidal). Your program should prompt the user for these values (coefficients, range and interval), accept input from the keyboard, and then print out the result on the screen. You can use a menu with the following options: a) Enter new coefficients (m, n, p and q) b) Enter the value for a, b and N c) Calculate the integral from a to b d) Exit ii). Include a report in a Word file that shows the results for the following values: i). Coefficients (-1, 4, -5, 2) and range (0,5) with N = 100 (2 points) Coefficients (-1, 4, -5, 2) and range (0,5) with N= 1000 (3 points) Coefficients (1, 5, 7, 2) and range (-2.5,1) with N= 1000 (2 points) iv). Coefficients (1, 5, 7, 2) and range (-2.5,1) with N = 100000 (3 points) v). Coefficients (1, 0, -1, 8) and range (-1,1) with N= 100000 (5 points) iii). vi). Coefficients (1/4, 3/4, -6/4, -2) and range (-4,2) with N= 100000 (5 points) Add your observations (10 points): i.e. what happens with v) and vi)? You can use the function pow(), found in <math.h>, to calculate the powers of x. Topics covered: Expression evaluation, operators, flow control statements (loops, switch-case, if- else, etc.) and functions. Introduction In this assignment you will write a small C program to read the coefficients of a third degree equation, and use a numerical integration method for calculating a numerical value of a definite integral in the range x= a to x=b using N intervals. The C program should be submitted as a standard C source code file. You can submit your files separately or zipped together into one file. Please note that the computer program should comply with the commenting and formatting rules as has been done in class. For example, there should be a header for the whole program that gives the author's name, class name, date, and description. End braces should be commented, and there are alignment and indenting requirements as discussed. Please ask if you have any questions. Program Background: A third-degree polynomial equation is represented as f(x) = mx³ + nx² + px + q. Where m, n, p and q are real values. f(x) = mx³ + nx² + px + q; vm, n, p, q ER Numerical integration consists of finding numerical approximation for the value S in Figure 1. To find the value of S, you will implement and compare two different solutions: f(x) S b x Figure 1: Numerical Integration 1) Midpoint rule: Also known as the rectangle rule; is used to compute an approximation to a definite integral. This is achieved by finding the area of rectangles whose height is determined by the value of a function. The interval [a,b] over which the function is to be integrated is divided into N equal subintervals of length Ax = (b-a)/N. The approximation to the integral is then calculated by : [F(x) • Σf(a + ² -* Ax) 2k-1 2 f(x) dx Ax * k=1 2) Trapezoidal rule: Similar to 1), but in this case the height of the rectangle, requires to evaluate f(x) at two different points. The general formula: Ax [ f(x) dx = = = * (f(x) + 2 + f (x₁) + 2 * ƒ (x₂) + ... + 2 + ƒ (xx-1) + ƒ (x₂)) Where Ax is the same as in 1), and x = a + k * Ax; for k=0 to N; Assignment: Your first program is a simple mathematical calculation. You will write a C program that shows a menu to get 4 real values from the user, namely m, n, p and q(20 points); once these values are provided, the user can enter the integration range and intervals(i.e. the values for a, b and M) (10 points). A third option will calculate the value of S, using methods 1 (midpoint) (20 points) and 2(trapezoidal) (20 points) explained above and display the results as well as the difference between the value of Si obtained with method 1, and the value of S₂ obtained with method 2. A function MUST be written for each method (midpoint and trapezoidal). Your program should prompt the user for these values (coefficients, range and interval), accept input from the keyboard, and then print out the result on the screen. You can use a menu with the following options: a) Enter new coefficients (m, n, p and q) b) Enter the value for a, b and N c) Calculate the integral from a to b d) Exit ii). Include a report in a Word file that shows the results for the following values: i). Coefficients (-1, 4, -5, 2) and range (0,5) with N = 100 (2 points) Coefficients (-1, 4, -5, 2) and range (0,5) with N= 1000 (3 points) Coefficients (1, 5, 7, 2) and range (-2.5,1) with N= 1000 (2 points) iv). Coefficients (1, 5, 7, 2) and range (-2.5,1) with N = 100000 (3 points) v). Coefficients (1, 0, -1, 8) and range (-1,1) with N= 100000 (5 points) iii). vi). Coefficients (1/4, 3/4, -6/4, -2) and range (-4,2) with N= 100000 (5 points) Add your observations (10 points): i.e. what happens with v) and vi)? You can use the function pow(), found in <math.h>, to calculate the powers of x. Topics covered: Expression evaluation, operators, flow control statements (loops, switch-case, if- else, etc.) and functions.
Expert Answer:
Answer rating: 100% (QA)
Note I have used step size as 1000 for integration so the error is less for me if you want ... View the full answer
Related Book For
Introduction to Governmental and Not for Profit Accounting
ISBN: 978-0132776011
7th edition
Authors: Martin Ives, Terry K. Patton, Suesan R. Patton
Posted Date:
Students also viewed these computer engineering questions
-
Megerle Custom Cabinet Co. uses the job order cost system. In recording payroll transactions, the following accounts are used: Cash ................ Administrative Salaries Wages Payable ...............
-
Agassi Company uses a job order cost system in each of its three manufacturing departments. Manufacturing overhead is applied to jobs on the basis of direct labor cost in Department D, direct labor...
-
Acquatic Manufacturing uses a job order cost system in each of its three manufacturing departments. Manufacturing overhead is applied to jobs on the basis of direct labor cost in Department A, direct...
-
Define pros and cons of the current transportation strategy of BEST and elaborate recommendations.
-
The differential between fixed- rate credit card rates and a banks cost of funds typically varies over the interest rate cycle. What is this relationship, and why does it exist? Does the differential...
-
A poster is to have an area of 180 in with 1-inch margins at the bottom and sides and a 2-inch margin at the top. What dimensions will give the largest printed area?
-
Assume you are considering controls over a client's purchasing activities, and estimate the following for acceptable risk of assessing control risk too low, tolerable rate of deviation, and expected...
-
A colleague tells you that he can get a business loan from the bank, but the rates seem very high for what your colleague considers a low-risk loan. a. Give an adverse selection explanation for this,...
-
Fastball (FB), a teenager who became a superhero after catching a radioactive baseball, can fly, and she can throw any object as fast as a jet aircraft with no air resistance at all. Right now FB is...
-
Response rates to Web surveys are typically low, partially due to users starting but not finishing the survey. The factors that influence response rates were investigated in Survey Methodology (Dec....
-
(4) A generator is connected through a transformer to a symchronous motor. The subtransient reactances of generator and motor are 0.2 p.u. and 0.3 p.u. respectively. The reactance of the transformer...
-
The CPI-U (U.S. city average, all items) has the following annual averages: a. For each year from 2007 to 2010, determine the annual inflation rate in percent to three decimal places. b. Since...
-
The United States manufacturing output per hour index is given as follows for years 2005 to 2009: a. For each year from 2006 to 2009, determine the rate of increase in U.S. manufacturing output per...
-
The Korean hourly compensation percentage rates of increase, based on U.S. dollars, are presented as follows: a. Assuming the Korean compensation index in U.S. dollar was $12.73 in 2004, determine...
-
The seasonally adjusted rate increases for gasoline, unleaded regular, during early 2011 are as follows: a. Assuming the index value in January 2011 was 278.404, determine the index for each year...
-
Explain why endogeneity is a potential problem in random effects models, and how it affects our choice of estimator.
-
Mario and Peter just opened a cleaning services business. Mario is saying that revenue must be recognized each time a cleaning service has been rendered. On the other hand, Peter is arguing that...
-
6 (a) Briefly develop a mathematical model of the behaviour of a copper-twisted pair cable (b) Derive the magnetic energy from: w given that: K + w, where the - - k symbols have their usual meaning...
-
The following transactions occurred during 2012: 1. The City of Watersville approved the construction of an enclosed concert arena for a total cost of $ 75,000,000 in order to attract professional...
-
What characteristics distinguish NFPOs from for- profit organizations? What characteristics distinguish government organizations from NFPOs?
-
The City of Lexington had the following transactions during the calendar year 2013. The transactions relate to financing and constructing a new firehouse. Lexington uses budgetary accounting in its...
-
On June 24, 2015, two grocery retailers, Netherlandsbased Ahold and Belgium-based Delhaize, announced their intention to engage in a merger of equals. By merging their activities, the two companies...
-
How would the following events (reported this year) affect your forecasts of a firms future profit or loss? An asset write-down. A merger or acquisition. The sale of a major division. The...
-
An investment banker states, It is not worth my while to worry about detailed long-term forecasts. Instead, I use the following approach when forecasting cash flows beyond three years. I assume that...
Study smarter with the SolutionInn App