I would like to calculate (1.0-p)^n
where p is a double between 0 and 1 (often very close to 0) and n is a positive integer that might be on the order of hundreds or thousands (perhaps larger; I'm not sure yet). If possible I would love to just use Java's built in java.lang.Math.pow(1.0-p, n)
for this, but I'm slightly concerned that there might be a gigantic loss of accuracy/precision in doing so with the range of values that I'm interested in. Does anybody have a rough idea of what kind of error I might expect using Java's implementation? I'm not sure what goes on under the hood in their implementation (logs and/or Taylor approximations?), so I can't hazard a good guess.
I'm mostly concerned about relative error (i.e. not being off by more than an order of magnitude). If the answer turns out to be that Java's implementation will produce too much error, do you have any good library recommendations (but again, I'm hoping this shouldn't be needed)? Thanks.