Skip to main content
added 848 characters in body
Source Link
Jess Riedel
  • 1.5k
  • 10
  • 25

This becomes terrible when you have multiple exponentials. (Edit: Interestingly, you can occasionally prevent ComplexExpand from converting Exp's to Cos's and Sin's using the option TargetFunctions -> Conjugate. This does't help with a E^(I b), but it does help with a E^(I b)+c E^(I d). Note that TargetFunctions -> Exp is not an allowed option.)

This becomes terrible when you have multiple exponentials.

This becomes terrible when you have multiple exponentials. (Edit: Interestingly, you can occasionally prevent ComplexExpand from converting Exp's to Cos's and Sin's using the option TargetFunctions -> Conjugate. This does't help with a E^(I b), but it does help with a E^(I b)+c E^(I d). Note that TargetFunctions -> Exp is not an allowed option.)

added 848 characters in body
Source Link
Jess Riedel
  • 1.5k
  • 10
  • 25

EDIT: Cheng Tao found an example with undesired behavior:

Conj[a Exp[I b] + c Exp[I d]]

Conjugate[a $e^{i b}$ + c $e^{i d}$]

This seems to be an issue with Conjugate not automatically distributing over addition. I have a patch to fix this behavior, but I suspect there is still an underlying pathology:

ConjNew[x_] := Refine[
    Conjugate[x] //. {Conjugate[sum_Plus] :> Conjugate /@ sum}, 
   _Symbol ∈ Reals];
ConjNew[a Exp[I b] + c Exp[I d]]

a $e^{-i b}$ + c $e^{-i d}$

(I could not find a way to use Distribute to fix this. Note also the issues with using Plus in a pattern.)

EDIT: Cheng Tao found an example with undesired behavior:

Conj[a Exp[I b] + c Exp[I d]]

Conjugate[a $e^{i b}$ + c $e^{i d}$]

This seems to be an issue with Conjugate not automatically distributing over addition. I have a patch to fix this behavior, but I suspect there is still an underlying pathology:

ConjNew[x_] := Refine[
    Conjugate[x] //. {Conjugate[sum_Plus] :> Conjugate /@ sum}, 
   _Symbol ∈ Reals];
ConjNew[a Exp[I b] + c Exp[I d]]

a $e^{-i b}$ + c $e^{-i d}$

(I could not find a way to use Distribute to fix this. Note also the issues with using Plus in a pattern.)

fixed i --> I
Source Link
Jess Riedel
  • 1.5k
  • 10
  • 25
Conj[a+ib]Conj[a + I b]

$a-ib$ a - i b

Conj[x_, exclu_:{}] := 
          Refine[Conjugate[x], _?((Head[#] == Symbol && ! MemberQ[exclu, #]) &) ∈ Reals];
Conj[a + iI b, {b}]
Conjugate[a+ib]Conjugate[a + I b]
ComplexExpand[Conjugate[a+ib]]ComplexExpand[Conjugate[a + I b]]
ComplexExpand[Conjugate[Exp[a + iI b]]]
Refine[Conjugate[a+ib]Refine[Conjugate[a + I b], _∈_ Reals]

a  -ib i b

Refine[Conjugate[Sqrt[i*a]]Refine[Conjugate[Sqrt[I*a]], _ ∈ Reals]
Refine[Conjugate[a+ibRefine[Conjugate[a + I b, {a,b} ∈ Reals}]
Simplify[Conjugate[iSimplify[Conjugate[I(x^2 + 2 x y + y^2)], _Symbol ∈ Reals]

$-i (x - y)^2$-i $($x - y$)^2$

when you may really have wanted $-i(x^2 + 2 x y + y^2)$-I(x^2 + 2 x y + y^2).

(a + iI b) /. {iI -> -iI}
Exp[-i]I] /. {iI -> -iI}
FullForm[Exp[-i]]I]]
Conj[a+ib]

$a-ib$

Conj[x_, exclu_:{}] := 
          Refine[Conjugate[x], _?((Head[#] == Symbol && ! MemberQ[exclu, #]) &) ∈ Reals];
Conj[a + i b, {b}]
Conjugate[a+ib]
ComplexExpand[Conjugate[a+ib]]
ComplexExpand[Conjugate[Exp[a + i b]]]
Refine[Conjugate[a+ib], _∈ Reals]

a-ib

Refine[Conjugate[Sqrt[i*a]], _ ∈ Reals]
Refine[Conjugate[a+ib, {a,b} ∈ Reals}]
Simplify[Conjugate[i(x^2 + 2 x y + y^2)], _Symbol ∈ Reals]

$-i (x - y)^2$

when you may really have wanted $-i(x^2 + 2 x y + y^2)$.

(a + i b) /. {i -> -i}
Exp[-i] /. {i -> -i}
FullForm[Exp[-i]]
Conj[a + I b]

a - i b

Conj[x_, exclu_:{}] := 
          Refine[Conjugate[x], _?((Head[#] == Symbol && ! MemberQ[exclu, #]) &) ∈ Reals];
Conj[a + I b, {b}]
Conjugate[a + I b]
ComplexExpand[Conjugate[a + I b]]
ComplexExpand[Conjugate[Exp[a + I b]]]
Refine[Conjugate[a + I b], _ Reals]

a  - i b

Refine[Conjugate[Sqrt[I*a]], _ ∈ Reals]
Refine[Conjugate[a + I b, {a,b} ∈ Reals}]
Simplify[Conjugate[I(x^2 + 2 x y + y^2)], _Symbol ∈ Reals]

-i $($x - y$)^2$

when you may really have wanted -I(x^2 + 2 x y + y^2).

(a + I b) /. {I -> -I}
Exp[-I] /. {I -> -I}
FullForm[Exp[-I]]
added 189 characters in body
Source Link
Jess Riedel
  • 1.5k
  • 10
  • 25
Loading
Source Link
Jess Riedel
  • 1.5k
  • 10
  • 25
Loading