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


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

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

From "Andreas Leitgeb" <andreas.leitgeb@1:261/38.remove-x1c-this>
Subject Re: What is the command to do a power of a value
Message-ID <50182C7E.55829.calajapr@time.synchro.net> (permalink)
Newsgroups comp.lang.java.programmer
References <50182C7D.55824.calajapr@time.synchro.net>
Date 2012-07-31 20:07 +0000
Organization tds.net

Show all headers | View raw


  To: Roedy Green
From: "Andreas Leitgeb" <andreas.leitgeb@1:261/38.remove-dpk-this>

  To: Roedy Green
From: "Andreas Leitgeb" <andreas.leitgeb@1:261/38.remove-rf4-this>

  To: Roedy Green
From: Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at>

On Sun, 29 Jul 2012 21:28:11 -0700 (PDT), xvictoryeohx@gmail.com wrote:
> C=L(1+i/100)power of n

 x ^ n  =  exp ( log(x) * n )    |  x = (1 + i/100)
        = exp ( log( 1 + i/100 ) * n)
        = exp ( log1p ( i/100 ) * n)

If you're doing more calculations with same interest-rate but different 
periods, then you may want to calculate
  double logBase = Math.log1p( i / 100 );
once, and use that for the individual calculations:
  C = L * Math.exp( logBase * n )

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

-+- 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

--- 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 | 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-x1c-this> - 2012-07-31 20:06 +0000
  Re: What is the command to do a power of a value "bugbear" <bugbear@1:261/38.remove-x1c-this> - 2012-07-31 20:07 +0000
  Re: What is the command to do a power of a value "glen herrmannsfeldt" <glen.herrmannsfeldt@1:261/38.remove-x1c-this> - 2012-07-31 20:07 +0000
    Re: What is the command to do a power of a value "xvictoryeohx" <xvictoryeohx@1:261/38.remove-x1c-this> - 2012-07-31 20:07 +0000
  Re: What is the command to do a power of a value "Roedy Green" <roedy.green@1:261/38.remove-x1c-this> - 2012-07-31 20:07 +0000
    Re: What is the command to do a power of a value "Andreas Leitgeb" <andreas.leitgeb@1:261/38.remove-x1c-this> - 2012-07-31 20:07 +0000
      Re: What is the command to do a power of a value "Patricia Shanahan" <patricia.shanahan@1:261/38.remove-x1c-this> - 2012-07-31 20:07 +0000
        Re: What is the command to do a power of a value "Patricia Shanahan" <patricia.shanahan@1:261/38.remove-x1c-this> - 2012-07-31 20:07 +0000
        Re: What is the command to do a power of a value "glen herrmannsfeldt" <glen.herrmannsfeldt@1:261/38.remove-x1c-this> - 2012-07-31 20:07 +0000
          Re: What is the command to do a power of a value "Patricia Shanahan" <patricia.shanahan@1:261/38.remove-x1c-this> - 2012-07-31 20:07 +0000
          Re: What is the command to do a power of a value "Andreas Leitgeb" <andreas.leitgeb@1:261/38.remove-x1c-this> - 2012-07-31 20:07 +0000

csiph-web