#include <cmath>
#include <string>
#include <vector>

#include "globale.h"
#include "info.h"
#include "calcul.h"

double EvalDer(int Indice, double x)
{
	double Retour = Derivees[Indice];
	double Temp;
	
	for (unsigned int i = Indice + 1; i < Derivees.size(); i++)
	{
		Temp = Derivees[i]*pow(x-LesInfos.x0, i - Indice);
		for (int j = i - Indice; j > 1; j--)
			Temp /= double(j);

		Retour += Temp;
	}

	return Retour;
}


double Derive(double x, int ordre, const type_formule& Formule)
{
	if (ordre == 2)
		return (Formule.Valeur(x));

	return ( (Derive(x+LesInfos.Epsilon, ordre-1, Formule) - 
			  Derive(x-LesInfos.Epsilon, ordre-1, Formule) ) / LesInfos.Epsilon ) / 2.0;
}
