Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Is this a bug in the log function?

While doing an experiment I had an anomalous result and traced it to the following unexpected output of log(x, 2). Can anybody explain what is going on here?

┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 10.7, Release Date: 2025-08-09                    │
│ Using Python 3.12.5. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: x = int(21743271936)
sage: factor(x)
2^28 * 3^4
sage: log(x, 2).n()
28.0000000000000
sage: log(x-1, 2).n()
34.3398500028183
sage: log(x+1, 2).n()
34.3398500029510

Is this a bug in the log function?

While doing an experiment I had an anomalous result and traced it to the following unexpected output of log(x, 2). Can anybody explain what is going on here?

┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 10.7, Release Date: 2025-08-09                    │
│ Using Python 3.12.5. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: x = int(21743271936)
sage: factor(x)
2^28 * 3^4
sage: log(x, 2).n()
28.0000000000000
sage: log(x-1, 2).n()
34.3398500028183
sage: log(x+1, 2).n()
34.3398500029510