I have a complex function, lets say $g(x)$. I want to take its and its conjugate's derivative. I need the solution of derivative which must be symbolically and computationally efficient.
Lets take an example:

Derivative[1][g][x_] := d[g[x]]

Derivative[1][Conjugate][g[x_]] := Conjugate[d[g[x]]]/d[g[x]];
Derivative[1][Conjugate][d[x_]] := Conjugate[d[d[x]]]/d[d[x]]

Derivative[1][d][x_] := d[d[x]]/d[x];
Derivative[1][d][x_Symbol] := d[d[x]] 

This will give me an effective symbolic representation of the derivative of $g(x)$ and $Conjugate(g(x))$ as d[g[x]] and Conjugate[d[g[x]]] but when I have to plug the analytical complex expression of $g(x)$ in d[g[x]], it will not compute the derivative of $g(x)$ instead gives only the symbolic representation of $d(g(x))$, which is computationally inefficient.
Is something can be done which is capable of symbolic as well as algebraic computation.

P.S. I do need the symbolic representation of the derivatives of conjugate in the above format only.


Maybe you can use the following two constructs to your advantage, which will keep the Conjugate, but evaluate and simplify the derivative inside. Using ReleaseHold, you can then evaluate even the Conjugate.

Note that I left out the divisor in the Conjugate-case for clarity, but you can easily add that into the second function's definition.

d[g_] := Derivative[1][g]
d[Conjugate[g_]] := With[{dg = d[g]@# // Simplify},
                      HoldForm[Conjugate[dg]] &]

(* example function *)
g[x_] := TrigToExp@Sin[x]

(* evaluation *)
(* \[ExponentialE]^(-\[ImaginaryI] x)/2+
      \[ExponentialE]^(\[ImaginaryI] x)/2 *)

(* Conjugate[1/2 \[ExponentialE]^(-\[ImaginaryI] x)
      (1+\[ExponentialE]^(2 \[ImaginaryI] x))] *)


If you want further derivatives, you can instead use this slight expansion of the idea above:

d[g_, n_:1] := Derivative[n][g]
d[Conjugate[g_], n_:1] := With[{dg = d[g, n]@# // Simplify}, HoldForm[Conjugate[dg]] &]

n gives the order of derivation you want. If left out, the first derivative is generated.

Interesting sidenote: n can even be negative, giving you the integral of your function. Observe e.g.:

d[h,0][x]       (* Sin[x] *)

d[h,-1][x]      (* -Cos[x] *)

d[h,1][x]       (* Cos[x] *)
d[h][x]         (* Cos[x] *) 
| improve this answer | |
  • $\begingroup$ Thanks for your input. Can you please tell me, where to read from to understand such programming in mathematica in a better way? I couldn't find this type of programming in any textbooks. $\endgroup$ – Shivam Sahu Mar 20 '15 at 13:53
  • 1
    $\begingroup$ @ShivamSahu: I can only speak for myself: I learned the little I know about Mathematica from its documentation and my own humble experiments. If my answer helped in your quest, please "accept" it. $\endgroup$ – Jinxed Mar 20 '15 at 20:27
  • $\begingroup$ I have one more question. How can we handle double derivative of g(x) and Conjugate(g(x)) with this? $\endgroup$ – Shivam Sahu Mar 22 '15 at 12:31
  • $\begingroup$ @ShivamSahu: Have a look at the update I made to my answer. :) $\endgroup$ – Jinxed Mar 24 '15 at 13:49
  • $\begingroup$ Thanks for the update. This was precisely what I was looking for. :) $\endgroup$ – Shivam Sahu Mar 25 '15 at 5:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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