Question: using piecewise quadratic functions. Assume f(x) is continuous over a,b . Let a,b be divided into N subintervals, each of length Delta x , with

using piecewise quadratic functions.\ Assume

f(x)

is continuous over

a,b

. Let

a,b

be divided into

N

subintervals, each of length

\\\\Delta x

, with endpoints at

P=x_(0),x_(1),x_(2),dots,x_(n),dots,x_(N)

. Each interval is

\\\\Delta x=(b-a)/(N)

.\ The equation for the Simpson numerical integration rule is derived as:\

\\\\int_a^b f(x)dx~~(\\\\Delta x)/(3)[f(x_(0))+4(\\\\sum_(n=1)^(N-1) ,n odd f(x_(n)))+2(\\\\sum_(n=2)^(N-2) ,n even f(x_(n)))+f(x_(N))].

\ Now complete the Python function InterageSimpson(N, a, b) below to implement this Simpson rule using the above equation.\ The function to be intergrate is

f(x)=2x^(3)

(Already defined in the function, no need to change).\ from math import

**

\ def InterageSimpson(

N,a,b

#

n

is the total intervals,

a

and

b

is the lower and upper bound respectively\ "'"'Hint: Use loop to add all the values in the above equation and\ use the if statement to determine whether the value is odd or even"'"."\ def

f(x)

:\ ## The function

f(x)=2**x****3

is defined as below, DON'T CHANGE IT:\

f=2**x****3

\

return f

\ value

=0

# # Initiation of the value\ TotalArea=0 # TotalArea as the final integral value, the area underneath the curve. # Initiation of the value\

dx=(b-a)/(N)#

delta

x

, the interval length\ # Complete the function by filling your codes below:\ # YOUR CODE HERE

 using piecewise quadratic functions.\ Assume f(x) is continuous over a,b. Let

using piecewise quadratic functions. The equation for the Simpson numerical integration rule is derived as: abf(x)dx3x[f(x0)+4(n=1,noddN1f(xn))+2(n=2,nevenN2f(xn))+f(xN)]. Now complete the Python function InterageSimpson(N, a, b) below to implement this Simpson rule using the above equation. The function to be intergrate is f(x)=2x3 (Already defined in the function, no need to change). 'Complete the function given the variables N,a,b and return the value as "TotalArea".' "Don't change the predefined content' only fill your code in the region 'YOUR CODE'" from math import def InterageSimpson( N,a,b):#n is the total intervals, a and b is the lower and upper bound respectively """Hint: Use loop to add all the values in the above equation and use the if statement to determine whether the value is odd or even""" def f(x) : \#\# The function f(x)=2x3 is defined as below, DON'T CHANGE IT: f=2X3 return f value=0 \# \# Initiation of the value TotalArea=0 \# TotalArea as the final integral value, the area underneath the curve. \# Initiation of the value dx=(ba)/N \# delta x, the interval length \# Complete the function by filling your codes below: \# YOUR CODE HERE return TotalArea \#Make sure in your solution, you use the same name "TotalArea" for the output using piecewise quadratic functions. The equation for the Simpson numerical integration rule is derived as: abf(x)dx3x[f(x0)+4(n=1,noddN1f(xn))+2(n=2,nevenN2f(xn))+f(xN)]. Now complete the Python function InterageSimpson(N, a, b) below to implement this Simpson rule using the above equation. The function to be intergrate is f(x)=2x3 (Already defined in the function, no need to change). 'Complete the function given the variables N,a,b and return the value as "TotalArea".' "Don't change the predefined content' only fill your code in the region 'YOUR CODE'" from math import def InterageSimpson( N,a,b):#n is the total intervals, a and b is the lower and upper bound respectively """Hint: Use loop to add all the values in the above equation and use the if statement to determine whether the value is odd or even""" def f(x) : \#\# The function f(x)=2x3 is defined as below, DON'T CHANGE IT: f=2X3 return f value=0 \# \# Initiation of the value TotalArea=0 \# TotalArea as the final integral value, the area underneath the curve. \# Initiation of the value dx=(ba)/N \# delta x, the interval length \# Complete the function by filling your codes below: \# YOUR CODE HERE return TotalArea \#Make sure in your solution, you use the same name "TotalArea" for the output

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!