Skip to main content
Fix evaluation error
Source Link
Carl Woll
  • 131.7k
  • 6
  • 246
  • 359

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

Conjugate[Derivative[1][f][x]]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[(f^(1,0,0))[a,y,z]]Conjugate[Derivative[1][f][x]]

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

Conjugate[Derivative[1][f][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[(f^(1,0,0))[a,y,z]]

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

Source Link
Carl Woll
  • 131.7k
  • 6
  • 246
  • 359

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

Conjugate[Derivative[1][f][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[(f^(1,0,0))[a,y,z]]