Power (function): Difference between revisions

From APL Wiki
Jump to navigation Jump to search
(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...")
 
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 [[Boolean]]s:
<source lang=apl>
      ¯1*1 0 0 1 0
¯1 1 1 ¯1 1
</source>
</source>



Revision as of 05:23, 2 June 2020

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).
*

Power (*) is a dyadic scalar function which computes the exponentiation function of the two arguments. More precisely, X*Y computes X raised to the power of Y. Power shares the glyph * with the monadic arithmetic function Exponential.

Examples

      2*¯1 0 1 2 3 4 5
0.5 1 2 4 8 16 32

A common technique is to choose sign based on Booleans:

      ¯1*1 0 0 1 0
¯1 1 1 ¯1 1

Properties

For positive integer Y, X*Y equals the product of Y copies of X. When Y is 0, X*Y equals 1, possibly except when X is also 0 (since zero to the power of zero is undefined in mathematics).

      3*5
243 
      ×/5⍴3
243
      1 2 3*0
1 1 1

Negation on the power results in the reciprocal on the return value.

      (2*¯4)=÷2*4
1

Reciprocal on the power results in the n-th root on the return value. This can be used to calculate the square root.

      3*2
9
      9*÷2
3

External links

Documentation

APL built-ins [edit]
Primitives (Timeline) Functions
Scalar
Monadic ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare Root
Dyadic AddSubtractTimesDivideResiduePowerLogarithmMinimumMaximumBinomialComparison functionsBoolean functions (And, Or, Nand, Nor) ∙ GCDLCMCircularComplexRoot
Non-Scalar
Structural ShapeReshapeTallyDepthRavelEnlistTableCatenateReverseRotateTransposeRazeMixSplitEncloseNestCut (K)PairLinkPartitioned EnclosePartition
Selection FirstPickTakeDropUniqueIdentityStopSelectReplicateExpandSet functions (IntersectionUnionWithout) ∙ Bracket indexingIndexCartesian ProductSort
Selector Index generatorGradeIndex OfInterval IndexIndicesDealPrefix and suffix vectors
Computational MatchNot MatchMembershipFindNub SieveEncodeDecodeMatrix InverseMatrix DivideFormatExecuteMaterialiseRange
Operators Monadic EachCommuteConstantReplicateExpandReduceWindowed ReduceScanOuter ProductKeyI-BeamSpawnFunction axis
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Withe, Atop, Over) ∙ Inner ProductDeterminantPowerAtUnderRankDepthVariantStencilCutDirect definition (operator)
Quad names Index originComparison toleranceMigration levelAtomic vector