I want to take the derivative of this with respect to eta:
fabc = 1/2 (-3 + 27/(2 + x)^2 + (1 - 1/(1 + (-1 + x) c[eta/cc])^2)/ c[eta/cc] + 2 Log[x])
Here I take the derivative:
totalderivativeb = FullSimplify[\!\( \*SubscriptBox[\(\[PartialD]\), \(eta\)]fabc\)]
The result is:
((-1 + x)^2 (3 + (-1 + x) c[eta/cc]) Derivative[c][eta/ cc])/(2 cc (1 + (-1 + x) c[eta/cc])^3)
This result is different than what I get if I take the derivative by hand. Additionally, if I take the finite difference derivative of my function, it matches what I get by hand (numerically), but does not match at all what mathematica gives me.
I have pulling my hair out all day trying to figure out what I am doing incorrectly in mathematica and why it gives me a different answer.
Any ideas what I am doing wrong? Is it not handling some chain rule or something?
Note that "cc" is just a constant.
When I take the derivative by hand, I get below. sorry it is my C++ code. I know it's messy, but it is correct, whereas the mathematica result is not correct. I think mathematica is not doing the chain rule or something appropriately.
double d = 1.0+(x-1.0)*c(rpf); double u1 = c(rpf)* 2.0*d*(x-1.0)*cprime(rpf)/d/d/d/d - (1.0 - 1.0/d/d)*cprime(rpf); double u2 = 2.0*c(rpf)*c(rpf); double first = u1/u2;
Note that "rpf" = eta/cc