Power (function): Difference between revisions

From APL Wiki
Jump to navigation Jump to search
m (Text replacement - "http://help.dyalog.com" to "https://help.dyalog.com")
Line 60: Line 60:
* [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]]

Revision as of 02:13, 28 May 2022

This page describes the dyadic function. For the monadic function that uses as a base, see Exponential. For the iteration operator, see Power (operator).
*

Power (*) is a dyadic scalar function that computes the exponentiation function of the two arguments, so that X*Y is X raised to the power 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 a Boolean array:

      ¯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

Negating the exponent (right argument) gives the reciprocal of the return value.

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

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 ÷2 gives the square root.

      3*2
9
      9*÷2
3

Power has two inverses, Root and Logarithm:

      2*3
8
      2⍟8
3
      3√8
2

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