I'm designing a project that applies derivatives to solve several problems... but the main program doesn't really focus on derivation itself but in its applications... so I'm looking for a lib that can do the derivation process for me and I can do the rest with the differentiated expression... does anybody know a good one? I found fadbad++ which is free, but it doesn't give me a symbolic derivative, it gives me an automatic one...
Are you trying to derive an expression for academic purposes or are you trying to calculate a practical derivative?
If you are doing a practical exercise then it is as simple as keeping track of the previous value of your variable and dividing it by the time difference or another variable since the last iteration of your main loop.
example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
void LoopedFunction(double dT) //This function is called every dT seconds.
{
staticdouble x_prev, y_prev;
double x, y, dxdt, dxdy;
x = ...//Function stuff.
y = ...//Function stuff.
dxdt = (x-x_prev)/(dT);
dxdy = (x-x_prev)/(y-y_prev);
x_prev = x;
y_prev = y;
}
Another idea is that if you have a function f(x) and you want to find f'(x) for x = a value, then do it like this: dx/dy = ( f(x+0.0001)-f(x-0.0001) ) / 0.0002;
if f(x) = x^2, then in code it would look like this:
1 2 3 4 5 6 7 8 9 10 11
double f( double x )
{
return x * x; //f(x) here
}
double f_prime(double x) //Finds the derivative at point x
{
double resolution = 0.001; // Reduce this for better resolution
double dxdy = (f(x+resolution) - f(x-resolution)) / (2 * resolution);
return dxdy;
}