library(caracas)
<- as_sym("2")
n_2 <- as_sym("pi", declare_symbols = FALSE) # pi is a constant in SymPy
n_pi <- sqrt(n_2) * n_pi
x
x#> [caracas]: √2⋅π
N(x)
#> [caracas]: 4.44288293815837
N(x, 5)
#> [caracas]: 4.4429
N(x, 50)
#> [caracas]: 4.4428829381583662470158809900606936986146216893757
as.character(N(x, 50))
#> [1] "4.4428829381583662470158809900606936986146216893757"
As SymPy
requires mpmath
this can be used directly, for example like this (example due to Hans W Borchers, thanks!):
<- reticulate::import('mpmath')
mpmath $mp$dps <- 30
mpmath<- mpmath$mpc(real = '1.0', imag = '63.453')
z <- mpmath$zeta(z)
zeta_z
zeta_z#> (2.3454640626800434588582100226 - 0.641476965582898402371607967236j)
as.character(zeta_z$real)
#> [1] "2.3454640626800434588582100226"
as.character(zeta_z$imag)
#> [1] "-0.641476965582898402371607967236"