Post Reply 
Continuous fractions in CAS
09-23-2020, 10:05 PM
Post: #5
RE: Continuous fractions in CAS
(09-23-2020 02:04 PM)Albert Chan Wrote:  sqrt(n) has repeating CF coefs is because radical can be flipped to the bottom:

√n = p + (√(n) - p) = p + q / (√(n) + p) = p + 1 / ((√(n) + p)/q)

where p = floor(√n), q = n - p²

If q = 0, n is perfect square, and we are done.
If q = 1, FP((√(n) + p)/q) = FP(√n), thus will repeat itself. (here, FP(x) meant x - floor(x))

Thank you for this detailed explanation, really enjoying it.

Example:

(09-23-2020 02:04 PM)Albert Chan Wrote:  XCas> dfc(sqrt(7),5)       → [2,1,1,1,4, (sqrt(7)+2)/3] ≡ [2, [1,1,1,4]]

Prime’s CAS gives:

dfc(sqrt(7),5) -> [2,1,1,1,4,1.54858377036]
No inner brackets.

(09-23-2020 02:04 PM)Albert Chan Wrote:  >>> list(CFsqrt(7))         # \(\sqrt{7} = [2; \overline{1, 1, 1, 4}]\)
[2, 1, 1, 1, 4]

This gave me the idea of inserting a list in the array, and I thought it was a success:
[1,2,{2}] Enter gives:
[1 2 [2]] in the history (hooray!)
[1 2 table()] in the result field
And it is unusable.

If someone has another clue, in addition to road’s one, I’ll take it.

Thibault - not collector but in love with the few HP models I own - Also musician : http://walruspark.co
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Continuous fractions in CAS - pinkman - 09-23-2020, 11:22 AM
RE: Continuous fractions in CAS - pinkman - 09-23-2020, 09:28 PM
RE: Continuous fractions in CAS - pinkman - 09-23-2020 10:05 PM
RE: Continuous fractions in CAS - Joe Horn - 09-24-2020, 01:12 AM
RE: Continuous fractions in CAS - pinkman - 09-24-2020, 07:14 AM
RE: Continuous fractions in CAS - Han - 03-05-2021, 01:38 AM



User(s) browsing this thread: 1 Guest(s)