Numerical Integration

image

Hi could someone please help me? Thank you

Numerical Integration
Using the trapezium rule, we can calculate the integral of a function, f(x), between the limits of x=a and x=b to be approximately :
∫_a^b▒〖f(x)dx=〗 h/2 [f(a)+f(b)+2∑_(i=1)^(n-1)▒f(a+ih) ]

Write a program to calculate the integral of sin2(x).

Your program should :
Ask the user for the values of a, b and how many points between these values.
Use the inline command in the script to evaluate sin2(x) when calculating the integral.
Be tested using the information that ∫_0^π▒〖〖sin〗^2 (x)dx=π/2〗

The error function, erf(z), is used in solving the heat equation. It is given by :
erf⁡(z)=2/√π ∫_0^z▒〖e^(〖-x〗^2 ) dx〗
Write a program which will calculate the value of the erf(z), adapted from your trapezium integration program above. You can test you program using the information that erf(π) = 1.