0
#include <cstdlib>
#include <iostream>
//Given that f(x)= exp(x)-sin(2x). Use a Newton object to find the minimum of the
//function

using namespace std;

class Newton{
      protected:
      double precision;
      public:
      Newton(double p):precision(p){};
      virtual ~Newton(){};
      double Find(Function& f, double start){};//Find does the actual
//iteration for a particular function f starting from a value start f is declared as 
//(a reference to) an object of the abstract Function class:
      
};

class Function{
      public:
      Function(){}
      return f;
      }
      virtual ~Function(){};
      virtual double operator()(double x)=0;//operator() does the function evaluation 
//for a particular value x and dfdx evaluates its derivative
      virtual double dfdx(double x)=0;
};

virtual double operator()(double x){
      return exp(x)-sin(2*x);
      }
virtual double dfdx(double x){
      return (exp(x)-cos(2*x)*2.0;
      }
      

int main()
{
    
    
    
    system("PAUSE");
    return EXIT_SUCCESS;
}
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by jonsca
0

Hint: what do lines 26 and 28 tell you about your Function class.

Also, see if you can get some of the implementation of Find. We can't truly know that your professor didn't give you this much with which to start.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.