class Function {     public:     virtual double compute(double value) = 0;     virtual double differenciate(double value) = 0;     virtual double integrate(double value) = 0; }; class Sine...

50.1K

Verified Solution

Question

Programming

class Function

{

    public:

    virtual double compute(double value) =0;

    virtual double differenciate(doublevalue) = 0;

    virtual double integrate(double value) =0;

};

class Sine : public Function

{

    public:

    double compute(double value); // computesin(x) for a given x

    double differenciate(double value); //compute derivative sin'(x) for a given x

    double integrate(double value); //integrate sin(x) for a given x

};

class Tangent : public Function

{

    public:

    double compute(double value); // computetan(x) for a given x

    double differenciate(double value); //compute derivative tan'(x) for a given x

    double integrate(double value); //integrate tan(x) for a given x

};

The classes represent mathematical functions, where eachfucntion f(x) (e.g. sine, tangent) can becomputed, differenciated and integrated for a given x.

Write a method named productRule to compute thederivative of a product of any two functions. Using the notationf’(x) to indicate the derivative of functionf(x), the derivative of the productf(x)*g(x) is defined asf(x)*g’(x)+g(x)*f’(x), where f(x)and g(x) are any two given functions, andf’(x) and g’(x) are functionderivatives, respectively. Your method should be applicable to anytwo functions derived from the Function interface.An example of the mehod call is given below:

Sine sin;  // the sine function

Tangent tan;   // the tangent function

double answer = sin.productRule(tan,5.3);    // compute the derivative ofsin(5.3)/tan(5.3)

Use C++98

Answer & Explanation Solved by verified expert
4.0 Ratings (837 Votes)
    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students