2 added 275 characters in body
source | link

The simple rule I to -I is not guaranteed to work, e.g.

Exp[3 I] /. I -> -I

and ComplexConjugate might be too slow (for lengthy expressions). Therefore, I rather define an alternative function to conjugate

ClearAll[AltConjugate]
AltConjugate[x_] := ReplaceAll[xReplaceAll[FullSimplify[x], Complex[a_, b_] -> Complex[a, -b]];

This functions looks for the paternpattern Complex[a_, b_] and replaces it by Complex[a, -b]. In-so

@celtschk -far this roots might be problematic, simple functions like f[x_]=Sqrt[-x^2] can be handle by simplifying the input function returns, i.e. adding FullSimplify in the correct resultdefinition of AltConjugate. Nevertheless, ifthis will fail for functions including more general roots, such as f[x]=Sqrt[-x^2 +I b] where both x and if only all variablesb are realreals. Nevertheless

Use this carefully and always test it.

Cheers.

The simple rule I to -I is not guaranteed to work, e.g.

Exp[3 I] /. I -> -I

and ComplexConjugate might be too slow (for lengthy expressions). Therefore, I rather define an alternative function to conjugate

ClearAll[AltConjugate]
AltConjugate[x_] := ReplaceAll[x, Complex[a_, b_] -> Complex[a, -b]];

This functions looks for the patern Complex[a_, b_] and replaces it by Complex[a, -b]. In-so-far this function returns the correct result, if and if only all variables are real. Nevertheless test it.

Cheers.

The simple rule I to -I is not guaranteed to work, e.g.

Exp[3 I] /. I -> -I

and ComplexConjugate might be too slow (for lengthy expressions). Therefore, I rather define an alternative function to conjugate

ClearAll[AltConjugate]
AltConjugate[x_] := ReplaceAll[FullSimplify[x], Complex[a_, b_] -> Complex[a, -b]];

This functions looks for the pattern Complex[a_, b_] and replaces it by Complex[a, -b].

@celtschk - roots might be problematic, simple functions like f[x_]=Sqrt[-x^2] can be handle by simplifying the input function, i.e. adding FullSimplify in the definition of AltConjugate. Nevertheless, this will fail for functions including more general roots, such as f[x]=Sqrt[-x^2 +I b] where both x and b are reals.

Use this carefully and always test it.

Cheers.

1
source | link

The simple rule I to -I is not guaranteed to work, e.g.

Exp[3 I] /. I -> -I

and ComplexConjugate might be too slow (for lengthy expressions). Therefore, I rather define an alternative function to conjugate

ClearAll[AltConjugate]
AltConjugate[x_] := ReplaceAll[x, Complex[a_, b_] -> Complex[a, -b]];

This functions looks for the patern Complex[a_, b_] and replaces it by Complex[a, -b]. In-so-far this function returns the correct result, if and if only all variables are real. Nevertheless test it.

Cheers.