we know that Pell equation is expressed as
which in case of D is not perfect square, can be approximated by continued fraction expansion of D, for instance let us consider such kind of equation
square root of 61 can be approximated by following matlab code
>> b=sqrt(61);
>> format rat
>> b
b =
1523/195
but i have question : how can i assign result in two separate variable ?namely
x=1523
y=195
from this site https://www.quora.com/What-is-the-fast-way-to-solve-the-fundamental-solution-of-Pell-equation
i understood that solution are based on numerator and denumerator, how can i assign fraction parts to x and y during the code in matlab? thanks in advance


While, by definition, an irrational number can never be exactly represented as a ratio of integers, it can approximately represented via such a ratio in finite precision arithmetic. This can be done through the
ratfunction to varying degrees of approximation:It is noted that the final
0does not indicate true equality of the terms; just equality to the limits of double precision arithmetic.