Power (function): Difference between revisions

Jump to navigation Jump to search
523 bytes added ,  14:23, 14 July 2020
m
Text replacement - "http://help.dyalog.com" to "https://help.dyalog.com"
(Created page with ":''This page describes the dyadic arithmetic function. For the monadic natural exponential function (power of e), see Exponential. For the operator that iterates the funct...")
 
m (Text replacement - "http://help.dyalog.com" to "https://help.dyalog.com")
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
:''This page describes the dyadic arithmetic function. For the monadic natural exponential function (power of e), see [[Exponential]]. For the operator that iterates the function operand, see [[Power (operator)]].''
:''This page describes the dyadic function. For the monadic function that uses <math>e</math> as a base, see [[Exponential]]. For the iteration operator, see [[Power (operator)]].''


{{Built-in|Power|*}} is a [[dyadic]] [[scalar function]] which computes the [[wikipedia:exponentiation|exponentiation]] function of the two [[argument|arguments]]. More precisely, <source lang=apl inline>X*Y</source> computes X raised to the power of Y. Power shares the [[glyph]] <source lang=apl inline>*</source> with the monadic arithmetic function [[Exponential]].
{{Built-in|Power|*}} is a [[dyadic]] [[scalar function]] that computes the [[wikipedia:exponentiation|exponentiation]] function of the two [[argument|arguments]], so that <source lang=apl inline>X*Y</source> is <source lang=apl inline>X</source> raised to the power <source lang=apl inline>Y</source>. Power shares the [[glyph]] <source lang=apl inline>*</source> with the monadic arithmetic function [[Exponential]].


== Examples ==
== Examples ==
Line 7: Line 7:
       2*¯1 0 1 2 3 4 5
       2*¯1 0 1 2 3 4 5
0.5 1 2 4 8 16 32
0.5 1 2 4 8 16 32
</source>
A common technique is to choose [[sign]] based on a [[Boolean]] array:
<source lang=apl>
      ¯1*1 0 0 1 0
¯1 1 1 ¯1 1
</source>
</source>


== Properties ==
== Properties ==


For positive integer Y, <source lang=apl inline>X*Y</source> equals the [[times|product]] of Y copies of X. When Y is 0, <source lang=apl inline>X*Y</source> equals 1, possibly except when X is also 0 (since [[wikipedia:zero to the power of zero|zero to the power of zero]] is undefined in mathematics).
For positive integer <source lang=apl inline>Y</source>, <source lang=apl inline>X*Y</source> equals the [[times|product]] of <source lang=apl inline>Y</source> copies of <source lang=apl inline>X</source>. When <source lang=apl inline>Y</source> is 0, <source lang=apl inline>X*Y</source> equals 1, possibly except when <source lang=apl inline>X</source> is also 0 (since [[wikipedia:zero to the power of zero|zero to the power of zero]] is undefined in mathematics).


<source lang=apl>
<source lang=apl>
Line 22: Line 27:
</source>
</source>


[[negate|Negation]] on the power results in the [[reciprocal]] on the return value.
[[negate|Negating]] the exponent (right argument) gives the [[reciprocal]] of the return value.


<source lang=apl>
<source lang=apl>
Line 29: Line 34:
</source>
</source>


[[Reciprocal]] on the power results in the n-th root on the return value. This can be used to calculate the square root.
If the exponent is the [[reciprocal]] of some number n, the result is the n-th [[root]] of the base. For example, a right argument of <source lang=apl inline>÷2</source> gives the [[square root]].


<source lang=apl>
<source lang=apl>
Line 36: Line 41:
       9*÷2
       9*÷2
3
3
</source>
Power has two inverses, [[Root]] and [[Logarithm]]:
<source lang=apl>
      2*3
8
      2⍟8
3
      3√8
2
</source>
</source>


Line 42: Line 57:
=== Documentation ===
=== Documentation ===


* [http://help.dyalog.com/latest/#Language/Primitive%20Functions/Power.htm Dyalog]
* [https://help.dyalog.com/latest/#Language/Primitive%20Functions/Power.htm Dyalog]
* [http://microapl.com/apl_help/ch_020_020_200.htm APLX]
* [http://microapl.com/apl_help/ch_020_020_200.htm APLX]
* J [https://www.jsoftware.com/help/dictionary/d200.htm Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/hat#dyadic NuVoc]
* J [https://www.jsoftware.com/help/dictionary/d200.htm Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/hat#dyadic NuVoc]
{{APL built-ins}}[[Category:Primitive functions]][[Category:Scalar dyadic functions]]
{{APL built-ins}}[[Category:Primitive functions]][[Category:Scalar dyadic functions]]

Navigation menu