Associated Topics || Dr. Math Home || Search Dr. Math

### Erlang B

```Date: 10/22/2002 at 14:11:22
From: Jamie  Bell
Subject: Logarithms

I need to know how to calculate the addition of numbers using
logarithms: 1 + 2 + 3

I have a formula in an Excel file that produces numbers large enough
to exceed Excel's calculation limits; e.g.: 200! and 10^1000.  I have
converted all of the factorial and expotential expressions to logs,
but there is a step that requires adding numbers that exceed Excel's
limits. How can I use logs to add the numbers?

The formula is Erlang B:

P = (A^N/N!) / Sum 0 through N of A^n/n!

Thanks.
```

```
Date: 11/14/2002 at 17:00:01
From: Doctor Peterson
Subject: Re: Logarithms

Hi, Jamie.

There are some useful things to say that have nothing to do with
logarithms.

Here is one page I found that will be useful to you:

A Robust and Efficient Algorithm for Evaluating Erlang's Formula -
Erlang B - Dave Albert, Jun Zhu

This gives a modified version of the formula that is easier to use.
I'll explain and derive it in what I think is a clearer form.

We can avoid calculating factorials when we are able to cancel, as is
usually done in calculating combinations. We can do that in this case
by distributing the numerator; that is, we can divide the numerator
and denominator by A^N/N!:

A^N/N!
P = --------------------
Sum[k=0 to N] A^k/k!

1
= ------------------------------
Sum[k=0 to N] (A^k/k!)(N!/A^N)

1
= ------------------------------------
Sum[k=0 to N] (N!/k!)/A^(N-k)

1
= ------------------
Sum[k=0 to N] a[k]

where

N!/k!
a[k] = -------, for k=0 to N
A^(N-k)

Look at the sequence a[k]:

N(N-1)...(3)(2)(1)
a[0] = ------------------
A^N

N(N-1)...(3)(2)
a[1] = ---------------
A^(N-1)

N(N-1)...(3)
a[2] = ------------
A^(N-2)
...
N
a[N-1] = ---
A^1

1
a[N] = ---
A^0

We can calculate the sequence a[k] recursively in reverse (starting
from a[N] and working back to a[0]), as

a[N] = 1
a[k-1] = a[k] * k/A  for k=N to 1

You will never get large numbers when you calculate this way, and
will have as much precision as you can get. You can do it in a simple
loop, adding in each a[k] as you calculate it, and then taking the
reciprocal of the result.

If you have any further questions, feel free to write back.

- Doctor Peterson, The Math Forum
http://mathforum.org/dr.math/
```
Associated Topics:
College Algorithms
High School Calculators, Computers
High School Logs

Search the Dr. Math Library:

 Find items containing (put spaces between keywords):   Click only once for faster results: [ Choose "whole words" when searching for a word like age.] all keywords, in any order at least one, that exact phrase parts of words whole words

Submit your own question to Dr. Math
Math Forum Home || Math Library || Quick Reference || Math Forum Search