#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;
}
KLane 0 Newbie Poster
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.