Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.readnews.com!transit3.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!53ab2750!not-for-mail From: "glen herrmannsfeldt" Subject: Re: What is the command to do a power of a value Message-ID: <50182C80.55838.calajapr@time.synchro.net> X-Comment-To: Patricia Shanahan Newsgroups: comp.lang.java.programmer In-Reply-To: <50182C7E.55831.calajapr@time.synchro.net> References: <50182C7E.55831.calajapr@time.synchro.net> X-FTN-AREA: COMP.LANG.JAVA.PROGRAMMER X-FTN-MSGID: 1:261/38 659b3193 X-FTN-REPLY: 1:261/38 0da09dbf Content-Type: text/plain; charset=IBM437 Content-Transfer-Encoding: 8bit X-Gateway: time.synchro.net [Synchronet 3.16a-Win32 NewsLink 1.98] Lines: 41 Date: Tue, 31 Jul 2012 20:07:04 GMT NNTP-Posting-Host: 69.21.70.65 X-Complaints-To: news@tds.net X-Trace: newsreading01.news.tds.net 1343765224 69.21.70.65 (Tue, 31 Jul 2012 15:07:04 CDT) NNTP-Posting-Date: Tue, 31 Jul 2012 15:07:04 CDT Organization: tds.net Xref: csiph.com comp.lang.java.programmer:16868 To: Patricia Shanahan From: "glen herrmannsfeldt" To: Patricia Shanahan From: glen herrmannsfeldt Patricia Shanahan 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 -+- 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 --- 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