Skip to main content
rewording first sentence
Source Link
Jack Poulson
  • 7.7k
  • 33
  • 41

This should be prettyThere is a straightforward solution with only two passes through the data:

First compute $$K := \max_i\; a_i,$$

which tells you that, if there are $n$ terms, then $$\sum_i e^{a_i} \le n e^K.$$

Since you presumably don't have $n$ anywhere near as large as even $10^{20}$, you should have no worry about overflowing in the computation of $$\tau := \sum_i e^{a_i-K} \le n$$ in double precision.

Thus, compute $\tau$ and then your solution is $e^K \tau$.

This should be pretty straightforward with only two passes through the data:

First compute $$K := \max_i\; a_i,$$

which tells you that, if there are $n$ terms, then $$\sum_i e^{a_i} \le n e^K.$$

Since you presumably don't have $n$ anywhere near as large as even $10^{20}$, you should have no worry about overflowing in the computation of $$\tau := \sum_i e^{a_i-K} \le n$$ in double precision.

Thus, compute $\tau$ and then your solution is $e^K \tau$.

There is a straightforward solution with only two passes through the data:

First compute $$K := \max_i\; a_i,$$

which tells you that, if there are $n$ terms, then $$\sum_i e^{a_i} \le n e^K.$$

Since you presumably don't have $n$ anywhere near as large as even $10^{20}$, you should have no worry about overflowing in the computation of $$\tau := \sum_i e^{a_i-K} \le n$$ in double precision.

Thus, compute $\tau$ and then your solution is $e^K \tau$.

Replaced Jack's "a" with "K" for consistency with cboettig's notation.
Source Link
Geoff Oxberry
  • 30.4k
  • 9
  • 65
  • 130

This should be pretty straightforward with only two passes through the data:

First compute $$a := \max_i\; a_i,$$$$K := \max_i\; a_i,$$

which tells you that, if there are $n$ terms, then $$\sum_i e^{a_i} \le n e^a.$$$$\sum_i e^{a_i} \le n e^K.$$

Since you presumably don't have $n$ anywhere near as large as even $10^{20}$, you should have no worry about overflowing in the computation of $$\tau := \sum_i e^{a_i-a} \le n$$$$\tau := \sum_i e^{a_i-K} \le n$$ in double precision.

Thus, compute $\tau$ and then your solution is $e^a \tau$$e^K \tau$.

This should be pretty straightforward with only two passes through the data:

First compute $$a := \max_i\; a_i,$$

which tells you that, if there are $n$ terms, then $$\sum_i e^{a_i} \le n e^a.$$

Since you presumably don't have $n$ anywhere near as large as even $10^{20}$, you should have no worry about overflowing in the computation of $$\tau := \sum_i e^{a_i-a} \le n$$ in double precision.

Thus, compute $\tau$ and then your solution is $e^a \tau$.

This should be pretty straightforward with only two passes through the data:

First compute $$K := \max_i\; a_i,$$

which tells you that, if there are $n$ terms, then $$\sum_i e^{a_i} \le n e^K.$$

Since you presumably don't have $n$ anywhere near as large as even $10^{20}$, you should have no worry about overflowing in the computation of $$\tau := \sum_i e^{a_i-K} \le n$$ in double precision.

Thus, compute $\tau$ and then your solution is $e^K \tau$.

added 23 characters in body
Source Link
Jack Poulson
  • 7.7k
  • 33
  • 41

This should be pretty straightforward with only two passes through the data:

First compute $$a := \max_i\; a_i$$$$a := \max_i\; a_i,$$

Ifwhich tells you that, if there are $n$ terms, then $$\sum_i e^{a_i} \le n e^a.$$

Since you presumably don't have $n$ anywhere near as large as even $10^{20}$, you should have no worry about overflowing in the computation of $$\tau := \sum_i e^{a_i-a} \le n$$ in double precision.

Thus, compute $\tau$ and then your solution is $e^a \tau$.

This should be pretty straightforward with only two passes through the data:

First compute $$a := \max_i\; a_i$$

If there are $n$ terms, then $$\sum_i e^{a_i} \le n e^a.$$

Since you presumably don't have $n$ anywhere near as large as even $10^{20}$, you should have no worry about overflowing in the computation of $$\tau := \sum_i e^{a_i-a} \le n$$ in double precision.

Thus, compute $\tau$ and then your solution is $e^a \tau$.

This should be pretty straightforward with only two passes through the data:

First compute $$a := \max_i\; a_i,$$

which tells you that, if there are $n$ terms, then $$\sum_i e^{a_i} \le n e^a.$$

Since you presumably don't have $n$ anywhere near as large as even $10^{20}$, you should have no worry about overflowing in the computation of $$\tau := \sum_i e^{a_i-a} \le n$$ in double precision.

Thus, compute $\tau$ and then your solution is $e^a \tau$.

Source Link
Jack Poulson
  • 7.7k
  • 33
  • 41
Loading