- 87.3k
- 14
- 104
- 322
For exp
not 0, between -1 and 1 it will make a recursive call with a negated exponent.
Furthermore x2nx2n = (xnxn)2 which can be used to do notreduce n recursions but onlydown to 2loglog2(n) recursions.
For exp = n + q, n int, 0 < q < 1 or exp = n ± q, n int, 0 < q <= 0.5 you can use xexp = (xn).(xq). For the integer power n you can do the logarithmic recursion (double
, long
or BigInteger
). For the q fraction you need an approximation sequence. Don't ask me how.
Underscore at the beginning, is extra. Nowadays the majority seems to find this less readable (as not a ubiquitous convention), and disruptive in reading. Less is more here.
For exp
not 0, between -1 and 1 it will make a recursive call with a negated exponent.
Furthermore x2n = (xn)2 which can be used to do not n recursions but only 2log(n) recursions.
For exp = n + q, n int, 0 < q < 1 or exp = n ± q, n int, 0 < q <= 0.5 you can use xexp = (xn).(xq). For the integer power n you can do the logarithmic recursion (double
, long
or BigInteger
). For the q fraction you need an approximation sequence. Don't ask me how.
Underscore at the beginning, is extra. Nowadays the majority seems to find this less readable (as not a ubiquitous convention), and disruptive in reading. Less is more here.
For exp
not 0, between -1 and 1 it will make a recursive call with a negated exponent.
Furthermore x2n = (xn)2 which can be used to reduce n recursions down to log2(n) recursions.
For exp = n + q, n int, 0 < q < 1 or exp = n ± q, n int, 0 < q <= 0.5 you can use xexp = (xn).(xq). For the integer power n you can do the logarithmic recursion (double
, long
or BigInteger
). For the q fraction you need an approximation sequence. Don't ask me how.
Underscore at the beginning, is extra. Nowadays the majority seems to find this less readable (as not a ubiquitous convention), and disruptive in reading. Less is more here.
For exp
not 0, between -1 and 1 it will make a recursive call with a negated exponent.
Furthermore x2n = (xn)2 which can be used to do not n recursions but only 2log(n) recursions.
For exp = n + q, n int, 0 < q < 1 or exp = n ± q, n int, 0 < q <= 0.5 you can use xexp = (xn).(xq). For the integer power n you can do the logarithmic recursion (double
, long
or BigInteger
). For the q fraction you need an approximation sequence. Don't ask me how.
Underscore at the beginning, is extra. Nowadays the majority seems to find this less readable (as not a ubiquitous convention), and disruptive in reading. Less is more here.