Calculating the area under a curve is a standard problem in numerical methods. What you will develop is an app that calculates and displays the area under a range of curves.   Figure 1: Area under the curve of y = x2 over the range 1 to 2, with 1 trapezoid.   The area can be calculated by drawing one or more polygons (trapezoids) that approximate the curve. We start by drawing a trapezoid that encompasses our curve between the given limits and the x-axis, so for equation 1 of table 1, it looks like figure 1. We then calculate the area of the trapezoid. Notice that the trapezoid over-estimates the true area. With enough (smaller) trapezoids we can get a very good approximation to the area under the curve (see figure 2). The sum of the area of the smaller trapezoids is the area under the curve. The area of a trapezoid is given by: A = ½ (h1 + h2) d Plot graphs of the equations in table 1 for varying (input) total numbers of trapezoids. Compute and display the area between each curve and the x-axis. The number of trapezoids should be a positive integer. Extend your app by allowing the input of varying min and max x limits beyond those in Table 1, with max >= min     Table 1: Sample curves and associated areas. Equation xMin xMax Actual Area y = x2 1 2 2 1/3 y = x2 – 4 -2 2 10 2/3 y = -x3 + 6x2 – x +17 2 4 80.0000 y = 2x3+2x2-5x+3 -2.5 7 65.2502     Figure 2: Area under the curve of y = x2 over the range 1 to 2, with 2 trapezoids.   The more trapezoids, the better the approximation approaches the actual area. It is useful to know the error in the calculation. The relative error can be computed by: RE = | calculated area – actual area |                         actual area   %RE = | calculated area – actual area | . 100%                         actual area   Extend your app further by plotting %RE in area values (and the theoretical %RE line) for a range of trapezoids (1-100,000 in powers of 10 on the x-axis, 0.1-100 in powers of 10 on the y-axis) for each curve in Table 1.   Question Week#9: App should allow input of the number of trapezoids and display correct plots of the curves for the data supplied in table 1 of the Problem Statement. Some unit tests implemented.   Answer? I need answer from Solar2D and Lua( Special request don't do in any languages. Need in Solar2D and Lua and I need full code for this. (plz use Table 1) Please give proper explanation and typed answer only.

EBK JAVA PROGRAMMING
8th Edition
ISBN:9781305480537
Author:FARRELL
Publisher:FARRELL
Chapter16: Graphics
Section: Chapter Questions
Problem 9RQ
icon
Related questions
Question

Calculating the area under a curve is a standard problem in numerical methods. What you will develop is an app that calculates and displays the area under a range of curves.

 

Figure 1: Area under the curve of y = x2 over the range 1 to 2, with 1 trapezoid.

 

The area can be calculated by drawing one or more polygons (trapezoids) that approximate the curve. We start by drawing a trapezoid that encompasses our curve between the given limits and the x-axis, so for equation 1 of table 1, it looks like figure 1. We then calculate the area of the trapezoid. Notice that the trapezoid over-estimates the true area. With enough (smaller) trapezoids we can get a very good approximation to the area under the curve (see figure 2). The sum of the area of the smaller trapezoids is the area under the curve.

The area of a trapezoid is given by: A = ½ (h1 + h2) d

Plot graphs of the equations in table 1 for varying (input) total numbers of trapezoids. Compute and display the area between each curve and the x-axis. The number of trapezoids should be a positive integer.

Extend your app by allowing the input of varying min and max x limits beyond those in Table 1, with max >= min

 

 

Table 1: Sample curves and associated areas.

Equation

xMin

xMax

Actual Area

y = x2

1

2

2 1/3

y = x– 4

-2

2

10 2/3

y = -x3 + 6x2 – x +17

2

4

80.0000

y = 2x3+2x2-5x+3

-2.5

7

65.2502

 

 

Figure 2: Area under the curve of y = x2 over the range 1 to 2, with 2 trapezoids.

 

The more trapezoids, the better the approximation approaches the actual area. It is useful to know the error in the calculation.

The relative error can be computed by:

RE = | calculated area – actual area |

                        actual area

 

%RE = | calculated area – actual area | . 100%

                        actual area

 

Extend your app further by plotting %RE in area values (and the theoretical %RE line) for a range of trapezoids (1-100,000 in powers of 10 on the x-axis, 0.1-100 in powers of 10 on the y-axis) for each curve in Table 1.

 

Question

Week#9: App should allow input of the number of trapezoids and display correct plots of the curves for the data supplied in table 1 of the Problem Statement. Some unit tests implemented.

 

Answer?

I need answer from Solar2D and Lua( Special request don't do in any languages. Need in Solar2D and Lua and I need full code for this. (plz use Table 1)

Please give proper explanation and typed answer only.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT