manpagez: man pages & more
info ginac
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.13 Complex expressions

For dealing with complex expressions there are the methods

 
ex ex::conjugate();
ex ex::real_part();
ex ex::imag_part();

that return respectively the complex conjugate, the real part and the imaginary part of an expression. Complex conjugation works as expected for all built-in functions and objects. Taking real and imaginary parts has not yet been implemented for all built-in functions. In cases where it is not known how to conjugate or take a real/imaginary part one of the functions conjugate, real_part or imag_part is returned. For instance, in case of a complex symbol x (symbols are complex by default), one could not simplify conjugate(x). In the case of strings of gamma matrices, the conjugate method takes the Dirac conjugate.

For example,

 
{
    varidx a(symbol("a"), 4), b(symbol("b"), 4);
    symbol x("x");
    realsymbol y("y");
                                           
    cout << (3*I*x*y + sin(2*Pi*I*y)).conjugate() << endl;
     // -> -3*I*conjugate(x)*y+sin(-2*I*Pi*y)
    cout << (dirac_gamma(a)*dirac_gamma(b)*dirac_gamma5()).conjugate() << endl;
     // -> -gamma5*gamma~b*gamma~a
}

If you declare your own GiNaC functions, then they will conjugate themselves by conjugating their arguments. This is the default strategy. If you want to change this behavior, you have to supply a specialized conjugation method for your function (see Symbolic functions and the GiNaC source-code for abs as an example). Also, specialized methods can be provided to take real and imaginary parts of user-defined functions.


© manpagez.com 2000-2024
Individual documents may contain additional copyright information.