CodeCogs - An iteractive open source Numerical library Welcome... Login
CodeCogs
shopping cart
OSXWindowsLinux
Search CodeCogs
Numerical Pages

Valid RSS

CMath.h

pow

About | FAQ | Contact
About FAQ Contact

Power function

viewed 36370 times


+View other versions (3)
Contents -

Interface

#include <math.h>
double pow (double x, double y)
long powl (long double x, long double y)
float powf (float x, float y)

#include <complex.h>
double complex cpow (double complex x, complex double y)
float complex cpowf (float complex x, complex float y)
long double complex cpowl (long double complex x, complex long double y)

Description

The pow functions compute x raised to the power of y, i.e.
Example 1:
#include <math.h>
#include <stdio.h>
 
int main(void)
{
  for(int i = 1; i < 5; i++)
     printf("pow(3.2, %d) = %lf\n", i, pow(3.2, i));  
  return 0;
}

Output:
pow(3.2, 1) = 3.200000
pow(3.2, 2) = 10.240000
pow(3.2, 3) = 32.768000
pow(3.2, 4) = 104.857600

Special Values

pow ( ±0, y ) returns ±∞ and raises the divide-by-zero floating-point exception for y an odd integer.
pow ( ±0, y ) returns +∞ and raises the divide-by-zero floating-point exception for y < 0 and not an odd integer. \n pow ( \a ±0, \a y ) returns ±0 for \a y an odd integer > 0.
pow ( ±0, y ) returns +0 for y > 0 and not an odd integer.
pow ( -1, ±∞ ) returns 1.
pow ( 1, y ) returns 1 for any y, even a NaN.
pow ( x, ±0 ) returns 1 for any x, even a NaN.
pow ( x, y ) returns a NaN and raises the invalid floating-point exception for finite x < 0 and finite non-integer y.
pow ( x, -∞ ) returns +∞ for |x| < 1. \n pow ( \a x, \a -∞ ) returns +0 for |x| > 1.
pow ( x, +∞ ) returns +0 for |x| < 1. \n pow ( \a x, \a +∞ ) returns +∞ for |x| > 1.
pow ( -∞, y ) returns -0 for y an odd integer < 0. \n pow ( \a -∞, \a y ) returns +0 for \a y < 0 and not an odd integer. \n pow ( \a -∞, \a y ) returns -∞ for \a y an odd integer > 0. \n pow ( \a -∞, \a y ) returns +∞ for \a y > 0 and not an odd integer.
pow ( +∞, y ) returns +0 for y < 0. \n pow ( \a +∞, \a y ) returns +∞ for \a y > 0.

A domain error occurs if x is finite and negative and y is finite and not an integer.

A domain error can occur if x is 0 and y less than or equal to 0.

See Also

exp, log

Standards

The pow function conforms to ISO/IEC 9899:1999(E).
Last Modified: 2009-11-01 08:42:07     Page Rendered: 2010-03-13 17:58:09

Page Comments

Format Excel Equations

  You must login to leave a messge


Valid CSS!   Valid XHTML 1.0 Transitional