ilog - Maple Help

ilog2

compute integer base 2 logarithm

ilog10

compute integer base 10 logarithm

ilog[b]

compute integer base b logarithm

ilog

compute integer natural logarithm

Calling Sequence

 ilog2(x) ilog10(x) ilog[b](x) ${\mathrm{ilog}}_{b}\left(x\right)$ ilog(x)

Parameters

 x - expression b - positive real number

Description

 • These functions compute integer approximations to logarithms. They are based on the IEEE function logb.
 • For real values $x$ and positive numeric values $b$, the function ${\mathrm{ilog}}_{b}\left(x\right)$ computes the integer base $b$ logarithm of $|x|$; that is, the logarithm rounded down to the nearest integer.
 If $b>1$, then ${\mathrm{ilog}}_{b}\left(x\right)$ returns $r$ such that ${b}^{r}\le \left|x\right|<{b}^{r+1}$.
 If $b<1$, then ${\mathrm{ilog}}_{b}\left(x\right)$ returns $r$ such that ${b}^{r+1}<\left|x\right|\le {b}^{r}$.
 • For complex values $x$, ${\mathrm{ilog}}_{b}\left(x\right)$ computes $\mathrm{max}\left({\mathrm{ilog}}_{b}\left(\mathrm{\Re }\left(x\right)\right),{\mathrm{ilog}}_{b}\left(\mathrm{\Im }\left(x\right)\right)\right)$.
 • The following relations hold for infinite and undefined values:
 If $b>1$, then ${\mathrm{ilog}}_{b}\left(±\mathrm{\infty }\right)=\phantom{\rule[-0.0ex]{0.5ex}{0.0ex}}\mathrm{\infty }$ and ${\mathrm{ilog}}_{b}\left(0\right)=-\mathrm{\infty }$.
 If $b<1$, then ${\mathrm{ilog}}_{b}\left(±\mathrm{\infty }\right)=-\mathrm{\infty }$ and ${\mathrm{ilog}}_{b}\left(0\right)=\mathrm{\infty }$.
 For all $b$, we have ${\mathrm{ilog}}_{b}\left(\mathrm{undefined}\right)=\mathrm{undefined}$.
 • You can enter the command ilog[b] using either the 1-D or 2-D calling sequence. For example, ilog[3](50) is equivalent to ${\mathrm{ilog}}_{3}\left(50\right)$.
 • The $\mathrm{ilog2}\left(x\right)$ and $\mathrm{ilog10}\left(x\right)$ functions compute the same values as ${\mathrm{ilog}}_{2}\left(x\right)$ and ${\mathrm{ilog}}_{10}\left(x\right)$, respectively. They both have more efficient implementations than the default algorithm for ${\mathrm{ilog}}_{b}\left(x\right)$ for $b\ne 2,b\ne 10$. (Indeed, ${\mathrm{ilog}}_{2}\left(x\right)$ and ${\mathrm{ilog}}_{10}\left(x\right)$ are generally computed using the $\mathrm{ilog2}$ and $\mathrm{ilog10}$ commands.)
 There are sometimes situations where you need a rough approximation of the size of the number, where $\mathrm{ilog}$ to any base will do. Then using $\mathrm{ilog2}$ is probably the best choice. (It is even faster than $\mathrm{ilog10}$ for some cases.)
 • The $\mathrm{ilog}\left(x\right)$ function computes ${\mathrm{ilog}}_{ⅇ}\left(x\right)$, approximating the natural logarithm of $x$.
 • The computation of $\mathrm{ilog2}\left(x\right)$ and $\mathrm{ilog10}\left(x\right)$ is more efficient than ${\mathrm{ilog}}_{b}\left(x\right)$ for $b\ne 2,10$.

 • The ilog2 and ilog10 commands are thread-safe as of Maple 15.

Examples

 > $\mathrm{ilog10}\left(x\right)$
 ${\mathrm{ilog10}}{}\left({x}\right)$ (1)
 > $\mathrm{ilog10}\left(150\right)$
 ${2}$ (2)
 > $\mathrm{ilog10}\left({10}^{-37}\right)$
 ${-37}$ (3)
 > $\mathrm{ilog10}\left({2}^{14}+{3}^{10}I\right)$
 ${4}$ (4)
 > $\mathrm{ilog2}\left(50\right)$
 ${5}$ (5)
 > $\mathrm{ilog}\left[2\right]\left({2}^{8}\right)$
 ${8}$ (6)
 > $\mathrm{ilog}\left[3\right]\left(10\right)$
 ${2}$ (7)
 > $\mathrm{ilog}\left(3\right)$
 ${1}$ (8)

The powers of $\mathrm{\phi }=\frac{1}{2}+\frac{1}{2}\sqrt{5}$ are very close to the Lucas numbers. In particular, ${\mathrm{\phi }}^{2000}$ is a tiny bit less than the 2000th Lucas number, and ${\mathrm{\phi }}^{2001}$ is a tiny bit more than the 2001st Lucas number. Consequently, the base-$\mathrm{\phi }$ logarithm of both the 2000th and 2001st Lucas number are strictly between 2000 and 2001 - so the answers from $\mathrm{ilog}$ should be 2000 in both cases.

 > $\mathrm{\phi }≔\frac{1}{2}+\frac{1}{2}\mathrm{sqrt}\left(5\right)$
 ${\mathrm{\phi }}{≔}\frac{{1}}{{2}}{+}\frac{\sqrt{{5}}}{{2}}$ (9)
 > $\mathrm{Lucas}≔n↦2\cdot \mathrm{combinat}:-\mathrm{fibonacci}\left(n+1\right)-\mathrm{combinat}:-\mathrm{fibonacci}\left(n\right)$
 ${\mathrm{Lucas}}{≔}{n}{↦}{2}{\cdot }{\mathrm{combinat}}{:-}{\mathrm{fibonacci}}{}\left({n}{+}{1}\right){-}{\mathrm{combinat}}{:-}{\mathrm{fibonacci}}{}\left({n}\right)$ (10)
 > $\mathrm{l2000}≔\mathrm{Lucas}\left(2000\right)$
 ${\mathrm{l2000}}{≔}{9446708185759308415384067495999677431530963218480368032804826598281856324445977322684945038267086094364761366000137291348836189673785457326607903364013465483957273836804336595888397782139002535468799414419546535346394066447256463745311310661259359973909189379826722425332112242554370313063917929424669185186291673823764654829513873821477637371237697744102254002802127905427315493403711022179894479121632130910668828127}$ (11)
 > $\mathrm{evalf}\left[900\right]\left({\mathrm{\phi }}^{2000}\right)$
 ${9.44670818575930841538406749599967743153096321848036803280482659828185632444597732268494503826708609436476136600013729134883618967378545732660790336401346548395727383680433659588839778213900253546879941441954653534639406644725646374531131066125935997390918937982672242533211224255437031306391792942466918518629167382376465482951387382147763737123769774410225400280212790542731549340371102217989447912163213091066882812699999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999989414301994556404261178907219383372907698634419491617032649619167}{×}{{10}}^{{417}}$ (12)
 > $\mathrm{ilog}\left[\mathrm{\phi }\right]\left(\mathrm{Lucas}\left(2000\right)\right)$
 ${2000}$ (13)
 > $\mathrm{l2001}≔\mathrm{Lucas}\left(2001\right)$
 ${\mathrm{l2001}}{≔}{15285094926360416404458847753853545672215113709866886761428113642426699623148315429402781518231396824903495901847342654693518581616001718736483909963503576057612526424919647262732272622204263764540041695502230453879379513883382816164600806848158718731671394389559139884843246782770607873339169023848390330701515748112231115788664367129870458859443365121656070623201452984720321258087284805794773049623826845661626456876}$ (14)
 > $\mathrm{evalf}\left[900\right]\left({\mathrm{\phi }}^{2001}\right)$
 ${1.52850949263604164044588477538535456722151137098668867614281136424266996231483154294027815182313968249034959018473426546935185816160017187364839099635035760576125264249196472627322726222042637645400416955022304538793795138833828161646008068481587187316713943895591398848432467827706078733391690238483903307015157481122311157886643671298704588594433651216560706232014529847203212580872848057947730496238268456616264568760000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000654232116200611158245512923334354892212558579525250227369596382}{×}{{10}}^{{418}}$ (15)
 > $\mathrm{ilog}\left[\mathrm{\phi }\right]\left(\mathrm{Lucas}\left(2001\right)\right)$
 ${2000}$ (16)