In R, I need to calculate sum((v/u) * (d^a))^(1/a) (see below) when d can be from 0 up to 10000 and a may be from 0 to 100. However, this overflows to Inf. v/u is dimensionless, as is a. I therefore assume that the result is on the same scale as d.
Is there a way to avoid the overflow in this calculation, either by some clever math, built-in functions, or by auto-scaling d, and then re-scaling the result without losing precision?
> N <- 200
> a <- 100
> v <- runif(N, min=1, max=20)
> u <- sum(v)
> d <- runif(N, min=1, max=8000)
> sum((v/u) * (d^a))^(1/a)
[1] Inf
