# How to declare derivatives of a multivariable function as real in order to get Re and Im part of the expression?

Re and Im work properly, with appropriate assumptions, in the example like this

Assuming[g[_, _] ∈ 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[_, _], _]) ∈ 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[_]) ∈ Reals, Simplify[Im[3*I*(D[g[r, r2]*f[r], r]) + 45]]]


gives 3 Re[g[r,r2] (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.

Use the FullForm of the derivatives:
Assuming[(r | g[_, _] | Derivative[1, 0][g][_, _]) ∈ Reals,

Assuming[(r | g[_, _] | f[_] | Derivative[1, 0][g][_, _] | Derivative[1][f][_]) ∈ Reals,

• Great, it works! Form Derivative[_, _][g][_, _] allows for generalizing to arbitrary number of derivatives. – Thela Hun Ginjeet Sep 23 '18 at 10:50