Mma does not know in advance if x is real, or complex. Indeed, if one defines your function and tries to get its real part:
f[x_] := x^2 + I x^3
Re[f[x]]
(* -Im[x^3] + Re[x^2] *)
Mma returns the result as if x were complex. One can use the functionality of Simplify
, to fix it:
Simplify[ Re[f[x]], x \[Element] Reals]
Simplify[ Im[f[x]], x \[Element] Reals]
(* x^2
x^3 *)
There is, however another way, that may seem you comfortable. Assuming f[x], has already been defined, let us define its imaginary and real parts as follows:
Ref[x_] := (List @@ f[x])[[1]]
IImf[x_] := (List @@ f[x])[[2]]
Then
D[Ref[x], x]
D[IImf[x], x]
(* 2 x
3 I x^2 *)
Have fun!
D[f[x], x]
orf'[x]
orf'[1]
gives you the derivatives of the real and imaginary parts simultaneously. $\endgroup$