log to the base 2

25 views
Skip to first unread message

Michael Beeson

unread,
Jul 18, 2020, 2:45:06 PM7/18/20
to sage-support

sage: n(log(2,408/370))

7.08999206263157

sage: log(2,2)

1

sage: 2^7

128

sage: n(log(2,408.0/370))

7.08999206263157

sage: version()

'SageMath version 8.7, Release Date: 2019-03-23'

sage: n(log(2,1.001))

693.493696416899

sage:log(2,1)  gives an error instead of 0.


Michael Beeson

unread,
Jul 18, 2020, 2:49:59 PM7/18/20
to sage-support
And also

sage: log(2,x)

log(2)/log(x)


which goes a long ways to explain the previous results.  So log(2,x) is not actually log to the base 2 of x.

Reimundo Heluani

unread,
Jul 18, 2020, 3:18:15 PM7/18/20
to sage-s...@googlegroups.com
sage: log?
Signature: log(*args, **kwds)
Docstring:
Return the logarithm of the first argument to the base of the
second argument which if missing defaults to "e".

It calls the "log" method of the first argument when computing the
logarithm, thus allowing the use of logarithm on any object
containing a "log" method. In other words, "log" works on more than
just real numbers.

So it should be

sage:
sage: log(1,2)
0

Which works fine.


Also on my Sage 9.2.beta2

sage: log(2,1)
Infinity

Cheers,

R.

>
>--
>You received this message because you are subscribed to the Google Groups
>"sage-support" group.
>To unsubscribe from this group and stop receiving emails from it, send an email
>to [1]sage-support...@googlegroups.com.
>To view this discussion on the web visit [2]https://groups.google.com/d/msgid/
>sage-support/89cc7e10-6752-440e-9ed2-f4cf4b120089o%40googlegroups.com.
>
>References:
>
>[1] mailto:sage-support...@googlegroups.com
>[2] https://groups.google.com/d/msgid/sage-support/89cc7e10-6752-440e-9ed2-f4cf4b120089o%40googlegroups.com?utm_medium=email&utm_source=footer

signature.asc
Reply all
Reply to author
Forward
0 new messages