2
$\begingroup$

I have to take the partial differentiation of an unknown function. For example, take the unknown function to be $g(x)$. Then it's derivative w.r.t $x$ is $g'(x)$.

By default, Mathematica differentiates the function. I want to keep the result of differentiation as $d(g(x))$ and not $g'(x)$. Is there any way to achieve this?

More precisely, I am using Conjugate[g[x]] as the unknown function and I want the output should be displayed only as d[Conjugate[g[x]] and not as Conjugate'[x]g'[x].

Also, can I handle the conjugate more efficiently than just carrying it all along in the code?

$\endgroup$
2
$\begingroup$

Edited because the goal was changed in the comment:

This can be done by directly defining the outcome of Derivative when applied to g in the two combinations that you seem to be interested in:

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]]

On the second line, I used the fact that g is a generic function whose derivative under a Conjugate by default invokes the chain rule. All I do then is to reverse the chain rule by dividing by the factor d[g[x]] that the chain rule will produce. This leaves only the factor I want, and I then replace that by the desired outcome d[Conjugate[g[x]]].

The analogous thing is done for d to allow higher derivatives. The exception is when d[x] is encountered where x is the differentiation variable (which isn't in the question, but I expect may happen). Then there is no chain rule needed, and I therefore specify a separate rule for it with the pattern x_Symbol.

Here is the test:

D[g[x], x]

(* ==> d[g[x]] *)

D[Conjugate[g[x]], x]

(* ==> d[Conjugate[g[x]]] *)

D[g[x], x, x]

(* ==> d[d[g[x]]] *)

D[d[g[x]], x]

(* ==> d[d[g[x]]] *)

D[d[x], x]

(* ==> d[d[x]] *)

D[Conjugate[g[x]], x]

(* ==> Conjugate[d[g[x]]] *)

D[Conjugate[g[x]], x, x]

(* ==> Conjugate[d[d[g[x]]]] *)

Now the remaining issue is to replace the repeated application of d by formatting of the type d^2 g[x] for d[d[g[x]]]. I'll wait to see if this is really desired before doing it.

$\endgroup$
  • $\begingroup$ Thanks for your input. This is exactly what I need. Can you please modify the output of D[Conjugate[g[x]], x] as Conjugate[d[g[x]] and not as d[Conjugate[g[x]]] . You are free to change the above mentioned approach of yours if needed. Anyways, Many Many thanks for your input. $\endgroup$ – Shivam Sahu Mar 5 '15 at 12:41
  • $\begingroup$ You just hve to do this: Derivative[1][Conjugate][g[x_]] := Conjugate[d[g[x]]]/d[g[x]] (but that's not what you asked in the question. $\endgroup$ – Jens Mar 5 '15 at 14:51
  • $\begingroup$ Thanks. This serves my purpose well. Can you please also help me with obtaining the double derivative of g[x] and Conjugate[g[x]] as d^2 g[x] and Conjugate[d^2[g[x]]]. I tried it all this time but I am unable to obtain the above desired representation. $\endgroup$ – Shivam Sahu Mar 7 '15 at 17:48
  • $\begingroup$ What you're asking now is very different from the original question because it aims for a new formatting that is inconsistent with Mathematica syntax (because of the squares). It would require box-level manipulations as I did here. $\endgroup$ – Jens Mar 7 '15 at 18:36
3
$\begingroup$

If it is just the displayed form you are after, you can also go with HoldForm like so:

HoldForm@D[Conjugate[g[x]],x]

unevaluated

This will carry over throughout the notebook without further ado, until you call ReleaseHold on it.

I hope this might be of some help to you.

$\endgroup$

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.