Re
and Im
work properly, with appropriate assumptions, in the example like this
Assuming[g[_, _] \[Element]∈ Reals, Simplify[Im[3*I*g[r, r2] + 45]]]
On the other hand, if the derivative of the function is also present, similar approach does not work
Assuming[(r | g[_, _] | D[g[_, _], _]) \[Element]∈ Reals,
Simplify[Im[3*I*D[g[r, r2], r] + 45]]]
i.e. does not give back 3*D[g[r, r2], r]
More dramatically,
Assuming[(r | g[_, _] | f[_]) \[Element]∈ Reals, Simplify[Im[3*I*(D[g[r, r2]*f[r], r]) + 45]]]
gives 3 Re[g[r,r2] (f^\[Prime]f^′)[r]+f[r] (g^(1,0))[r,r2]]
.
In real problem, I have the function of four variables and mixed partial derivatives, so it would be great if there is some generic way to prescribe all of function's derivatives as Real.