Csound Csound-dev Csound-tekno Search About

[Csnd] logarithms

Date2010-07-23 10:35
FromStefan Thomas
Subject[Csnd] logarithms
Dear community,
is it possible to calculate logarhiithms, that are not based on 2?

Date2010-07-23 11:03
FromAnja Hofmann
Subject[Csnd] Re: logarithms
Hi!
# Dear community,
# is it possible to calculate logarhiithms, that are not based on 2?
Yes .. using the opcodes log10 or log (based on e).
The code in the examples subdirectory of the csound manual worked fine for me with Csound 5.12 under linux (Ubuntu).
Best wishes,
Anja Hofmann
Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"


Date2010-07-23 16:05
FromStefan Thomas
Subject[Csnd] Re: Re: logarithms
And if I want to have an logarithm based on 2.25, e.g.?

2010/7/23 Anja Hofmann <anja.r.hofmann@web.de>
Hi!
# Dear community,
# is it possible to calculate logarhiithms, that are not based on 2?
Yes .. using the opcodes log10 or log (based on e).
The code in the examples subdirectory of the csound manual worked fine for me with Csound 5.12 under linux (Ubuntu).
Best wishes,
Anja Hofmann
Send bugs reports to the Sourceforge bug tracker
           https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"



Date2010-07-23 16:14
Fromjoachim heintz
Subject[Csnd] Re: Re: Re: logarithms
the formula is:
the logarithm of a number N to a base B is:
either log(N) / log(B)
or log10(N) / log10 (B)

	joachim


Am 23.07.2010 um 17:05 schrieb Stefan Thomas:

> And if I want to have an logarithm based on 2.25, e.g.?
>
> 2010/7/23 Anja Hofmann 
> Hi!
> # Dear community,
> # is it possible to calculate logarhiithms, that are not based on 2?
> Yes .. using the opcodes log10 or log (based on e).
> The code in the examples subdirectory of the csound manual worked  
> fine for me with Csound 5.12 under linux (Ubuntu).
> Best wishes,
> Anja Hofmann
> Send bugs reports to the Sourceforge bug tracker
>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
> "unsubscribe csound"
>
>



Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"

Date2010-07-23 16:18
FromAaron Krister Johnson
Subject[Csnd] Re: Re: Re: logarithms
Hi Stefan,

In order to calculate a logarithm of a number x in any arbitrary base n, use the following relationship:

log_n(x) = log_10(x)/log10(n)

Here the "_n" means "base n" so  "_10" means base 10, which along with base e is standard on most calculators or programming languages.

Python has a log function where you can specify an arbitrary base as an extra argument, eg
log(4.523,2) would give the log of 4.523 in base 2. The formula above is being used behind the scenes.

Hope this helps.

AKJ


On Fri, Jul 23, 2010 at 10:05 AM, Stefan Thomas <kontrapunktstefan@googlemail.com> wrote:
And if I want to have an logarithm based on 2.25, e.g.?

2010/7/23 Anja Hofmann <anja.r.hofmann@web.de>

Hi!
# Dear community,
# is it possible to calculate logarhiithms, that are not based on 2?
Yes .. using the opcodes log10 or log (based on e).
The code in the examples subdirectory of the csound manual worked fine for me with Csound 5.12 under linux (Ubuntu).
Best wishes,
Anja Hofmann
Send bugs reports to the Sourceforge bug tracker
           https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"





--
Best,

Aaron Krister Johnson
http://www.akjmusic.com
http://www.untwelve.org


Date2010-07-23 16:31
FromAaron Krister Johnson
Subject[Csnd] Re: Re: Re: Re: logarithms
Joachim beat me to it by a couple of minutes! :)

Anyway, I want to clarify something: My equation was inconsistent in the use of the underscore, it should correctly read:

log_n(x) = log_10(x)/log_10(n)

I use an underscore here b/c it's hard to write subscript notation in plain text. Subscripts are often used to indicate base in logarithmic equations. However, we could even simplify matter further and just write caps or something for plain text purposes, and since the relation holds for all arbitrary available bases on whatever calculating device you have, we could write:

logB(x) = log(x)/log(B)

....as Joachim suggests. His choice of 'B' as a variable for the base is better than my earlier choice 'n', so if that helps, go with that!

BTW, 'log' on a calculator can be either base 'e' or base 10...it works either way for the above arbitrary base relationship. Some calculators have both bases available, but it doesn't matter as long as you use the same base throughout the equation's right hand side.

On a side note, I remember being surprised to find the shell math language 'BC' on Linux used base 'e', and log10 wasn't available...you had to 'roll your own'!!!! I think many common LISP implementations are similar...

On Fri, Jul 23, 2010 at 10:14 AM, joachim heintz <jh@joachimheintz.de> wrote:
the formula is:
the logarithm of a number N to a base B is:
either log(N) / log(B)
or log10(N) / log10 (B)

       joachim


Am 23.07.2010 um 17:05 schrieb Stefan Thomas:


And if I want to have an logarithm based on 2.25, e.g.?

2010/7/23 Anja Hofmann <anja.r.hofmann@web.de>
Hi!
# Dear community,
# is it possible to calculate logarhiithms, that are not based on 2?
Yes .. using the opcodes log10 or log (based on e).
The code in the examples subdirectory of the csound manual worked fine for me with Csound 5.12 under linux (Ubuntu).
Best wishes,
Anja Hofmann
Send bugs reports to the Sourceforge bug tracker
          https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"





Send bugs reports to the Sourceforge bug tracker
          https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"




--
Best,

Aaron Krister Johnson
http://www.akjmusic.com
http://www.untwelve.org