Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Algorithm and Programming P#4. Area under the curve. Write a python program to compute numerically the integral: I = Sb=0 Vx 1 dx Equation-1 Make

Algorithm and Programming image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
P#4. Area under the curve. Write a python program to compute numerically the integral: I = Sb=0 Vx 1 dx Equation-1 Make use of the Trapezoidal rule which can be expressed as: I = n(f(x0) + 2 ?={ $(xi) + f(x)) Equation-2a Expressed in "arroz y habichuelas": 1 = {(fo +2f1 +2f2 + ... + 2 fn-1 + fn) Equation-2b This is just a simplified expression for the sum of n trapeziums in which the area under the curve is divided Variable subscripts can be represented by "1" as in f(x) = f and runs as 0, 1, 2, 3, .... and represent nodes or points by which the area under the cruve is divided. of is the function also called the integrand; equal to VX-1 For instance: fu is the function evaluated at X1: f(x) = f1 = 1X1 - 1 his the step size (another common notation is Ax ) and can be calculated as Equation #3 On is the number of panels bis the integral's upper limit (for our example b=6) Da is the integral's lower limit (for our example a=1) It is a term of the summation which is equal to the multiplication of a coefficient and a function as in 2fi h = 4x = (b-a) Trapezium Rule Area = yet a [ xo +263 +vs+u+ y u+x] where = As the purpose is to compute the total area under the curve, this is divided into sectors of panels. Each small panel area is computed with the formula for the area of a trapezium. Equation-2b is just a formula to compute the area under the function curve, which has been sliced into trapezoids. The program will compute the values of x to evaluate each f(x) = f The values of x can be calculated by two different ways as: With scalars: (A) Method: x = x + h with initial value of x = a; Equations 4a (B) Method: x = a +1h for i = 0, 1,..., n; Equation # 4b With arrays (don't use it yet): (A) Method (i) = x(i-1) + h with x(O) = a as an initial value; (B) Method x(0) = a + (*h for i=0,1,2...n; Equation# 4c Equations #4d More specifications: The number of times the function is evaluated to compute Eq#2b is ONE unit greater than the number of panels. For instance, if n = 6 the number of times the function is evaluated is 7. Your first step toward the solution should be to expand Eq#2 to account for the number of terms (7 in this example, with i-index starting in zero and ending in 6). Note also that the coefficient multiplying the functions (f) is one for the first and last terms and two (2) for the rest, i.e., coefficients=c== [1, 2, 2, 2,..., 2, 1); seven total values. For the testing phase of your program, please be aware that the solution is: X.XXX (do it) Use simple scalars for the representation of x, f(x), c, and terms variables. The program must print the values of x, f(x),c and terms as soon as they are computed for each i-index (counter) as: i X fi=f(x) G ti=cifi 1 2 n Code must implement each one of the parameters and variables discussed here (not shortcuts all. ved) The output is the table above and the result of the integration (area under the curve) REFERENCES 1. https://www.khanacademy.org/math/ap-calculus-ab/ab-integration-new/ab-6-2/v/trapezoidal- approximation-of-area-under-curve 2. https://www.onlinemathlearning.com/trapezium-rule.html

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions

Question

Define robbery, burglary, safe burglary, and theft.

Answered: 1 week ago