Question

In: Computer Science

Using python, write a function calcA() that determines the area under the curve ?(?) = ??...

Using python, write a function calcA() that determines the area under the curve ?(?) = ?? −? over the range ?1 to ?2. The area is to be determined approximately as follows: ? = ∫ ?(?) ?? ?2 ?1 ≈ ∑ 1 2 (?(?? ) + ?(??−1 ))∆? ? ?=1 (1) Where ? is the number of intervals over the range ?1 to ?2. So if ? is equal to 10, then ∆? = (?2 − ?1)/10. This function receives the two range limits and divides it into ? intervals and generates ? + 1 values and puts them in a list. The function will then iterate over this list and implement (1), above, to calculate the area under the curve. Test your calcA() function over the range 0 to 5 w. Then calculate the area of a rectangle, which is equal to 5.

Solutions

Expert Solution

The above program is implemented in python3 and code is explained in comments

Approximate formula to find the integration is

For f(x)=x * e-x Below is the code in python

We can see that when we find the integration of above function by rules of integration we get the result as

0.9595723180054871

So this can proove the effectiveness of our code.

For m=10 we have an error of 0.2 approx.

NOTE: Our code accuracy will always increase when we increase the value of m

For m=100, our code outputs :

The approx. result of integration over range 0 to 5 is: 0.9593583958723835

This value is more closer to the original value, which means our accuracy increased.

2) To find the area of rectangle

f(x)=width ; For a rectangle of width 1

f(x)=1


Related Solutions

In python write a function whose input is a string. This function determines the data type...
In python write a function whose input is a string. This function determines the data type of the input string. The data types can be a float, int, or string. Most pass the following assertions: assert determine_data_type('1.2') == float assert determine_data_type('4') == int assert determine_data_type('EAS503') == str
Design a function in python that takes a list of strings as an argument and determines...
Design a function in python that takes a list of strings as an argument and determines whether the strings in the list are getting decreasingly shorter from the front to the back of the list
Write a script or function in Python that approximates the solution to the system ??⃗=?⃗⃗ using...
Write a script or function in Python that approximates the solution to the system ??⃗=?⃗⃗ using the Jacobi Method. The inputs should be an nxn matrix A, an n-dimensional vector?⃗⃗, a starting vector ?⃗0,an error tolerance ?, and a maximum number of iterations N. The outputs should be either an approximate solution to the system??⃗=?⃗⃗ or an error message, along with the number of iterations completed. Additionally, it would be wise to build in functionality that allows you to optionally...
In a normal distribution curve, what percentage of the area under the curve is contained in...
In a normal distribution curve, what percentage of the area under the curve is contained in the region, on one side of the mean, between 1 standard deviation from the mean and 2 standard deviations from the mean? A. 95% B. 68.27% C. 50% D. 27.24%% E. 13.59%
Using the standard normal (z) distribution table, what is the area under the standard normal curve...
Using the standard normal (z) distribution table, what is the area under the standard normal curve between 1.67 and 2.72? a. 0.0442 b. 0.9525 c. 0.2563 d. 0.6140
Using the standard Normal distribution tables, what is the area under the standard Normal curve corresponding...
Using the standard Normal distribution tables, what is the area under the standard Normal curve corresponding to Z < 1.1?
Consider the value of t such that 0.025 of the area under the curve is to...
Consider the value of t such that 0.025 of the area under the curve is to the left of t. Step 2 of 2: Assuming the degrees of freedom equals 26, determine the t value. Round your answer to three decimal places
Consider the value of t such that 0.01 of the area under the curve is to...
Consider the value of t such that 0.01 of the area under the curve is to the left of t. Step 2 of 2 :   Assuming the degrees of freedom equals 10, select the t value from the t table.
Consider the value of t such that 0.1 of the area under the curve is to...
Consider the value of t such that 0.1 of the area under the curve is to the right of t. Step 2 of 2 :   Assuming the degrees of freedom equals 13, select the t value from the t table.
Consider the value of t such that 0.025 of the area under the curve is to...
Consider the value of t such that 0.025 of the area under the curve is to the left of t. Step 2 of 2 : Assuming the degrees of freedom equals 19, select the t value from the t table.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT