4,577
edits
(General editing) |
m (Text replacement - "</source>" to "</syntaxhighlight>") |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
:''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)]].'' | :''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]] that computes the [[wikipedia:exponentiation|exponentiation]] function of the two [[argument|arguments]], so that < | {{Built-in|Power|*}} is a [[dyadic]] [[scalar function]] that computes the [[wikipedia:exponentiation|exponentiation]] function of the two [[argument|arguments]], so that <syntaxhighlight lang=apl inline>X*Y</syntaxhighlight> is <syntaxhighlight lang=apl inline>X</syntaxhighlight> raised to the power <syntaxhighlight lang=apl inline>Y</syntaxhighlight>. Power shares the [[glyph]] <syntaxhighlight lang=apl inline>*</syntaxhighlight> with the monadic arithmetic function [[Exponential]]. | ||
== Examples == | == Examples == | ||
< | <syntaxhighlight lang=apl> | ||
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 | ||
</ | </syntaxhighlight> | ||
A common technique is to choose [[sign]] based on a [[Boolean]] array: | A common technique is to choose [[sign]] based on a [[Boolean]] array: | ||
< | <syntaxhighlight lang=apl> | ||
¯1*1 0 0 1 0 | ¯1*1 0 0 1 0 | ||
¯1 1 1 ¯1 1 | ¯1 1 1 ¯1 1 | ||
</ | </syntaxhighlight> | ||
== Properties == | == Properties == | ||
For positive integer < | For positive integer <syntaxhighlight lang=apl inline>Y</syntaxhighlight>, <syntaxhighlight lang=apl inline>X*Y</syntaxhighlight> equals the [[times|product]] of <syntaxhighlight lang=apl inline>Y</syntaxhighlight> copies of <syntaxhighlight lang=apl inline>X</syntaxhighlight>. When <syntaxhighlight lang=apl inline>Y</syntaxhighlight> is 0, <syntaxhighlight lang=apl inline>X*Y</syntaxhighlight> equals 1, possibly except when <syntaxhighlight lang=apl inline>X</syntaxhighlight> is also 0 (since [[wikipedia:zero to the power of zero|zero to the power of zero]] is undefined in mathematics). | ||
< | <syntaxhighlight lang=apl> | ||
3*5 | 3*5 | ||
243 | 243 | ||
Line 25: | Line 25: | ||
1 2 3*0 | 1 2 3*0 | ||
1 1 1 | 1 1 1 | ||
</ | </syntaxhighlight> | ||
[[negate|Negating]] the exponent (right argument) gives the [[reciprocal]] of the return value. | [[negate|Negating]] the exponent (right argument) gives the [[reciprocal]] of the return value. | ||
< | <syntaxhighlight lang=apl> | ||
(2*¯4)=÷2*4 | (2*¯4)=÷2*4 | ||
1 | 1 | ||
</ | </syntaxhighlight> | ||
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 < | 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 <syntaxhighlight lang=apl inline>÷2</syntaxhighlight> gives the [[square root]]. | ||
< | <syntaxhighlight lang=apl> | ||
3*2 | 3*2 | ||
9 | 9 | ||
9*÷2 | 9*÷2 | ||
3 | 3 | ||
</ | </syntaxhighlight> | ||
Power has two inverses, [[Root]] and [[Logarithm]]: | |||
<syntaxhighlight lang=apl> | |||
2*3 | |||
8 | |||
2⍟8 | |||
3 | |||
3√8 | |||
2 | |||
</syntaxhighlight> | |||
== External links == | == External links == | ||
Line 47: | Line 57: | ||
=== Documentation === | === Documentation === | ||
* [ | * [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] | ||
* [https://mlochbaum.github.io/BQN/doc/arithmetic.html#basic-arithmetic BQN] | |||
{{APL built-ins}}[[Category:Primitive functions]][[Category:Scalar dyadic functions]] | {{APL built-ins}}[[Category:Primitive functions]][[Category:Scalar dyadic functions]] |