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
    $\begingroup$ There's also the Computation Science StackExchange (scicomp.stackexchange.com) in Beta that can help with this sort of question (and needs some more love to stay alive!). Just sayin' :) $\endgroup$
    – Damien
    Aug 27 '12 at 11:04

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.


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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.