Question

An approximation to the integral of a function f(x) over an interval [a, b] can be...

An approximation to the integral of a function f(x) over an interval [a, b] can be found by first approximating f(x) by the straight line that goes through the end points (a, f(a)) and (b, f(b)), and then finding the area under the straight line, which is the area of a trapezoid.

In python, write a function trapezint(f, a, b) that returns this approximation to the  integral. The argument f is a Python implementation of the mathematical function f(x). Test your code by integrating cos(x) and sin(x) from 0 to π.

Homework Answers

Answer #1

After replacing the function f(x) with a straight line, we will get a trapezium figure which can be sectorized in two parts (one rectangle and another triangle) and area can be calculated as the sum of the area of the rectangle and the area of the triangle. Please find the attached images for the detailed solution to the question along with python program for the integral.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Problem 7. Consider the line integral Z C y sin x dx − cos x dy....
Problem 7. Consider the line integral Z C y sin x dx − cos x dy. a. Evaluate the line integral, assuming C is the line segment from (0, 1) to (π, −1). b. Show that the vector field F = <y sin x, − cos x> is conservative, and find a potential function V (x, y). c. Evaluate the line integral where C is any path from (π, −1) to (0, 1).
Define a function f as follows: f ( x ) = sin ⁡ ( x )...
Define a function f as follows: f ( x ) = sin ⁡ ( x ) x , i f x ≠ 0 , a n d f ( 0 ) = 1. Then f is a continuous function. Find the trapezoidal approximation to the integral ∫ 0 π f ( x ) d xusing n = 4 trapezoids. Write out the sum formally and give a decimal value for it.
1 Approximation of functions by polynomials Let the function f(x) be given by the following: f(x)...
1 Approximation of functions by polynomials Let the function f(x) be given by the following: f(x) = 1/ 1 + x^2 Use polyfit to approximate f(x) by polynomials of degree k = 2, 4, and 6. Plot the approximating polynomials and f(x) on the same plot over an appropriate domain. Also, plot the approximation error for each case. Note that you also will need polyval to evaluate the approximating polynomial. Submit your code and both plots. Make sure each of...
(a) Is the vector field F = <e^(−x) cos y, e^(−x) sin y> conservative? (b) If...
(a) Is the vector field F = <e^(−x) cos y, e^(−x) sin y> conservative? (b) If so, find the associated potential function φ. (c) Evaluate Integral C F*dr, where C is the straight line path from (0, 0) to (2π, 2π). (d) Write the expression for the line integral as a single integral without using the fundamental theorem of calculus.
Consider the function f(x)=x⋅sin(x). a) Find the area bound by y=f(x) and the x-axis over the...
Consider the function f(x)=x⋅sin(x). a) Find the area bound by y=f(x) and the x-axis over the interval, 0≤x≤π. (Do this without a calculator for practice and give the exact answer.) b) Let M(x) be the Maclaurin polynomial that consists of the first 5 nonzero terms of the Maclaurin series for f(x). Find M(x) by taking advantage of the fact that you already know the Maclaurin series for sin x. M(x)= c) Since every Maclaurin polynomial is by definition centered at...
a)Prove that the function u(x, y) = x -y÷x+y is harmonic and obtain a conjugate function...
a)Prove that the function u(x, y) = x -y÷x+y is harmonic and obtain a conjugate function v(x, y) such that f(z) = u + iv is analytic. b)Convert the integral from 0 to 5 of (25-t²)^3/2 dt into a Beta Function and evaluate the resulting function. c)Solve the first order PDE sin(x) sin(y) ∂u ∂x + cos(x) cos(y) ∂u ∂y = 0 such that u(x, y) = cos(2x), on x + y = π 2
Let h be the function defined by H(x)= integral pi/4 to x (sin^2(t))dt. Which of the...
Let h be the function defined by H(x)= integral pi/4 to x (sin^2(t))dt. Which of the following is an equation for the line tangent to the graph of h at the point where x= pi/4. The function is given by H(x)= integral 1.1 to x (2+ 2ln( ln(t) ) - ( ln(t) )^2)dt for (1.1 < or = x < or = 7). On what intervals, if any, is h increasing? What is a left Riemann sum approximation of integral...
1.) Let f(x,y) =x^2+y^3+sin(x^2+y^3). Determine the line integral of f(x,y) with respect to arc length over...
1.) Let f(x,y) =x^2+y^3+sin(x^2+y^3). Determine the line integral of f(x,y) with respect to arc length over the unit circle centered at the origin (0, 0). 2.) Let f ( x,y)=x^3+y+cos( x )+e^(x − y). Determine the line integral of f(x,y) with respect to arc length over the line segment from (-1, 0) to (1, -2)
Problem 1 f(x) = ex * cos(x) Evaluate the integral of f(x) from x = -...
Problem 1 f(x) = ex * cos(x) Evaluate the integral of f(x) from x = - Π / 2 to x = + Π / 2 using: 1. Trapezoidal Rule where Δx = Π / 6 2. Simpson's 1/3 Rule where n = 4 3. Simpson's 3/8 Rule 4. Draw a scatter plot of f(x) in Excel over the desired range (use sufficient data points to accurately depict the function) 5a. What is the true solution? (evaluate the integral) 5b....
Compute the line integral of f(x, y, z) = x 2 + y 2 − cos(z)...
Compute the line integral of f(x, y, z) = x 2 + y 2 − cos(z) over the following paths: (a) the line segment from (0, 0, 0) to (3, 4, 5) (b) the helical path → r (t) = cos(t) i + sin(t) j + t k from (1, 0, 0) to (1, 0, 2π)
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT