# Revision history [back]

### Behavior of numerical_approx function in Sage?

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?

### Behavior of numerical_approx function in Sage?

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?point (no matter how many digits there are before the decimal point)?

### Behavior of numerical_approx function in Sage?

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)?

### Behavior of numerical_approx function in Sage?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)?