I have some function,
int somefunction( //parameters here, let's say int x) {
return something Let's say x*x+2*x+3 or does not matter
}
How do I find the derivative of this function? If I have
int f(int x) {
return sin(x);
}
after derivative it must return cos(x).
You can approximate the derivative by looking at the gradient over a small interval. Eg
Depending on where you’re evaluating the function, you might get better results from
(f(x+DELTA) - f(x-DELTA)) / 2*DELTAinstead.(I assume ‘int’ in your question was a typo. If they really are using integers you might have problems with precision this way.)