in reply to Add numbers in log domain [solved]

pRaNaV:

You'll likely have to clarify your question. As I read it, you're probably wanting to compute the logarithm of a sum using a base other than e. But since the documentation for the log function (which you can read via perldoc -f log) covers this, I'm hard pressed to imagine that's what you actually want. But if you did want that, then:

my ($x, $y, $base) = (23.5, 54.3, 2.0); my $result = log($x + $y) / log($base); print "result: $result\n";

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^2: Add numbers in log domain
by BrowserUk (Patriarch) on Jun 04, 2012 at 11:32 UTC

    My interpretation of the OP is: Given two (log) values X & Y where both are the logs to the same (unspecified) base: B; is it possible to derive Z, such that Z = logB( B^X + B^Y ); without going through the exponentiation step.

    Eg.

    X = logB( x ) = 2.51294159473206;

    Y = logB( y ) = 2.95544864408182;

    Z = logB( x + y ) = 3.51294159473206;

    Is it possible to derive Z without discovering x & y by 'antilogging' X & Y?


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

      Sorry, for not being clear. Yes, BrowserUK is right. I wan't to know how this (log(x + y)) can be done in perl without using exponentiation (base^x, base^y etc.).