2.1.16.2.4 ipow


Description

returns the power of the complex value such that the power is an integer

Syntax

complex ipow( complex z, int n )

Parameters

z
[input] the complex value whose power is sought.
n
[input] the power

Return

z^n

Examples

EX1

void    run_complex_ipow()
{
    complex            cc(sqrt(3.), 1.);    // the complex number whose real part
                                        // is the square root of 3, and imaginary part is 1.
                                        // so that its phase is 30 degrees and amplitude is 2.
    int                n = 3;
    
    complex            cresult = ipow(cc, n);
    
    out_complex("Input = ", cc);
    out_int("power = ", n);
    out_complex("ipow = ", cresult);    // the result should be such that its amplitude is 8 (which
                                        // is 2 to the power 3) and whose phase is 90 degrees (which
                                        // is 30 degrees times 3).
                                        // so "ipow = -0.000000+8.000000i"
}

Remark

See Also

Header to Include

origin.h

Reference