3
$\begingroup$

We have a problem to find $x$ such that $ \sum_{i}\left(\frac{a_i}{x}\right)^\lambda= \sum_{j}\left(\frac{b_j}{x}\right)^{-\lambda} $

$a_i < x < b_j$

$a_i \approx x \approx b_j$

We get analytic solution: $ x = \left[\frac{\sum_{i}a_i^\lambda}{\sum_{j}b_j^{-\lambda}}\right]^{\frac{1}{2\lambda}} $

But since $a_i,b_j,x,\lambda \approx 10^3$ we cannot evaluate this formula because of numerical overflow ($a_i ^ \lambda \approx 1000^{1000}$)

Please advise. Thanks.

  • 1
    There's also the Computation Science StackExchan$g$e (http://scicomp.stackexchange.com/) in Beta that can help with this sort of question (and needs some more love to stay alive!). Just sayin' :)2012-08-27

2 Answers 2

5

The expression for $x$ is invariant under change of scale: a'_i= s a_i, b'_j= s b_j. So, use $s=10^{-3}$ and get those numbers close to 1. This probably helps.

4

This is similar to what lhf said, but it might help. Set $A=\max_i a_i$ and $B=\max_i b_i$, then $ x=\sqrt{\frac{A}{B}}\left[\frac{\sum_i\left(\frac{a_i}{A}\right)^\lambda}{\sum_i\left(\frac{b_i}{B}\right)^\lambda}\right]^\frac{1}{2\lambda} $ I think that this should get you decent stability and keep the computation from overflowing.