Algorithm for regular continued fraction of a square root












0












$begingroup$


Say I have a number $n$, and want to find the expression of $sqrt{n}$ as a regular continued fraction. How would I do such a thing systematically?

A naive computer algorithm wouldn't work, due to floating point errors.










share|cite|improve this question









$endgroup$












  • $begingroup$
    The algorithm is described here : en.wikipedia.org/wiki/…
    $endgroup$
    – Peter
    Jan 24 at 18:33










  • $begingroup$
    It doesn't always produce a regular continued fraction. for example when $S=7$
    $endgroup$
    – J. Doe
    Jan 24 at 18:48






  • 1




    $begingroup$
    it gives $a=sqrt4=2$, $r=3$ (because $S=7=lfloorsqrt7rfloor^2+3=4+3$), and that means $sqrt7=2+frac3{4+frac3{4+frac3{4+frac3{...}}}}$, while the desired result is one in which the first element is $lfloorsqrt7rfloor=2$, and all the numerators are 1. And yes, $n$ is a positive integer.
    $endgroup$
    – J. Doe
    Jan 24 at 19:07








  • 1




    $begingroup$
    Maybe, you have chosen the wrong algorithm. I have not further checked the site, but I still think that the algorithm for a regular continued fraction should be present.
    $endgroup$
    – Peter
    Jan 24 at 19:09






  • 2




    $begingroup$
    See the algorithm for which Wikipedia uses $sqrt{114}$ as an example.
    $endgroup$
    – Misha Lavrov
    Jan 24 at 19:10
















0












$begingroup$


Say I have a number $n$, and want to find the expression of $sqrt{n}$ as a regular continued fraction. How would I do such a thing systematically?

A naive computer algorithm wouldn't work, due to floating point errors.










share|cite|improve this question









$endgroup$












  • $begingroup$
    The algorithm is described here : en.wikipedia.org/wiki/…
    $endgroup$
    – Peter
    Jan 24 at 18:33










  • $begingroup$
    It doesn't always produce a regular continued fraction. for example when $S=7$
    $endgroup$
    – J. Doe
    Jan 24 at 18:48






  • 1




    $begingroup$
    it gives $a=sqrt4=2$, $r=3$ (because $S=7=lfloorsqrt7rfloor^2+3=4+3$), and that means $sqrt7=2+frac3{4+frac3{4+frac3{4+frac3{...}}}}$, while the desired result is one in which the first element is $lfloorsqrt7rfloor=2$, and all the numerators are 1. And yes, $n$ is a positive integer.
    $endgroup$
    – J. Doe
    Jan 24 at 19:07








  • 1




    $begingroup$
    Maybe, you have chosen the wrong algorithm. I have not further checked the site, but I still think that the algorithm for a regular continued fraction should be present.
    $endgroup$
    – Peter
    Jan 24 at 19:09






  • 2




    $begingroup$
    See the algorithm for which Wikipedia uses $sqrt{114}$ as an example.
    $endgroup$
    – Misha Lavrov
    Jan 24 at 19:10














0












0








0





$begingroup$


Say I have a number $n$, and want to find the expression of $sqrt{n}$ as a regular continued fraction. How would I do such a thing systematically?

A naive computer algorithm wouldn't work, due to floating point errors.










share|cite|improve this question









$endgroup$




Say I have a number $n$, and want to find the expression of $sqrt{n}$ as a regular continued fraction. How would I do such a thing systematically?

A naive computer algorithm wouldn't work, due to floating point errors.







algorithms roots radicals continued-fractions






share|cite|improve this question













share|cite|improve this question











share|cite|improve this question




share|cite|improve this question










asked Jan 24 at 18:21









J. DoeJ. Doe

1




1












  • $begingroup$
    The algorithm is described here : en.wikipedia.org/wiki/…
    $endgroup$
    – Peter
    Jan 24 at 18:33










  • $begingroup$
    It doesn't always produce a regular continued fraction. for example when $S=7$
    $endgroup$
    – J. Doe
    Jan 24 at 18:48






  • 1




    $begingroup$
    it gives $a=sqrt4=2$, $r=3$ (because $S=7=lfloorsqrt7rfloor^2+3=4+3$), and that means $sqrt7=2+frac3{4+frac3{4+frac3{4+frac3{...}}}}$, while the desired result is one in which the first element is $lfloorsqrt7rfloor=2$, and all the numerators are 1. And yes, $n$ is a positive integer.
    $endgroup$
    – J. Doe
    Jan 24 at 19:07








  • 1




    $begingroup$
    Maybe, you have chosen the wrong algorithm. I have not further checked the site, but I still think that the algorithm for a regular continued fraction should be present.
    $endgroup$
    – Peter
    Jan 24 at 19:09






  • 2




    $begingroup$
    See the algorithm for which Wikipedia uses $sqrt{114}$ as an example.
    $endgroup$
    – Misha Lavrov
    Jan 24 at 19:10


















  • $begingroup$
    The algorithm is described here : en.wikipedia.org/wiki/…
    $endgroup$
    – Peter
    Jan 24 at 18:33










  • $begingroup$
    It doesn't always produce a regular continued fraction. for example when $S=7$
    $endgroup$
    – J. Doe
    Jan 24 at 18:48






  • 1




    $begingroup$
    it gives $a=sqrt4=2$, $r=3$ (because $S=7=lfloorsqrt7rfloor^2+3=4+3$), and that means $sqrt7=2+frac3{4+frac3{4+frac3{4+frac3{...}}}}$, while the desired result is one in which the first element is $lfloorsqrt7rfloor=2$, and all the numerators are 1. And yes, $n$ is a positive integer.
    $endgroup$
    – J. Doe
    Jan 24 at 19:07








  • 1




    $begingroup$
    Maybe, you have chosen the wrong algorithm. I have not further checked the site, but I still think that the algorithm for a regular continued fraction should be present.
    $endgroup$
    – Peter
    Jan 24 at 19:09






  • 2




    $begingroup$
    See the algorithm for which Wikipedia uses $sqrt{114}$ as an example.
    $endgroup$
    – Misha Lavrov
    Jan 24 at 19:10
















$begingroup$
The algorithm is described here : en.wikipedia.org/wiki/…
$endgroup$
– Peter
Jan 24 at 18:33




$begingroup$
The algorithm is described here : en.wikipedia.org/wiki/…
$endgroup$
– Peter
Jan 24 at 18:33












$begingroup$
It doesn't always produce a regular continued fraction. for example when $S=7$
$endgroup$
– J. Doe
Jan 24 at 18:48




$begingroup$
It doesn't always produce a regular continued fraction. for example when $S=7$
$endgroup$
– J. Doe
Jan 24 at 18:48




1




1




$begingroup$
it gives $a=sqrt4=2$, $r=3$ (because $S=7=lfloorsqrt7rfloor^2+3=4+3$), and that means $sqrt7=2+frac3{4+frac3{4+frac3{4+frac3{...}}}}$, while the desired result is one in which the first element is $lfloorsqrt7rfloor=2$, and all the numerators are 1. And yes, $n$ is a positive integer.
$endgroup$
– J. Doe
Jan 24 at 19:07






$begingroup$
it gives $a=sqrt4=2$, $r=3$ (because $S=7=lfloorsqrt7rfloor^2+3=4+3$), and that means $sqrt7=2+frac3{4+frac3{4+frac3{4+frac3{...}}}}$, while the desired result is one in which the first element is $lfloorsqrt7rfloor=2$, and all the numerators are 1. And yes, $n$ is a positive integer.
$endgroup$
– J. Doe
Jan 24 at 19:07






1




1




$begingroup$
Maybe, you have chosen the wrong algorithm. I have not further checked the site, but I still think that the algorithm for a regular continued fraction should be present.
$endgroup$
– Peter
Jan 24 at 19:09




$begingroup$
Maybe, you have chosen the wrong algorithm. I have not further checked the site, but I still think that the algorithm for a regular continued fraction should be present.
$endgroup$
– Peter
Jan 24 at 19:09




2




2




$begingroup$
See the algorithm for which Wikipedia uses $sqrt{114}$ as an example.
$endgroup$
– Misha Lavrov
Jan 24 at 19:10




$begingroup$
See the algorithm for which Wikipedia uses $sqrt{114}$ as an example.
$endgroup$
– Misha Lavrov
Jan 24 at 19:10










0






active

oldest

votes











Your Answer





StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3086209%2falgorithm-for-regular-continued-fraction-of-a-square-root%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Mathematics Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3086209%2falgorithm-for-regular-continued-fraction-of-a-square-root%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

Does disintegrating a polymorphed enemy still kill it after the 2018 errata?

A Topological Invariant for $pi_3(U(n))$