Results 1 to 8 of 8

Math Help - An approximation for log(a+b)

  1. #1
    Newbie
    Joined
    Feb 2011
    From
    York, UK
    Posts
    15

    An approximation for log(a+b)

    Hello,
    I have very big numbers that overflow as an integer value. Therefore, I keep the logarithms of those values. The problem is that: I need log(a+b) but I only know loga and logb. How can I approximate to find log(a+b)?
    Thanks.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor chisigma's Avatar
    Joined
    Mar 2009
    From
    near Piacenza (Italy)
    Posts
    2,162
    Thanks
    5
    If we suppose that a>b then...

    \displaystyle \ln (a+b)= \ln a + \ln (1+\frac{b}{a}) =  \ln a + \frac{b}{a} - \frac{b^{2}}{2\ a^{2}} + \frac{b^{3}}{3\ a^{3}} - ... (1)

    If a<b then swap a and b...

    Kind regards

    \chi \sigma
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by malaguena View Post
    Hello,
    I have very big numbers that overflow as an integer value. Therefore, I keep the logarithms of those values. The problem is that: I need log(a+b) but I only know loga and logb. How can I approximate to find log(a+b)?
    Thanks.
    More context please.

    But if a\ge b

    \ln(a+b)\approx\ln(a)+\left[ 0.985605 \left(\frac{b}{a}\right)+0.111097 \left(\frac{b}{a}\right)^2-0.403140\left(\frac{b}{a}\right)^3\right]

    and if b \ge a

    \ln(a+b)\approx\ln(b)+\left[ 0.985605 \left(\frac{a}{b}\right)+0.111097 \left(\frac{a}{b}\right)^2-0.403140\left(\frac{a}{b}\right)^3\right]

    With absolute error <0.0007 over the appropriate interval for each of the approximations

    CB
    Last edited by CaptainBlack; February 8th 2011 at 05:26 AM.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Newbie
    Joined
    Feb 2011
    From
    York, UK
    Posts
    15
    More specifically problem is exactly like this: I need to calculate this: dk=alpha*gamma(nk)+dleftk*drightk
    alpha is a small double value here.
    gamma(nk)=(n-1)! (overflows for big integers - where nk is an integer value)
    dleftk and drightk are calculated recursively according to the same equation. Therefore, I have log(gamma(nk)) and log(dleftk*drightk) and I need to calculate dk.

    dk is calculated for a tree, and here dleftk and drightk represent the children of the node dk.

    I thought keeping the logarithms will be easier, but any other solution will be appreciated as well.
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie
    Joined
    Feb 2011
    From
    York, UK
    Posts
    15
    Quote Originally Posted by CaptainBlack View Post
    More context please.

    CB
    More specifically problem is exactly like this: I need to calculate this: dk=alpha*gamma(nk)+dleftk*drightk
    alpha is a small double value here.
    gamma(nk)=(n-1)! (overflows for big integers - where nk is an integer value)
    dleftk and drightk are calculated recursively according to the same equation. Therefore, I have log(alpha*gamma(nk)) and log(dleftk*drightk) and I need to calculate dk.

    dk is calculated for a tree, and here dleftk and drightk represent the children of the node dk.

    I thought keeping the logarithms will be easier, but any other solution will be appreciated as well.
    Last edited by malaguena; February 8th 2011 at 05:06 AM.
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Newbie
    Joined
    Feb 2011
    From
    York, UK
    Posts
    15
    Quote Originally Posted by chisigma View Post
    If we suppose that a>b then...

    \displaystyle \ln (a+b)= \ln a + \ln (1+\frac{b}{a}) =  \ln a + \frac{b}{a} - \frac{b^{2}}{2\ a^{2}} + \frac{b^{3}}{3\ a^{3}} - ... (1)

    If a<b then swap a and b...

    Kind regards

    \chi \sigma

    But is not that the case, when a is much bigger than b, and vice versa?
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Newbie
    Joined
    Feb 2011
    From
    York, UK
    Posts
    15
    Quote Originally Posted by CaptainBlack View Post
    More context please.

    But if a\ge b

    \ln(a+b)\approx\ln(a)+\left[ 0.985605 \left(\frac{b}{a}\right)+0.111097 \left(\frac{b}{a}\right)^2-0.403140\left(\frac{b}{a}\right)^3\right]

    and if b \ge a

    \ln(a+b)\approx\ln(b)+\left[ 0.985605 \left(\frac{a}{b}\right)+0.111097 \left(\frac{a}{b}\right)^2-0.403140\left(\frac{a}{b}\right)^3\right]

    With absolute error <0.0007 over the appropriate interval for each of the approximations

    CB
    Great! Thanks very much for the solution. I really appreciated it.
    Follow Math Help Forum on Facebook and Google+

  8. #8
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by CaptainBlack View Post
    More context please.

    But if a\ge b

    \ln(a+b)\approx\ln(a)+\left[ 0.985605 \left(\frac{b}{a}\right)+0.111097 \left(\frac{b}{a}\right)^2-0.403140\left(\frac{b}{a}\right)^3\right]

    and if b \ge a

    \ln(a+b)\approx\ln(b)+\left[ 0.985605 \left(\frac{a}{b}\right)+0.111097 \left(\frac{a}{b}\right)^2-0.403140\left(\frac{a}{b}\right)^3\right]

    With absolute error <0.0007 over the appropriate interval for each of the approximations

    CB
    If we are less fussy and an absolute error <0.005 is acceptabe a second degree fit will do:

    if a\ge b

    \ln(a+b)\approx\ln(a)+\left[ 0.937234 \left(\frac{b}{a}\right)-0.248540 \left( \frac{b}{a} \right)^2\right]

    and if b \ge a

    \ln(a+b)\approx\ln(b)+\left[ 0.937234 \left(\frac{a}{b}\right)-0.248540\left( \frac{a}{b}\right)^2\right]
    Last edited by CaptainBlack; February 8th 2011 at 06:18 AM.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Approximation
    Posted in the Calculus Forum
    Replies: 6
    Last Post: August 30th 2011, 05:08 AM
  2. Approximation
    Posted in the Calculus Forum
    Replies: 1
    Last Post: August 25th 2011, 04:31 AM
  3. Approximation
    Posted in the Calculus Forum
    Replies: 2
    Last Post: May 21st 2010, 02:09 PM
  4. approximation
    Posted in the Algebra Forum
    Replies: 2
    Last Post: September 5th 2009, 04:46 AM
  5. Approximation
    Posted in the Pre-Calculus Forum
    Replies: 3
    Last Post: June 26th 2009, 08:17 AM

Search Tags


/mathhelpforum @mathhelpforum