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


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

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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.readnews.com!transit4.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!53ab2750!not-for-mail
From "Andreas Leitgeb" <andreas.leitgeb@1:261/38.remove-dpk-this>
Subject Re: What is the command to do a power of a value
Message-ID <50181D63.55750.calajapr@time.synchro.net> (permalink)
X-Comment-To Patricia Shanahan
Newsgroups comp.lang.java.programmer
In-Reply-To <5016CF47.55649.calajapr@time.synchro.net>
References <5016CF47.55649.calajapr@time.synchro.net>
X-FTN-AREA COMP.LANG.JAVA.PROGRAMMER
X-FTN-MSGID 1:261/38 a8c27516
X-FTN-REPLY 1:261/38 02f56482
Content-Type text/plain; charset=IBM437
Content-Transfer-Encoding 8bit
X-Gateway time.synchro.net [Synchronet 3.16a-Win32 NewsLink 1.98]
Lines 34
Date Tue, 31 Jul 2012 18:02:36 GMT
NNTP-Posting-Host 69.21.70.65
X-Complaints-To news@tds.net
X-Trace newsreading01.news.tds.net 1343757756 69.21.70.65 (Tue, 31 Jul 2012 13:02:36 CDT)
NNTP-Posting-Date Tue, 31 Jul 2012 13:02:36 CDT
Organization tds.net
Xref csiph.com comp.lang.java.programmer:16782

Show key headers only | View raw


  To: Patricia Shanahan
From: Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at>

Patricia Shanahan <pats@acm.org> wrote:
> On 7/30/2012 6:22 AM, Andreas Leitgeb wrote:
>> The gist of this response is, that for the kind of base (1+i/100),
>> you better separate the pow operation out into log and exp, and
>> actually use log1p on (i/100) instead of log on (1+i/100) for
>> efficiency's and precision's sake.
>> For "Math.log1p" see:
>> http://docs.oracle.com/javase/6/docs/api/java/lang/Math.html#log1p%28double%
29
>
> 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. ..."

Well, one ulp of i/100 is likely smaller than one ulp of 1+i/100 (at least it 
is for 0 <= i <= 100, the typical range for interest rates). It's like 
calculating sin(0.0) versus sin(Math.PI), where sin() makes the same promise 
wrt precision up to an ulp.

If the OP had been interested in the interest value alone, i.e. in
  I = L*( (1+i/100)^n ) - L
then using  log1p() and expm1() probably would beat the precision of pow() by, 
um, a few decimal digits, depending of course on the values of i and n.

Anyway, I think it's good to know that log1p() and expm1() exist, even if the 
example at hand doesn't now seem to cry out for them as loudly as I thought it 
did on first read.

--- BBBS/Li6 v4.10 Dada-1
 * Origin: Prism bbs (1:261/38)
--- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.programmer | Previous | NextPrevious 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