Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      cpowf, cpow, cpowl

      From cppreference.com
      <c‎ |numeric‎ |complex
       
       
       
      Complex number arithmetic
      Types and the imaginary constant
      (C99)
      (C99)    
      (C11)
      (C99)
      Manipulation
      (C99)
      (C99)
      (C99)
      (C99)
      (C99)
      (C99)
      Power and exponential functions
      (C99)
      (C99)
      cpow
      (C99)
      (C99)
      Trigonometric functions
      (C99)
      (C99)
      (C99)
      (C99)
      (C99)
      (C99)
      Hyperbolic functions
      (C99)
      (C99)
      (C99)
      (C99)
      (C99)
      (C99)
       
      Defined in header<complex.h>
      floatcomplex       cpowf(floatcomplex x,floatcomplex y);
      (1)(since C99)
      doublecomplex      cpow(doublecomplex x,doublecomplex y);
      (2)(since C99)
      longdoublecomplex cpowl(longdoublecomplex x,longdoublecomplex y);
      (3)(since C99)
      Defined in header<tgmath.h>
      #define pow( x, y )
      (4)(since C99)
      1-3) Computes the complex power function xy
      , with branch cut for the first parameter along the negative real axis.
      4) Type-generic macro: If any argument has typelongdoublecomplex,cpowl is called. if any argument has typedoublecomplex,cpow is called, if any argument has typefloatcomplex,cpowf is called. If the arguments are real or integer, then the macro invokes the corresponding real function (powf,pow,powl). If any argument is imaginary, the corresponding complex number version is called.

      Contents

      [edit]Parameters

      x, y - complex argument

      [edit]Return value

      If no errors occur, the complex powerxy
      , is returned.

      Errors and special cases are handled as if the operation is implemented bycexp(y*clog(x)), except that the implementation is allowed to treat special cases more carefully.

      [edit]Example

      Run this code
      #include <stdio.h>#include <complex.h> int main(void){doublecomplex z= cpow(1.0+2.0*I,2);printf("(1+2i)^2 = %.1f%+.1fi\n",creal(z),cimag(z)); doublecomplex z2= cpow(-1,0.5);printf("(-1+0i)^0.5 = %.1f%+.1fi\n",creal(z2),cimag(z2)); doublecomplex z3= cpow(conj(-1),0.5);// other side of the cutprintf("(-1-0i)^0.5 = %.1f%+.1fi\n",creal(z3),cimag(z3)); doublecomplex z4= cpow(I, I);// i^i = exp(-pi/2)printf("i^i = %f%+fi\n",creal(z4),cimag(z4));}

      Output:

      (1+2i)^2 = -3.0+4.0i(-1+0i)^0.5 = 0.0+1.0i(-1-0i)^0.5 = 0.0-1.0ii^i = 0.207880+0.000000i

      [edit]References

      • C11 standard (ISO/IEC 9899:2011):
      • 7.3.8.2 The cpow functions (p: 195-196)
      • 7.25 Type-generic math <tgmath.h> (p: 373-375)
      • G.6.4.1 The cpow functions (p: 544)
      • G.7 Type-generic math <tgmath.h> (p: 545)
      • C99 standard (ISO/IEC 9899:1999):
      • 7.3.8.2 The cpow functions (p: 177)
      • 7.22 Type-generic math <tgmath.h> (p: 335-337)
      • G.6.4.1 The cpow functions (p: 479)
      • G.7 Type-generic math <tgmath.h> (p: 480)

      [edit]See also

      (C99)(C99)(C99)
      computes the complex square root
      (function)[edit]
      (C99)(C99)
      computes a number raised to the given power (\(\small{x^y}\)xy)
      (function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=c/numeric/complex/cpow&oldid=77465"

      [8]ページ先頭

      ©2009-2025 Movatter.jp