First time here? Check out the FAQ!

Ask Your Question
1

log base 10

asked 13 years ago

Jason gravatar image

Is there a built-in way to use a log with base other than e? The log documentation doesn't show any example (I thought log(10,x) was what I wanted for a while but it's actually different than what one might expect).

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
4

answered 13 years ago

kcrisman gravatar image

This is in log?:

   EXAMPLES:

      sage: log(e^2)
      2
      sage: log(1024, 2); RDF(log(1024, 2))
      10
      10.0

So log(x,10) should be what you're looking for...

Preview: (hide)
link

Comments

Thanks, I wasn't aware that log_b(x) was equivalent to log(x)/log(b). Might be good to add that to the docs. (I got hung up because I saw log(10)/log(2) in the log? documentation and assumed it meant that log(x,y) was something that didn't help me, because it didn't say "To use the log in base b, do this")

Jason gravatar imageJason ( 13 years ago )

Well, the very first line of `log?` is "Return the logarithm of x to the given base." See http://www.sagemath.org/doc/reference/sage/functions/log.html#sage.functions.log.log. But if you think we should be a little more explicit, let us know and we could open a ticket...

kcrisman gravatar imagekcrisman ( 13 years ago )

If you could make this change it would be great: "EXAMPLES: sage: log(e^2)" : To something like: EXAMPLES: To change the base of the logarithm, add a second parameter. sage: log(1000,10): 3 Small change but helpful!

Jason gravatar imageJason ( 13 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 13 years ago

Seen: 13,389 times

Last updated: Dec 01 '11