Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

FOR DERIVATIVE THIS IS THE FORMULA double derivative(double (*)(double), double,

ID: 3683798 • Letter: F

Question

FOR DERIVATIVE THIS IS THE FORMULA
double derivative(double (*)(double), double, double);
double derivative(double (*pf)(double t), double x, double h)
{  
   return ((*pf)(x+h) - (*pf)(x-h))/(2*h);  
}
FOR INTEGRATION THIS IS THE FORMULA
double riemann(double (*)(double), double, double, int)
double riemann(double (*pf)(double t), double a, double b, int n)
{
   double s = 0, h = (b-a)/n, x;
   int i;
   for (x = a, i = 0; i < n; x += h, i++)
       s += (*pf)(x);  
   return s*h;  
}

Nicolas Makhoul O Find c-Nico.docx - Word (Unlicensed Product) Home Insert Design Layout References Mailings Review View Grammarly Tell me what you want to do... Share Copy abc Replace Enable Grammarly Grammarly Paste B 1 abe X, X2 A A _ _ _ _ M | | 1 Normal 1 No Spac Heading 1 Heading 2 Title Subtitle Subtle Em Select Format Painter Clipboard Font Paragraph Editing es Write a program that allows the user to select among built-in functions, an interval, and whether to integrate or differentiate. Use the formulas shown in Problems 7.4 and 7.5 and make the interface a menu Use arrays to save function values Test your functions by differentiating the integral function. List as many individual requirements for the above program as you can FOR DERIVATIVE THIS IS THE FORMULA double derivative(double (*)(double), double, double); double derivative(double (*pf)(double t), double x, double h) return ((*pf (xth) (*pf)(xh))/2*h); FOR INTEGRATION THIS IS THE FORMULA double riemann(double (*)(double), double, double, int) double rieouble (*pf)(double t), double a, double b, int n) double s = 0, h = (ba)/n, x; int i Page 1 of 1 139 words + 100% Ask me anything 3:51 PM 3/30/2016 97%

Explanation / Answer

/** C++ code to demostrate differentiatioon and integration of y =x^3 ***/

#include <iostream>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <cmath>

using namespace std;

void interval (double a[])
{
cout << "Low: ";
cin >> a[0];
cout << "High: ";;
cin >> a[1];


}

double cube (double t) // function x^3
{
return t*t*t;
}

double derivative(double (*pf)(double t), double x, double h)
{
return ((*pf)(x+h) - (*pf)(x-h))/(2*h);
}


double riemann(double (*pf)(double t), double a, double b, int n)
{
double s = 0, h = (b-a)/n, x;
int i;
for (x = a, i = 0; i < n; x += h, i++)
s += (*pf)(x);
return s*h;

}

int main()
{
while(1)
{
double a[2];
int choice;
cout << "Select Function: ";
cout << "1.Interval 2.Integration 3.Derivation ";
cin >> choice;
if (choice == 1)
{
interval(a);
}
else if(choice == 2)
{
int n;
cout << "Enter n: ";
cin >> n;
cout << "Value for function x^3: "<< riemann(cube,a[0],a[1],n)<< endl;
}
else if(choice == 3)
{
double x,h;
cout << "Enter x: ";
cin >> x;
cout << "Enter h: ";
cin >> h;
cout << "Value for function x^3: "<< derivative(cube,x,h)<< endl;

}
else break;

}

return 0;
}