Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #16685

Re: What is the command to do a power of a value

From glen herrmannsfeldt <gah@ugcs.caltech.edu>
Newsgroups comp.lang.java.programmer
Subject Re: What is the command to do a power of a value
Date 2012-07-30 22:26 +0000
Organization Aioe.org NNTP Server
Message-ID <jv71m7$o8m$1@speranza.aioe.org> (permalink)
References <5016CF47.55648.calajapr@time.synchro.net> <5016CF47.55649.calajapr@time.synchro.net>

Show all headers | View raw


Patricia Shanahan <patricia.shanahan@1:261/38.remove-rf4-this> wrote:

(snip, someone wrote)
>>   x ^ n  =  exp ( log(x) * n )    |  x = (1 + i/100)
>>          = exp ( log( 1 + i/100 ) * n)
>>          = exp ( log1p ( i/100 ) * n)

(snip)

> I am curious about why you expect this to be more precise than: 
> "The computed result must be within 1 ulp of the exact result. 
> Results must be semi-monotonic." (From the pow description). 
> Or do you know of cases where Math.pow gets an over-large 
> rounding error?

I didn't know about the log1p function. (Does Java have one?)

As x gets small log(1+x) loses precision. Consider:

      log(1+1e-60)

The x87 instruction set has an instruction for evaluating log(1+x)
and one for evaluating exp(x-1). Most HLLs don't.

-- glen

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

What is the command to do a power of a value "xvictoryeohx" <xvictoryeohx@1:261/38.remove-rf4-this> - 2012-07-30 19:00 +0000
  Re: What is the command to do a power of a value "bugbear" <bugbear@1:261/38.remove-rf4-this> - 2012-07-30 19:00 +0000
  Re: What is the command to do a power of a value "glen herrmannsfeldt" <glen.herrmannsfeldt@1:261/38.remove-rf4-this> - 2012-07-30 19:00 +0000
    Re: What is the command to do a power of a value "xvictoryeohx" <xvictoryeohx@1:261/38.remove-rf4-this> - 2012-07-30 19:00 +0000
  Re: What is the command to do a power of a value "Roedy Green" <roedy.green@1:261/38.remove-rf4-this> - 2012-07-30 19:00 +0000
    Re: What is the command to do a power of a value "Andreas Leitgeb" <andreas.leitgeb@1:261/38.remove-rf4-this> - 2012-07-30 19:00 +0000
      Re: What is the command to do a power of a value "Patricia Shanahan" <patricia.shanahan@1:261/38.remove-rf4-this> - 2012-07-30 19:00 +0000
        Re: What is the command to do a power of a value Patricia Shanahan <pats@acm.org> - 2012-07-30 13:15 -0700
        Re: What is the command to do a power of a value glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-07-30 22:26 +0000
          Re: What is the command to do a power of a value Patricia Shanahan <pats@acm.org> - 2012-07-30 16:01 -0700
          Re: What is the command to do a power of a value Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2012-07-30 23:11 +0000
        Re: What is the command to do a power of a value "Andreas Leitgeb" <andreas.leitgeb@1:261/38.remove-dpk-this> - 2012-07-31 18:02 +0000

csiph-web