Returns base raised to the power of exponent.
math.pow(base, exponent) multiplies base by itself exponent times for whole exponents, and handles fractions through roots: math.pow(x, 0.5) is the square root.
A negative base with a fractional exponent has no real result and gives na. Zero to the power of zero is 1.
Syntax
math.pow(base: simple int/float, exponent: simple int/float) -> simple float
math.pow(base: input int/float, exponent: input int/float) -> input float
math.pow(base: const int/float, exponent: const int/float) -> const float
math.pow(base: series int/float, exponent: series int/float) -> series floatArguments
| Name | Type | Default | Description |
|---|---|---|---|
| base | const/ | required | The number that is multiplied by itself exponent times. na gives na. |
| exponent | const/ | required | The power to raise it to. |
Returns
const/input/simple/series float: base to the power of exponent.
Remarks
- A negative exponent gives a reciprocal:
math.pow(2, -1)is 0.5.
Example
//@version=6
indicator("Compound growth")
growth = math.pow(1 + 0.01, bar_index)
plot(math.log(growth), "Log growth", color = color.blue)See also
Runs on Sidechair