I need to find Dp
and Dq
from this formula:
I tried to use ContFrac
lib for this task:
pip install ContFrac
import contfrac
find_number = 2140e225
value = (1,math.sqrt(find_number))
conv = list(contfrac.convergents(value))
print(conv)
But the output is odd because number is too big:
0 + 1/(my_sqrt)
Method from SymPy also doesn't work and returns 0.
print(continued_fraction((1//sqrN)))
Update 1:
I was playing with SymPy and found that I should use this library sqrt
implementation.
from sympy import sqrt
lm = continued_fraction((1 / sqrt(number)))
lz = flatten(lm)
print(list(continued_fraction_convergents(lz)))
But these will cause internal exception:
PrecisionExhausted: Try simplifying the input, using chop=True, or providing a higher maxn for evalf
But as I see I can't raise man for continued_fraction
operation.
And I'm also unable to pass number as decimal:
decimal.getcontext().prec = 125
lm = continued_fraction((1 / sqrt(decimal.Decimal(find_number))))
ValueError: expecting a rational or quadratic irrational, not 2.16152455423408e-125