- This page describes the dyadic arithmetic function. For the monadic natural logarithm function, see Natural Logarithm.
Logarithm (⍟
), or Log, is a dyadic scalar function which computes the logarithm of the two arguments. More precisely, X⍟Y
computes how much power of X equals Y, i.e. the value of R that satisfies Y=X*R
. Logarithm shares the glyph ⍟
with the monadic arithmetic function Natural Logarithm. The glyph, a composition of the glyphs for Circular (○
) and Power (*
) to indicate its close mathematical ties with these two functions, is a stylised tree log.
Examples
2⍟0.5 1 2 32 1024
¯1 0 1 5 10
Logarithm can be used to determine how many digits are needed to write a positive integer Y in base X:
Digits←{1+⌊⍺⍟⍵}
ToBase←⊥⍣¯1
(2 Digits 100) (2 ToBase 100)
┌─┬─────────────┐
│7│1 1 0 0 1 0 0│
└─┴─────────────┘
(10 Digits 100) (10 ToBase 100)
┌─┬─────┐
│3│1 0 0│
└─┴─────┘
Properties
By definition, logarithm is the inverse of the power with the same base (left argument).
2*1 2 3 4 5
2 4 8 16 32
2⍟2 4 8 16 32
1 2 3 4 5
2 (*⍣¯1 ≡ ⍟) ⍳10
1
Reciprocal on the left or right argument gives the negated result.
2⍟÷2 4 8 16 32
¯1 ¯2 ¯3 ¯4 ¯5
(÷2)⍟2 4 8 16 32
¯1 ¯2 ¯3 ¯4 ¯5
See also
External links
Documentation
APL built-ins [edit]
|
Primitives (Timeline) |
Functions
|
Scalar
|
Monadic
|
Conjugate ∙ Negate ∙ Signum ∙ Reciprocal ∙ Magnitude ∙ Exponential ∙ Natural Logarithm ∙ Floor ∙ Ceiling ∙ Factorial ∙ Not ∙ Pi Times ∙ Roll ∙ Type ∙ Imaginary ∙ Square Root ∙ Round
|
Dyadic
|
Add ∙ Subtract ∙ Times ∙ Divide ∙ Residue ∙ Power ∙ Logarithm ∙ Minimum ∙ Maximum ∙ Binomial ∙ Comparison functions ∙ Boolean functions (And, Or, Nand, Nor) ∙ GCD ∙ LCM ∙ Circular ∙ Complex ∙ Root
|
Non-Scalar
|
Structural
|
Shape ∙ Reshape ∙ Tally ∙ Depth ∙ Ravel ∙ Enlist ∙ Table ∙ Catenate ∙ Reverse ∙ Rotate ∙ Transpose ∙ Raze ∙ Mix ∙ Split ∙ Enclose ∙ Nest ∙ Cut (K) ∙ Pair ∙ Link ∙ Partitioned Enclose ∙ Partition
|
Selection
|
First ∙ Pick ∙ Take ∙ Drop ∙ Unique ∙ Identity ∙ Stop ∙ Select ∙ Replicate ∙ Expand ∙ Set functions (Intersection ∙ Union ∙ Without) ∙ Bracket indexing ∙ Index ∙ Cartesian Product ∙ Sort
|
Selector
|
Index generator ∙ Grade ∙ Index Of ∙ Interval Index ∙ Indices ∙ Deal ∙ Prefix and suffix vectors
|
Computational
|
Match ∙ Not Match ∙ Membership ∙ Find ∙ Nub Sieve ∙ Encode ∙ Decode ∙ Matrix Inverse ∙ Matrix Divide ∙ Format ∙ Execute ∙ Materialise ∙ Range
|
Operators |
Monadic
|
Each ∙ Commute ∙ Constant ∙ Replicate ∙ Expand ∙ Reduce ∙ Windowed Reduce ∙ Scan ∙ Outer Product ∙ Key ∙ I-Beam ∙ Spawn ∙ Function axis ∙ Identity (Null, Ident)
|
Dyadic
|
Bind ∙ Compositions (Compose, Reverse Compose, Beside, Withe, Atop, Over) ∙ Inner Product ∙ Determinant ∙ Power ∙ At ∙ Under ∙ Rank ∙ Depth ∙ Variant ∙ Stencil ∙ Cut ∙ Direct definition (operator) ∙ Identity (Lev, Dex)
|
Quad names
|
Index origin ∙ Comparison tolerance ∙ Migration level ∙ Atomic vector
|