---
title: "Fast implementation/approximation of pow() function in C/C++"
author: "vergilwang"
date: "2013-03-29T16:42:00Z"
tags: []
categories: ["互联网"]
slug: "fast-implementation-approximation-of-pow-function-in-c-c"
draft: false
lastmod: "2014-02-15T15:34:03Z"
id: 2011259
url: "https://vergilwang.iteye.com/blog/2011259"
---

老外的帖子

Sure - it's easy if you have exponential and natural log functions.

Since`y = x^n`, you can take the natural log of both sides:

```c
ln(y)= n*ln(x)
```

Then taking the exponential of both sides gives you what you want:

```c
y = exp(n*ln(x))
```

If you want something better, the best place I know to look is[Abramowitz and Stegun](http://www.math.ucla.edu/~cbm/aands/).