4
$\begingroup$

I have a problem with Mathematica, taking the derivative of the conjugate of some function. I know that a similar question has been posed before here, but the solution did not work for multivariate function.

Problem is: I try to evaluate

D[Conjugate[f[x, y, z]], x]

And get the result

Conjugate'[f[x, y, z]] f^(1, 0, 0)[x, y, z]

But would like

Conjugate[f^(1, 0, 0)[x, y, z]]

where ^ is supposed to be superscript. Can anyone help me resolve this?

$\endgroup$
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – Michael E2 Aug 11 '15 at 11:30
  • 1
    $\begingroup$ MapAt[D[#, x] &, Conjugate[f[x, y, z]], 1] or Map[D[#, x] &, Conjugate[f[x, y, z]]] or D[#, x] & /@ Conjugate[f[x, y, z]]. $\endgroup$ – march Aug 11 '15 at 15:51
10
$\begingroup$

There are System options one can set to control the behavior of D. One of these is the "ExcludedFunctions" option:

excluded="ExcludedFunctions"/.
    ("DifferentiationOptions"/.SystemOptions["DifferentiationOptions"])

{Hold,HoldComplete,Less,LessEqual,Greater,GreaterEqual,Inequality,Unequal,Nand,Nor,Xor,Not,Element,Exists,ForAll,Implies,Positive,Negative,NonPositive,NonNegative,Replace,ReplaceAll,ReplaceRepeated}

These are functions that D will not differentiate. We can add Conjugate to this list by using:

SetSystemOptions["DifferentiationOptions"->
    "ExcludedFunctions"->Union[excluded,{Conjugate}]]

DifferentiationOptions->{AlwaysThreadGradients->False,DifferentiateHeads->True,DifferentiateIteratorIndexed->True,DirectHighDerivatives->True,DirectHighDerivativeThreshold->10,ExcludedFunctions->{Conjugate,Element,Exists,ForAll,Greater,GreaterEqual,Hold,HoldComplete,Implies,Inequality,Less,LessEqual,Nand,Negative,NonNegative,NonPositive,Nor,Not,Positive,Replace,ReplaceAll,ReplaceRepeated,Unequal,Xor},ExitOnFailure->False,HighDerivativeMaxTerms->1000,SymbolicAutomaticDifferentiation->False}

Now, D will not try to differentiate Conjugate:

D[Conjugate[f[x]], x]//InputForm

D[Conjugate[f[x]], x]

We are now free to give D rules for differentiating Conjugate:

Unprotect[Conjugate];
Conjugate /: D[Conjugate[f_], x__] := Conjugate[D[f, x]]
Protect[Conjugate];

Let's see what happens to the OP example now:

D[Conjugate[f[x, y, z]], x]

Conjugate[Derivative[1][f][x]]

$\endgroup$
6
$\begingroup$

I think what you want is something like this:

Conjugate[f[x_, y_, z_]] ^:= cf[x, y, z]

Derivative[d__][cf][x__] := Conjugate[Derivative[d][f][x]]

D[Conjugate[f[x, y, z]], x]

Conjugate[Derivative[1, 0, 0][f][x, y, z]]

All I did here is to define the derivative of the function f to be another function cf which then can be given the property you want.

$\endgroup$
  • $\begingroup$ Is the ^ before the := a typo? $\endgroup$ – AccidentalFourierTransform May 23 '18 at 15:39
  • $\begingroup$ @AccidentalFourierTransform No, it's UpSetDelayed. $\endgroup$ – Jens May 23 '18 at 17:05
  • $\begingroup$ Oh, that's a new one for me, cool. Thanks! $\endgroup$ – AccidentalFourierTransform May 23 '18 at 17:14
  • $\begingroup$ Just a last question, as this is going to be very helpful for me. If we take cf[x,y,z] =-E^(-2 I x) + 2 E^(-I y - I z) + 2 E^(-3 I z - I x) + 12 E^(-2 I y - 2 I x). It doesn't work. I'm sure I'm missing something ? $\endgroup$ – Shamina Oct 3 '18 at 21:40
  • $\begingroup$ @Shamina cf is supposed to remain purely symbolic. I don't understand what you're trying to do with the = assignment. Even if you change that to cf[x_,y_,z_] := ... it wouldn't correspond to what this question was originally about. You may have to ask a new question. $\endgroup$ – Jens Oct 4 '18 at 4:51

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.