NO HALFWAY SOLVED OR UNCOMPLETED ANSWERS!! Write a program which calculates the
ID: 3632150 • Letter: N
Question
NO HALFWAY SOLVED OR UNCOMPLETED ANSWERS!!Write a program which calculates the integral of the function
f(x)=B*exp(-x^2.5)+(A*x^n)/m!
on the interval from a to b (0<a<b). In the main program, scanf
a double value for n and a non-negative integer value for m,
nonzero double values for A and B, and positive double values for a and b>a.
Call the function Integr() to evaluate the integral.
Your main program should be followed by three functions:
double Integr(double n, int m, double A, double B, double a, double b)
double func(double x, double n, int m, double A, double B)
double mfact(int m)
When writing the function Integr(), use the program w4-10.c, appropriately
modified to integrate an arbitrary function f(x) from a to b
(let the program ask you for n_trap only once, and scan
sufficiently large value for n_trap; also print the length
of the corresponding sub-interval del_x). Within Integr() call another
function func() to evaluate f(x). The return value of func() should
be equal to B*exp(-x^2.5)+A*x^n if m=0, or B*exp(-x^2.5)+A*x^n/m! if m>0.
To evaluate m! call the function mfac() that you will also create.
To evaluate x^n call the function pow(), which is embedded in
the math.h library.
................................................................
Your output should look like this:
Enter the exponents (double)n and (int)m: 1.5 6
Enter the coefficients A and B: 2.5 -3.75
Enter the bounds for the integration interval, a < b : 1.05 4.05
Integrate f(x) on [a,b]
Enter the number of trapezoids: 10000
The length of the subinterval del_x = .......
The value of the integral is ...... .
Explanation / Answer
#include #include double Intgr(n, m, A, B, a, b); double func(x, n, m, A, B); double mfact(m); double m, A, a, b, x, del_x, sum, f, integral, subinterval; int n, k, n_trap; main() { printf(" Enter the exponents (double)n and (int)m: "); scanf("%d %f", &n, &m); printf("Enter the coefficients A and B: "); scanf("%f", &A); printf("Enter the bounds for the integration interval, aRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.