2
$\begingroup$

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.

$\endgroup$

1 Answer 1

3
$\begingroup$

Use the FullForm of the derivatives:

Assuming[(r | g[_, _] | Derivative[1, 0][g][_, _]) ∈ Reals, 
   Simplify[Im[3*I*D[g[r, r2], r] + 45]]]

enter image description here

Assuming[(r | g[_, _] | f[_] | Derivative[1, 0][g][_, _] | Derivative[1][f][_]) ∈ Reals, 
   Simplify[Im[3*I*(D[g[r, r2]*f[r], r]) + 45]]]

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ Great, it works! Form Derivative[_, _][g][_, _] allows for generalizing to arbitrary number of derivatives. $\endgroup$ Commented Sep 23, 2018 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.