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.
Answer
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 *)
d[g][x]
(* \[ExponentialE]^(-\[ImaginaryI] x)/2+
\[ExponentialE]^(\[ImaginaryI] x)/2 *)
d[Conjugate[g]][x]
(* Conjugate[1/2 \[ExponentialE]^(-\[ImaginaryI] x)
(1+\[ExponentialE]^(2 \[ImaginaryI] x))] *)
Update
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.:
h[x_]:=Sin[x]
d[h,0][x] (* Sin[x] *)
d[h,-1][x] (* -Cos[x] *)
d[h,1][x] (* Cos[x] *)
d[h][x] (* Cos[x] *)
Comments
Post a Comment