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.
-
Reconsider the data in Exercise 5.32. Set up an EWMA control chart with and for this process. Interpret the results. In exercise 1 = 0.2
-
A flow field is formed by combining a uniform flow in the positive \(x\) direction, with \(U=10 \mathrm{~m} / \mathrm{s}\), and a counterclockwise vortex, with strength \(K=16 \pi \mathrm{m}^{2} /...
-
Examine the suggestion that small and medium-sized companies do not need information from a core set of ecological indicators related to their business.
-
Tiffany Goren started her own consulting firm, Goren Consulting, on May 1, 2010. The trial balance at May 31 is as shown below. In addition to those accounts listed on the trial balance, the chart of...
-
A corporation issues $ 5 0 0 0 0 0 , 8 % , 1 0 - years bonds on January 1 , 2 0 2 1 for $ 4 7 9 0 0 0 . Interst is paid annually on January 1 .
-
Assume you have an graph as following. Use Dijkstra Algortihm to calculate shortest path from vertex A to every vertex (manuel calculation). Write the Dijkstra code to generate this graph and find...
-
A body weighs 500 N on the surface of the earth. How much would it weigh halfway below the surface of the earth? (a) 125 N (b) 250 N (c) 500 N (d) 1000 N
-
Does either the domain an(d)/(o)r range of f(x)=x^(2) need to be restricted in order to find an inverse function? Explain why or why not.
-
Carla Vista Tire Co. just paid an annual dividend of $1.20 on its common shares. If Carla Vista is expected to increase its annual dividend by 5.1 percent per year into the foreseeable future and the...
-
Express the limit as a definite integral on the given interval. n lim [2(x,*)3-5x,]Ax, [2,6] 018 =1 12 dx
-
In the circuit to the right assume the voltage of the lower left corner remains O V throughout the problem. a) What is the total current out of the battery? (Hint, find the total equivalent...
-
Write one ARM instruction to do the following operation? LDRH R6, [RO] ADD RO, RO, #10
-
List and explain 7 strategies of how firms from emerging economies/developing countries transform themselves into global MNCs despite their late entry into global competition? Use examples where...
-
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...
-
What is the difference between a flowchart and an internal control questionnaire?
-
Why would studying and evaluating each of the client's controls not necessarily be the most efficient way of determining the scope of related substantive tests?
-
What is an audit strategy?
Study smarter with the SolutionInn App