I have the following exercise to perform a class that calculates several of the properties of a mathematical function.
Consider a
y=f(x)
function defined in a[a,b]
interval. You want to sample this function. To this end, the values ofx
y
will be stored in a vector in another the values ofy
corresponding to each value ofx
. This problem seeks to create a class that allows storing the sampled function and carry out certain calculations: first derivative, second derivative, relative maximums and minimums.To this end we ask:
Design a class (not to implement) that stores a sampled function, its first and second derivatives, and allows certain operations to be performed. For this it must consist of:
Attributes that allow to store x , and , and ' and and' '
A constructor passed as a parameter a function
y=f(x)
, a interval[a,b]
, and the number of samplesn
, and create and store x , and , and ' and and' '
I tried to start the class like that but I got stuck:
I'm trying to do section a)
class function{
private:
vector_item_t* x_; // x abajo os dejo la clase vector_t en la que me base
vector_item_t* y_; // y
vector_item_t* y1; // y'
vector_item_t* y2; // y''
public:
/*b) constructor */ function(¿?)
}
I stuck in the second section how I do the parameter that calculates the image of x? when dealing with vectors I do not know how the first and second derivative should be programmed, because they are not polynomials that are ordered according to their degree.
I appreciate any ideas.
class vector_t
typedef double vector_item_t;
typedef unsigned short int vector_inx_t;
class vector_t {
private:
vector_item_t* v_;
vector_inx_t sz_;
public:
vector_t (vector_inx_t n);
~vector_t (void);
void mostrarVector(void);
vector_item_t get_vector_item(vector_inx_t i);
void set_vector_item(vector_inx_t i, vector_item_t it);
vector_inx_t get_sz(void);
};