How can I perform arithmetic on numbers on the order of a googloplex i.e. 10^(10^100)?
I don’t have enough memory to express them exactly as integers with all their digits, but I’d like to be able to represent them as BigFloats. The largest I’ve been able to get is approximately 10^(10^18):
julia> m = exp(ULogarithmic, floatmax(BigFloat))
exp(5.875653789111587590936911998878442589938516392745498308333779606469323584389875e+1388255822130839282)
julia> log10(log10(m))
1.388255822130839282406840509258088745814167339601572288185265795534139656091031e+18
I think this should cover your case, but I get
julia> ten = ULogarithmic(big(10.0))
exp(2.302585092994045684017991454684364207601101488628772976033327900967572609677367)
julia> ten^(ten^100)
ERROR: StackOverflowError:
Stacktrace:
[1] promote_type(#unused#::Type{BigFloat}, #unused#::Type{Logarithmic{BigFloat}})
@ Base ./promotion.jl:298
[2] promote_result(#unused#::Type, #unused#::Type, #unused#::Type{BigFloat}, #unused#::Type{Logarithmic{BigFloat}})
@ Base ./promotion.jl:312
--- the last 2 lines are repeated 39990 more times ---
[79983] promote_type(#unused#::Type{BigFloat}, #unused#::Type{Logarithmic{BigFloat}})
@ Base ./promotion.jl:298
@cjdoris , do you have any ideas for addressing this?
But in this case, float(x) returns Inf. I think you’ll need a new loggamma method to do this. Maybe you can modify the SpecialFunctions implementation for this type?
I think I’d use an approximation, and just make sure the error is small enough for your purposes. A good starting point is Stirling’s approximation, and there are some alternatives in the links toward the bottom. It’s especially handy that the relative error decreases with the size of the argument, so you might end up needing only a couple of terms.
The issue is that loggamma is defined via ccalls rather than wholly in Julia. If it were Julia all the way down, I would expect ULogarithmic’s implementations of primitives would make it work without modification.
To quickly compute the limit as n goes to infinity of 2n*log(n) / log2(factorial(n)). I was able to compute the value to 64-bit floating point precision, pasted it into Google, and found this post which led me to conclude that the closed form answer is log(4). After getting this closed form, I continued on pencil and paper.
Beyond that already resolved use-case, this is a theoretical question.
I haven’t bought the Pro so I cannot see the full solution, but it seems apparent that the limit was found by manipulating the math expression, not by actually computing values for large n. The largest n represented by all the software bits in the world is nothing compared to infinity, who knows if the value converges or diverges past there.