ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 01 Mar 2018 21:38:58 +0100Behavior of numerical_approx functionhttps://ask.sagemath.org/question/41343/behavior-of-numerical_approx-function/What I noticed is that the `log` function does not give a numerical approximation by default, and one has to use the `numerical_approx` (`n`) function for this purpose. Though, I found its behavior a bit interesting, or not what I expected. I have a Sage code that looks like this:
p = 2**372 * 3**239 - 1
log(p, 2).numerical_approx() # 750.806037672356
log(p, 2).numerical_approx(digits = 4) # 750.8
log(p, 2).numerical_approx(digits = 7) # 750.8060
So, by default `numerical_approx` gives 12 digits after the decimal point, but I found that it optionally takes an argument called `digits`. The confusing part for me is that I thought that `digits` specifies how many digits to be displayed after the decimal point, but this clearly is not the case, as you can see from the examples above. It actually specifies how many digits in total (sum of digits before and after the decimal point) it should print. So, how can I get numerical approximation of logarithms with 4 digits after the decimal point (no matter how many digits there are before the decimal point)?ninhoThu, 01 Mar 2018 21:38:58 +0100https://ask.sagemath.org/question/41343/