java - Find power of real number -


I am trying to find x ^ y where x Is positive and y is a real number. Many sources are online for integer but not much for actual numbers.

Example:

  6 ^ 4.3 = 2218.4537377949778046576946747662  

I do not have to use any Math library. I know that it works:

  exp (y * log (x))  

But I get an exposure without any library Will happen. Is there a series that I can use to get real number power? I am doing it in Java.

To make a good agreement between the efficiency and ease of implementation, you can develop

"Fastest "The part is the logarithmic.

Before the power of x to find the power of 2 , assume that the x = (2 ^ n) .x ', 1 & lt; = 'X' & lt; 2 . Then ln (x) = nal (2) + ln (x ') .

  6 = (2 ^ 2) x 1.5  

evaluation from series ln (x ') = 2 argth ((x'-1 ) / (X '+ 1))

  LN (1.5) = 2 (0.2 + 0.2 ^ 3/3 + 0.2 ^ 5/5 ...) = 0.4 0.405333333333 0.4054649490476 0.405465107978 0.4054651087878 0.405465108108 ... LN (6) = 2 x 0.69314718056 + 0.405465108108 = 1.791759469228  

then y.ln (x) , divided into integer part (Use exponentation by squirting) and partial part

  4.3 x 1.791759469228 = 7.704565717681 e ^ 7 = 1096.633158428  

For partial use, use standard teller development.

  e ^ 0.704565717681 = 0.704565717681 + 0.704565717681 ^ 3/6 ... 1 1.70246571768 1.012647714295 2.01106472233 2.02133246059 2.02277931986 2.0229492211 2.02296632204 2.02296782814 2.02296794604 2.02296795435 2.02296795488 2.02296795491 ...  

and multiply

  6 ^ 4.3 = 1096.633158428 x 2.02296795491 = 2218.45373779  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

How to access user directory in lazarus? -

java - Gradle dependencies: compile project by relative path -