simple-squiggle

A restricted subset of Squiggle
Log | Files | Refs | README

pow.md (1382B)


      1 <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
      2 
      3 # Function pow
      4 
      5 Calculates the power of x to y, `x ^ y`.
      6 Matrix exponentiation is supported for square matrices `x`, and positive
      7 integer exponents `y`.
      8 
      9 For cubic roots of negative numbers, the function returns the principal
     10 root by default. In order to let the function return the real root,
     11 math.js can be configured with `math.config({predictable: true})`.
     12 To retrieve all cubic roots of a value, use `math.cbrt(x, true)`.
     13 
     14 
     15 ## Syntax
     16 
     17 ```js
     18 math.pow(x, y)
     19 ```
     20 
     21 ### Parameters
     22 
     23 Parameter | Type | Description
     24 --------- | ---- | -----------
     25 `x` | number &#124; BigNumber &#124; Complex &#124; Unit &#124; Array &#124; Matrix | The base
     26 `y` | number &#124; BigNumber &#124; Complex | The exponent
     27 
     28 ### Returns
     29 
     30 Type | Description
     31 ---- | -----------
     32 number &#124; BigNumber &#124; Complex &#124; Array &#124; Matrix | The value of `x` to the power `y`
     33 
     34 
     35 ### Throws
     36 
     37 Type | Description
     38 ---- | -----------
     39 
     40 
     41 ## Examples
     42 
     43 ```js
     44 math.pow(2, 3)               // returns number 8
     45 
     46 const a = math.complex(2, 3)
     47 math.pow(a, 2)                // returns Complex -5 + 12i
     48 
     49 const b = [[1, 2], [4, 3]]
     50 math.pow(b, 2)               // returns Array [[9, 8], [16, 17]]
     51 ```
     52 
     53 
     54 ## See also
     55 
     56 [multiply](multiply.md),
     57 [sqrt](sqrt.md),
     58 [cbrt](cbrt.md),
     59 [nthRoot](nthRoot.md)