[R] Exponentiate very large numbers

Rolf Turner rolf.turner at xtra.co.nz
Tue Feb 5 21:41:50 CET 2013


Presumably you wish to *calculate*

     exp(1347) - exp(eps + 1351) where eps = ln(0.1)

(rather than *solve* anything).

This is equal to

     exp(1347)*(1 - exp(eps + 4)) = - exp(1347 + log(exp(eps+4) - 1)
     = -exp(1347 + 1.495107) = - exp(1348.495107)

This is, to all intents and purposes, minus infinity.

     cheers,

         Rolf Turner
On 02/05/2013 04:59 AM, francesca casalino wrote:
> I am sorry I have confused you, the logs are all base e:
>
> ln(a) = 1347
> ln(b) = 1351
>
> And I am trying to solve this expression:
>
> exp( ln(a) ) - exp( ln(0.1) + ln(b) )
>
>
> Thank you.
>
> 2013/2/4 francesca casalino <francy.casalino at gmail.com>:
>> Dear R experts,
>>
>> I have the logarithms of 2 values:
>>
>> log(a) = 1347
>> log(b) = 1351
>>
>> And I am trying to solve this expression:
>>
>> exp( ln(a) ) - exp( ln(0.1) + ln(b) )
>>
>> But of course every time I try to exponentiate the log(a) or log(b)
>> values I get Inf. Are there any tricks I can use to get a real result
>> for exp( ln(a) ) - exp( ln(0.1) + ln(b) ), either in logarithm or
>> exponential form?
>>
>>
>> Thank you very much for the help
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list