Logarithm: Difference between revisions

Jump to navigation Jump to search
90 bytes added ,  22:05, 10 September 2022
m
Text replacement - "<source" to "<syntaxhighlight"
No edit summary
m (Text replacement - "<source" to "<syntaxhighlight")
Tags: Mobile edit Mobile web edit
Line 1: Line 1:
:''This page describes the dyadic arithmetic function. For the monadic natural logarithm function, see [[Natural Logarithm]].''
:''This page describes the dyadic arithmetic function. For the monadic natural logarithm function, see [[Natural Logarithm]].''


{{Built-in|Logarithm|⍟}}, or '''Log''', is a [[dyadic]] [[scalar function]] which computes the [[wikipedia:logarithm|logarithm]] of the two [[argument|arguments]]. More precisely, <source lang=apl inline>X⍟Y</source> computes how much [[power]] of X equals Y, i.e. the value of R that satisfies <source lang=apl inline>Y=X*R</source>. Logarithm shares the [[glyph]] <source lang=apl inline>⍟</source> with the monadic arithmetic function [[Natural Logarithm]]. The [[glyph]], a composition of the glyphs for [[Circular]] (<source lang=apl inline>○</source>) and [[Power]] (<source lang=apl inline>*</source>) to indicate its close mathematical ties with these two functions, is a stylised tree log.<ref>[[E. E. McDonnell|McDonnell, E. E.]]. [https://www.jsoftware.com/papers/eem/storyofo.htm Recreational APL: The Story of <source lang=apl inline>○</source>]. [[APL Quote-Quad]], Volume 8, Number 2, 1977-12.</ref>
{{Built-in|Logarithm|⍟}}, or '''Log''', is a [[dyadic]] [[scalar function]] which computes the [[wikipedia:logarithm|logarithm]] of the two [[argument|arguments]]. More precisely, <syntaxhighlight lang=apl inline>X⍟Y</source> computes how much [[power]] of X equals Y, i.e. the value of R that satisfies <syntaxhighlight lang=apl inline>Y=X*R</source>. Logarithm shares the [[glyph]] <syntaxhighlight lang=apl inline>⍟</source> with the monadic arithmetic function [[Natural Logarithm]]. The [[glyph]], a composition of the glyphs for [[Circular]] (<syntaxhighlight lang=apl inline>○</source>) and [[Power]] (<syntaxhighlight lang=apl inline>*</source>) to indicate its close mathematical ties with these two functions, is a stylised tree log.<ref>[[E. E. McDonnell|McDonnell, E. E.]]. [https://www.jsoftware.com/papers/eem/storyofo.htm Recreational APL: The Story of <syntaxhighlight lang=apl inline>○</source>]. [[APL Quote-Quad]], Volume 8, Number 2, 1977-12.</ref>


== Examples ==
== Examples ==


<source lang=apl>
<syntaxhighlight lang=apl>
       2⍟0.5 1 2 32 1024
       2⍟0.5 1 2 32 1024
¯1 0 1 5 10
¯1 0 1 5 10
Line 12: Line 12:
Logarithm can be used to determine how many digits are needed to write a positive integer Y in base X:
Logarithm can be used to determine how many digits are needed to write a positive integer Y in base X:


<source lang=apl>
<syntaxhighlight lang=apl>
       Digits←{1+⌊⍺⍟⍵}
       Digits←{1+⌊⍺⍟⍵}
       ToBase←⊥⍣¯1
       ToBase←⊥⍣¯1
Line 29: Line 29:
By definition, logarithm is the [[inverse]] of the [[power]] with the same base (left argument).
By definition, logarithm is the [[inverse]] of the [[power]] with the same base (left argument).


<source lang=apl>
<syntaxhighlight lang=apl>
       2*1 2 3 4 5
       2*1 2 3 4 5
2 4 8 16 32
2 4 8 16 32
Line 40: Line 40:
[[Reciprocal]] on the left or right argument gives the [[negate|negated]] result.
[[Reciprocal]] on the left or right argument gives the [[negate|negated]] result.


<source lang=apl>
<syntaxhighlight lang=apl>
       2⍟÷2 4 8 16 32
       2⍟÷2 4 8 16 32
¯1 ¯2 ¯3 ¯4 ¯5
¯1 ¯2 ¯3 ¯4 ¯5

Navigation menu