Skip to main content
2 of 3
added 4 characters in body
kglr
  • 400.5k
  • 18
  • 488
  • 929

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[_, _] \[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])[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.