Symmetric continued fractions property where $q^2equiv(-1)^n$ mod $p$












3














Let $[a_0,a_1,a_2,ldots,a_n,a_n,ldots,a_2,a_1,a_0]=:frac{p}{q}inmathbb{Q}$ be a symmetric continued fraction. This sequence of $a_i$'s consists of finitely many elements because $frac{p}{q}$ is rational. I need to prove that $q^2equiv(-1)^r$ mod $p$ with $r$ the length of the sequence of $a_i$'s.



I'm getting pretty stuck from the beginning. There's a big chance I have to use the property $p_{n-1}q_n-p_nq_{n-1}=(-1)^n$. I guess saying that $frac{p_n}{q_n}=frac{p_n}{p_{n-1}}$ would really come in hand for this would prove the statement immedeately, but I don't see/know how to prove this last equality. Any help is appreciated.



Note: the $p_i$'s and $q_i$'s are from the continued fractions of $p$ and $q$ respectively.



Try: By a lemma from my book we can use the following algorithm:
$$begin{bmatrix}
p_i&p_{i-1}\
q_i&q_{i-1}
end{bmatrix}
=
begin{bmatrix}
p_{i-1}&p_{i-2}\
q_{i-1}&q_{i-2}
end{bmatrix}
begin{bmatrix}
a_i&1\
1&0
end{bmatrix}, text{where }begin{bmatrix}
p_{-1}&p_{-2}\
q_{-1}&q_{-2}
end{bmatrix}=I_2 text{and } igeqslant0.$$



So we have the following using symmetry of the continued fractions:
$$begin{align*}q_0&=1,\ q_1&=a_1,\
&vdots\q_{n-1}&=a_{1}q_{n-2}+q_{n-3} (a_1=a_{n-1}),\ q_n&=a_0q_{n-1}+q_{n-2}.end{align*}$$

We also have:
$$begin{align*}
p_0&=a_0,\ p_1&=a_1p_0+1,\
&vdots\p_{n-1}&=a_{1}p_{n-2}+p_{n-3} (a_1=a_{n-1}),\ p_n&=a_0p_{n-1}+p_{n-2}.
end{align*}$$

Somehow it should now turn out to be true that $q_n=p_{n-1}$. How to continue from here on? Please verify my answer below if you are able to.










share|cite|improve this question





























    3














    Let $[a_0,a_1,a_2,ldots,a_n,a_n,ldots,a_2,a_1,a_0]=:frac{p}{q}inmathbb{Q}$ be a symmetric continued fraction. This sequence of $a_i$'s consists of finitely many elements because $frac{p}{q}$ is rational. I need to prove that $q^2equiv(-1)^r$ mod $p$ with $r$ the length of the sequence of $a_i$'s.



    I'm getting pretty stuck from the beginning. There's a big chance I have to use the property $p_{n-1}q_n-p_nq_{n-1}=(-1)^n$. I guess saying that $frac{p_n}{q_n}=frac{p_n}{p_{n-1}}$ would really come in hand for this would prove the statement immedeately, but I don't see/know how to prove this last equality. Any help is appreciated.



    Note: the $p_i$'s and $q_i$'s are from the continued fractions of $p$ and $q$ respectively.



    Try: By a lemma from my book we can use the following algorithm:
    $$begin{bmatrix}
    p_i&p_{i-1}\
    q_i&q_{i-1}
    end{bmatrix}
    =
    begin{bmatrix}
    p_{i-1}&p_{i-2}\
    q_{i-1}&q_{i-2}
    end{bmatrix}
    begin{bmatrix}
    a_i&1\
    1&0
    end{bmatrix}, text{where }begin{bmatrix}
    p_{-1}&p_{-2}\
    q_{-1}&q_{-2}
    end{bmatrix}=I_2 text{and } igeqslant0.$$



    So we have the following using symmetry of the continued fractions:
    $$begin{align*}q_0&=1,\ q_1&=a_1,\
    &vdots\q_{n-1}&=a_{1}q_{n-2}+q_{n-3} (a_1=a_{n-1}),\ q_n&=a_0q_{n-1}+q_{n-2}.end{align*}$$

    We also have:
    $$begin{align*}
    p_0&=a_0,\ p_1&=a_1p_0+1,\
    &vdots\p_{n-1}&=a_{1}p_{n-2}+p_{n-3} (a_1=a_{n-1}),\ p_n&=a_0p_{n-1}+p_{n-2}.
    end{align*}$$

    Somehow it should now turn out to be true that $q_n=p_{n-1}$. How to continue from here on? Please verify my answer below if you are able to.










    share|cite|improve this question



























      3












      3








      3







      Let $[a_0,a_1,a_2,ldots,a_n,a_n,ldots,a_2,a_1,a_0]=:frac{p}{q}inmathbb{Q}$ be a symmetric continued fraction. This sequence of $a_i$'s consists of finitely many elements because $frac{p}{q}$ is rational. I need to prove that $q^2equiv(-1)^r$ mod $p$ with $r$ the length of the sequence of $a_i$'s.



      I'm getting pretty stuck from the beginning. There's a big chance I have to use the property $p_{n-1}q_n-p_nq_{n-1}=(-1)^n$. I guess saying that $frac{p_n}{q_n}=frac{p_n}{p_{n-1}}$ would really come in hand for this would prove the statement immedeately, but I don't see/know how to prove this last equality. Any help is appreciated.



      Note: the $p_i$'s and $q_i$'s are from the continued fractions of $p$ and $q$ respectively.



      Try: By a lemma from my book we can use the following algorithm:
      $$begin{bmatrix}
      p_i&p_{i-1}\
      q_i&q_{i-1}
      end{bmatrix}
      =
      begin{bmatrix}
      p_{i-1}&p_{i-2}\
      q_{i-1}&q_{i-2}
      end{bmatrix}
      begin{bmatrix}
      a_i&1\
      1&0
      end{bmatrix}, text{where }begin{bmatrix}
      p_{-1}&p_{-2}\
      q_{-1}&q_{-2}
      end{bmatrix}=I_2 text{and } igeqslant0.$$



      So we have the following using symmetry of the continued fractions:
      $$begin{align*}q_0&=1,\ q_1&=a_1,\
      &vdots\q_{n-1}&=a_{1}q_{n-2}+q_{n-3} (a_1=a_{n-1}),\ q_n&=a_0q_{n-1}+q_{n-2}.end{align*}$$

      We also have:
      $$begin{align*}
      p_0&=a_0,\ p_1&=a_1p_0+1,\
      &vdots\p_{n-1}&=a_{1}p_{n-2}+p_{n-3} (a_1=a_{n-1}),\ p_n&=a_0p_{n-1}+p_{n-2}.
      end{align*}$$

      Somehow it should now turn out to be true that $q_n=p_{n-1}$. How to continue from here on? Please verify my answer below if you are able to.










      share|cite|improve this question















      Let $[a_0,a_1,a_2,ldots,a_n,a_n,ldots,a_2,a_1,a_0]=:frac{p}{q}inmathbb{Q}$ be a symmetric continued fraction. This sequence of $a_i$'s consists of finitely many elements because $frac{p}{q}$ is rational. I need to prove that $q^2equiv(-1)^r$ mod $p$ with $r$ the length of the sequence of $a_i$'s.



      I'm getting pretty stuck from the beginning. There's a big chance I have to use the property $p_{n-1}q_n-p_nq_{n-1}=(-1)^n$. I guess saying that $frac{p_n}{q_n}=frac{p_n}{p_{n-1}}$ would really come in hand for this would prove the statement immedeately, but I don't see/know how to prove this last equality. Any help is appreciated.



      Note: the $p_i$'s and $q_i$'s are from the continued fractions of $p$ and $q$ respectively.



      Try: By a lemma from my book we can use the following algorithm:
      $$begin{bmatrix}
      p_i&p_{i-1}\
      q_i&q_{i-1}
      end{bmatrix}
      =
      begin{bmatrix}
      p_{i-1}&p_{i-2}\
      q_{i-1}&q_{i-2}
      end{bmatrix}
      begin{bmatrix}
      a_i&1\
      1&0
      end{bmatrix}, text{where }begin{bmatrix}
      p_{-1}&p_{-2}\
      q_{-1}&q_{-2}
      end{bmatrix}=I_2 text{and } igeqslant0.$$



      So we have the following using symmetry of the continued fractions:
      $$begin{align*}q_0&=1,\ q_1&=a_1,\
      &vdots\q_{n-1}&=a_{1}q_{n-2}+q_{n-3} (a_1=a_{n-1}),\ q_n&=a_0q_{n-1}+q_{n-2}.end{align*}$$

      We also have:
      $$begin{align*}
      p_0&=a_0,\ p_1&=a_1p_0+1,\
      &vdots\p_{n-1}&=a_{1}p_{n-2}+p_{n-3} (a_1=a_{n-1}),\ p_n&=a_0p_{n-1}+p_{n-2}.
      end{align*}$$

      Somehow it should now turn out to be true that $q_n=p_{n-1}$. How to continue from here on? Please verify my answer below if you are able to.







      number-theory modular-arithmetic recurrence-relations continued-fractions






      share|cite|improve this question















      share|cite|improve this question













      share|cite|improve this question




      share|cite|improve this question








      edited Dec 11 at 13:58

























      asked Dec 8 at 17:37









      Guus Palmer

      620319




      620319






















          2 Answers
          2






          active

          oldest

          votes


















          1














          I guess I figured it out now. We can make a straight forward argument as follows:



          $$begin{align*}frac{p_n}{p_{n-1}} =
          frac{a_n*p_{n-1}}{p_{n-1}} +
          frac{p_{n-2}}{p_{n-1}} =
          a_n +
          frac{p_{n-2}}{p_{n-1}} =
          a_n + frac{1}{frac{p_{n-1}}{p_{n-2}}}.
          end{align*}$$



          Then $frac{p_{n-1}}{p_{n-2}}=a_{n-1}+frac{1}{frac{p_{n-2}}{p_{n-3}}}$ and so on.



          Continue doing this for arbitrary $n$ and get:



          $$frac{p_n}{p_{n-1}} =a_n + frac{1}{a_{n-1} + frac{1}{a_{n-2} + frac{1}{frac{p_{n-3}}{ddots}}}} = [a_{n},a_{n-1},a_{n-2},ldots,a_{0}].$$ Now $p_{n-1}q_{n}-p_nq_{n-1}=q_{n}^2-p_nq_{n-1}=(-1)^n$ by $frac{p_n}{q_n}=frac{p_n}{p_{n-1}}$ from what I stated earlier. Hence, $q^2equiv(-1)^n$ mod $p$. $Box$.






          share|cite|improve this answer































            1














            I think a bit more detail about the recursion is useful.





            As noted in the answer by Guus Palmer,
            $$
            begin{align}
            frac{p_n}{p_{n-1}}
            &=left(a_n;frac{p_{n-1}}{p_{n-2}}right)\
            &=left(a_n;a_{n-1},frac{p_{n-2}}{p_{n-3}}right)\
            &=left(a_n;a_{n-1},a_{n-2},dots,a_1,color{#C00}{frac{p_0}{p_{-1}}}right)\[6pt]
            &=left(a_n;a_{n-1},a_{n-2},dots,a_1,color{#C00}{a_0}right)tag1
            end{align}
            $$

            $$ %begin{align} frac{p_n}{p_{n-1}} &=a_n+cfrac1{frac{p_{n-1}}{p_{n-2}}}\ &=a_n+cfrac1{a_{n-1}+cfrac1{frac{p_{n-2}}{p_{n-3}}}}\ &,,vdots\ &=a_n+cfrac1{a_{n-1}+cfrac1{a_{n-2}+cfrac1{begin{matrix}ddots&lower{18pt}{a_1+cfrac1{color{#C00}{frac{p_0}{p_{-1}}}}}end{matrix}}}}\ &=a_n+cfrac1{a_{n-1}+cfrac1{a_{n-2}+cfrac1{begin{matrix}ddots&lower{18pt}{a_1+cfrac1{color{#C00}{a_0}}}end{matrix}}}}\ end{align} $$



            Since $p_{-2}=0$ and $p_{-1}=1$ in the standard recursion.





            However, note that the sequence of denominators also follows the same initial recursion:
            $$
            begin{align}
            frac{q_n}{q_{n-1}}
            &=left(a_n;frac{q_{n-1}}{q_{n-2}}right)\
            &=left(a_n;a_{n-1},frac{q_{n-2}}{q_{n-3}}right)\
            &=left(a_n;a_{n-1},a_{n-2},dots,a_2,color{#C00}{frac{q_1}{q_0}}right)\[6pt]
            &=left(a_n;a_{n-1},a_{n-2},dots,a_2,color{#C00}{a_1}right)tag2
            end{align}
            $$

            $$ %begin{align} frac{q_n}{q_{n-1}} &=a_n+cfrac1{frac{q_{n-1}}{q_{n-2}}}\ &=a_n+cfrac1{a_{n-1}+cfrac1{frac{q_{n-2}}{q_{n-3}}}}\ &,,vdots\ &=a_n+cfrac1{a_{n-1}+cfrac1{a_{n-2}+cfrac1{begin{matrix}ddots&lower{18pt}{a_2+cfrac1{color{#C00}{frac{q_1}{q_0}}}}end{matrix}}}}\ &=a_n+cfrac1{a_{n-1}+cfrac1{a_{n-2}+cfrac1{begin{matrix}ddots&lower{18pt}{a_2+cfrac1{color{#C00}{a_1}}}end{matrix}}}}\ end{align} $$



            Since $q_{-2}=1$ and $q_{-1}=0$ in the standard recursion, we cannot extend the continued fraction to include $frac{q_0}{q_{-1}}$ as we did with $frac{p_n}{p_{n-1}}$.





            So we need to be careful about considering the beginning of the continued fraction without being careful of the ending terms. Although the later terms are less significant, in this case, they are important.





            The rest of the answer is fine. For sequential approximants of any continued fraction, we have
            $$
            p_{k-1}q_k-p_kq_{k-1}=(-1)^ktag3
            $$

            Since
            $$
            frac{p_n}{q_n}=(a_0;a_1,a_2,dots,a_{n-1},a_n)tag4
            $$

            is a palindromic continued fraction, we have from $(1)$ and $(4)$
            $$
            frac{p_n}{q_n}=frac{p_n}{p_{n-1}}tag5
            $$

            and applying $(5)$ to $(3)$, with $k=n$, we get
            $$
            q_n^2-p_nq_{n-1}=(-1)^ntag6
            $$

            That is,
            $$
            q_n^2equiv(-1)^npmod{p_n}tag7
            $$






            share|cite|improve this answer





















              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%2f3031393%2fsymmetric-continued-fractions-property-where-q2-equiv-1n-mod-p%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














              I guess I figured it out now. We can make a straight forward argument as follows:



              $$begin{align*}frac{p_n}{p_{n-1}} =
              frac{a_n*p_{n-1}}{p_{n-1}} +
              frac{p_{n-2}}{p_{n-1}} =
              a_n +
              frac{p_{n-2}}{p_{n-1}} =
              a_n + frac{1}{frac{p_{n-1}}{p_{n-2}}}.
              end{align*}$$



              Then $frac{p_{n-1}}{p_{n-2}}=a_{n-1}+frac{1}{frac{p_{n-2}}{p_{n-3}}}$ and so on.



              Continue doing this for arbitrary $n$ and get:



              $$frac{p_n}{p_{n-1}} =a_n + frac{1}{a_{n-1} + frac{1}{a_{n-2} + frac{1}{frac{p_{n-3}}{ddots}}}} = [a_{n},a_{n-1},a_{n-2},ldots,a_{0}].$$ Now $p_{n-1}q_{n}-p_nq_{n-1}=q_{n}^2-p_nq_{n-1}=(-1)^n$ by $frac{p_n}{q_n}=frac{p_n}{p_{n-1}}$ from what I stated earlier. Hence, $q^2equiv(-1)^n$ mod $p$. $Box$.






              share|cite|improve this answer




























                1














                I guess I figured it out now. We can make a straight forward argument as follows:



                $$begin{align*}frac{p_n}{p_{n-1}} =
                frac{a_n*p_{n-1}}{p_{n-1}} +
                frac{p_{n-2}}{p_{n-1}} =
                a_n +
                frac{p_{n-2}}{p_{n-1}} =
                a_n + frac{1}{frac{p_{n-1}}{p_{n-2}}}.
                end{align*}$$



                Then $frac{p_{n-1}}{p_{n-2}}=a_{n-1}+frac{1}{frac{p_{n-2}}{p_{n-3}}}$ and so on.



                Continue doing this for arbitrary $n$ and get:



                $$frac{p_n}{p_{n-1}} =a_n + frac{1}{a_{n-1} + frac{1}{a_{n-2} + frac{1}{frac{p_{n-3}}{ddots}}}} = [a_{n},a_{n-1},a_{n-2},ldots,a_{0}].$$ Now $p_{n-1}q_{n}-p_nq_{n-1}=q_{n}^2-p_nq_{n-1}=(-1)^n$ by $frac{p_n}{q_n}=frac{p_n}{p_{n-1}}$ from what I stated earlier. Hence, $q^2equiv(-1)^n$ mod $p$. $Box$.






                share|cite|improve this answer


























                  1












                  1








                  1






                  I guess I figured it out now. We can make a straight forward argument as follows:



                  $$begin{align*}frac{p_n}{p_{n-1}} =
                  frac{a_n*p_{n-1}}{p_{n-1}} +
                  frac{p_{n-2}}{p_{n-1}} =
                  a_n +
                  frac{p_{n-2}}{p_{n-1}} =
                  a_n + frac{1}{frac{p_{n-1}}{p_{n-2}}}.
                  end{align*}$$



                  Then $frac{p_{n-1}}{p_{n-2}}=a_{n-1}+frac{1}{frac{p_{n-2}}{p_{n-3}}}$ and so on.



                  Continue doing this for arbitrary $n$ and get:



                  $$frac{p_n}{p_{n-1}} =a_n + frac{1}{a_{n-1} + frac{1}{a_{n-2} + frac{1}{frac{p_{n-3}}{ddots}}}} = [a_{n},a_{n-1},a_{n-2},ldots,a_{0}].$$ Now $p_{n-1}q_{n}-p_nq_{n-1}=q_{n}^2-p_nq_{n-1}=(-1)^n$ by $frac{p_n}{q_n}=frac{p_n}{p_{n-1}}$ from what I stated earlier. Hence, $q^2equiv(-1)^n$ mod $p$. $Box$.






                  share|cite|improve this answer














                  I guess I figured it out now. We can make a straight forward argument as follows:



                  $$begin{align*}frac{p_n}{p_{n-1}} =
                  frac{a_n*p_{n-1}}{p_{n-1}} +
                  frac{p_{n-2}}{p_{n-1}} =
                  a_n +
                  frac{p_{n-2}}{p_{n-1}} =
                  a_n + frac{1}{frac{p_{n-1}}{p_{n-2}}}.
                  end{align*}$$



                  Then $frac{p_{n-1}}{p_{n-2}}=a_{n-1}+frac{1}{frac{p_{n-2}}{p_{n-3}}}$ and so on.



                  Continue doing this for arbitrary $n$ and get:



                  $$frac{p_n}{p_{n-1}} =a_n + frac{1}{a_{n-1} + frac{1}{a_{n-2} + frac{1}{frac{p_{n-3}}{ddots}}}} = [a_{n},a_{n-1},a_{n-2},ldots,a_{0}].$$ Now $p_{n-1}q_{n}-p_nq_{n-1}=q_{n}^2-p_nq_{n-1}=(-1)^n$ by $frac{p_n}{q_n}=frac{p_n}{p_{n-1}}$ from what I stated earlier. Hence, $q^2equiv(-1)^n$ mod $p$. $Box$.







                  share|cite|improve this answer














                  share|cite|improve this answer



                  share|cite|improve this answer








                  edited Dec 11 at 14:02

























                  answered Dec 11 at 13:46









                  Guus Palmer

                  620319




                  620319























                      1














                      I think a bit more detail about the recursion is useful.





                      As noted in the answer by Guus Palmer,
                      $$
                      begin{align}
                      frac{p_n}{p_{n-1}}
                      &=left(a_n;frac{p_{n-1}}{p_{n-2}}right)\
                      &=left(a_n;a_{n-1},frac{p_{n-2}}{p_{n-3}}right)\
                      &=left(a_n;a_{n-1},a_{n-2},dots,a_1,color{#C00}{frac{p_0}{p_{-1}}}right)\[6pt]
                      &=left(a_n;a_{n-1},a_{n-2},dots,a_1,color{#C00}{a_0}right)tag1
                      end{align}
                      $$

                      $$ %begin{align} frac{p_n}{p_{n-1}} &=a_n+cfrac1{frac{p_{n-1}}{p_{n-2}}}\ &=a_n+cfrac1{a_{n-1}+cfrac1{frac{p_{n-2}}{p_{n-3}}}}\ &,,vdots\ &=a_n+cfrac1{a_{n-1}+cfrac1{a_{n-2}+cfrac1{begin{matrix}ddots&lower{18pt}{a_1+cfrac1{color{#C00}{frac{p_0}{p_{-1}}}}}end{matrix}}}}\ &=a_n+cfrac1{a_{n-1}+cfrac1{a_{n-2}+cfrac1{begin{matrix}ddots&lower{18pt}{a_1+cfrac1{color{#C00}{a_0}}}end{matrix}}}}\ end{align} $$



                      Since $p_{-2}=0$ and $p_{-1}=1$ in the standard recursion.





                      However, note that the sequence of denominators also follows the same initial recursion:
                      $$
                      begin{align}
                      frac{q_n}{q_{n-1}}
                      &=left(a_n;frac{q_{n-1}}{q_{n-2}}right)\
                      &=left(a_n;a_{n-1},frac{q_{n-2}}{q_{n-3}}right)\
                      &=left(a_n;a_{n-1},a_{n-2},dots,a_2,color{#C00}{frac{q_1}{q_0}}right)\[6pt]
                      &=left(a_n;a_{n-1},a_{n-2},dots,a_2,color{#C00}{a_1}right)tag2
                      end{align}
                      $$

                      $$ %begin{align} frac{q_n}{q_{n-1}} &=a_n+cfrac1{frac{q_{n-1}}{q_{n-2}}}\ &=a_n+cfrac1{a_{n-1}+cfrac1{frac{q_{n-2}}{q_{n-3}}}}\ &,,vdots\ &=a_n+cfrac1{a_{n-1}+cfrac1{a_{n-2}+cfrac1{begin{matrix}ddots&lower{18pt}{a_2+cfrac1{color{#C00}{frac{q_1}{q_0}}}}end{matrix}}}}\ &=a_n+cfrac1{a_{n-1}+cfrac1{a_{n-2}+cfrac1{begin{matrix}ddots&lower{18pt}{a_2+cfrac1{color{#C00}{a_1}}}end{matrix}}}}\ end{align} $$



                      Since $q_{-2}=1$ and $q_{-1}=0$ in the standard recursion, we cannot extend the continued fraction to include $frac{q_0}{q_{-1}}$ as we did with $frac{p_n}{p_{n-1}}$.





                      So we need to be careful about considering the beginning of the continued fraction without being careful of the ending terms. Although the later terms are less significant, in this case, they are important.





                      The rest of the answer is fine. For sequential approximants of any continued fraction, we have
                      $$
                      p_{k-1}q_k-p_kq_{k-1}=(-1)^ktag3
                      $$

                      Since
                      $$
                      frac{p_n}{q_n}=(a_0;a_1,a_2,dots,a_{n-1},a_n)tag4
                      $$

                      is a palindromic continued fraction, we have from $(1)$ and $(4)$
                      $$
                      frac{p_n}{q_n}=frac{p_n}{p_{n-1}}tag5
                      $$

                      and applying $(5)$ to $(3)$, with $k=n$, we get
                      $$
                      q_n^2-p_nq_{n-1}=(-1)^ntag6
                      $$

                      That is,
                      $$
                      q_n^2equiv(-1)^npmod{p_n}tag7
                      $$






                      share|cite|improve this answer


























                        1














                        I think a bit more detail about the recursion is useful.





                        As noted in the answer by Guus Palmer,
                        $$
                        begin{align}
                        frac{p_n}{p_{n-1}}
                        &=left(a_n;frac{p_{n-1}}{p_{n-2}}right)\
                        &=left(a_n;a_{n-1},frac{p_{n-2}}{p_{n-3}}right)\
                        &=left(a_n;a_{n-1},a_{n-2},dots,a_1,color{#C00}{frac{p_0}{p_{-1}}}right)\[6pt]
                        &=left(a_n;a_{n-1},a_{n-2},dots,a_1,color{#C00}{a_0}right)tag1
                        end{align}
                        $$

                        $$ %begin{align} frac{p_n}{p_{n-1}} &=a_n+cfrac1{frac{p_{n-1}}{p_{n-2}}}\ &=a_n+cfrac1{a_{n-1}+cfrac1{frac{p_{n-2}}{p_{n-3}}}}\ &,,vdots\ &=a_n+cfrac1{a_{n-1}+cfrac1{a_{n-2}+cfrac1{begin{matrix}ddots&lower{18pt}{a_1+cfrac1{color{#C00}{frac{p_0}{p_{-1}}}}}end{matrix}}}}\ &=a_n+cfrac1{a_{n-1}+cfrac1{a_{n-2}+cfrac1{begin{matrix}ddots&lower{18pt}{a_1+cfrac1{color{#C00}{a_0}}}end{matrix}}}}\ end{align} $$



                        Since $p_{-2}=0$ and $p_{-1}=1$ in the standard recursion.





                        However, note that the sequence of denominators also follows the same initial recursion:
                        $$
                        begin{align}
                        frac{q_n}{q_{n-1}}
                        &=left(a_n;frac{q_{n-1}}{q_{n-2}}right)\
                        &=left(a_n;a_{n-1},frac{q_{n-2}}{q_{n-3}}right)\
                        &=left(a_n;a_{n-1},a_{n-2},dots,a_2,color{#C00}{frac{q_1}{q_0}}right)\[6pt]
                        &=left(a_n;a_{n-1},a_{n-2},dots,a_2,color{#C00}{a_1}right)tag2
                        end{align}
                        $$

                        $$ %begin{align} frac{q_n}{q_{n-1}} &=a_n+cfrac1{frac{q_{n-1}}{q_{n-2}}}\ &=a_n+cfrac1{a_{n-1}+cfrac1{frac{q_{n-2}}{q_{n-3}}}}\ &,,vdots\ &=a_n+cfrac1{a_{n-1}+cfrac1{a_{n-2}+cfrac1{begin{matrix}ddots&lower{18pt}{a_2+cfrac1{color{#C00}{frac{q_1}{q_0}}}}end{matrix}}}}\ &=a_n+cfrac1{a_{n-1}+cfrac1{a_{n-2}+cfrac1{begin{matrix}ddots&lower{18pt}{a_2+cfrac1{color{#C00}{a_1}}}end{matrix}}}}\ end{align} $$



                        Since $q_{-2}=1$ and $q_{-1}=0$ in the standard recursion, we cannot extend the continued fraction to include $frac{q_0}{q_{-1}}$ as we did with $frac{p_n}{p_{n-1}}$.





                        So we need to be careful about considering the beginning of the continued fraction without being careful of the ending terms. Although the later terms are less significant, in this case, they are important.





                        The rest of the answer is fine. For sequential approximants of any continued fraction, we have
                        $$
                        p_{k-1}q_k-p_kq_{k-1}=(-1)^ktag3
                        $$

                        Since
                        $$
                        frac{p_n}{q_n}=(a_0;a_1,a_2,dots,a_{n-1},a_n)tag4
                        $$

                        is a palindromic continued fraction, we have from $(1)$ and $(4)$
                        $$
                        frac{p_n}{q_n}=frac{p_n}{p_{n-1}}tag5
                        $$

                        and applying $(5)$ to $(3)$, with $k=n$, we get
                        $$
                        q_n^2-p_nq_{n-1}=(-1)^ntag6
                        $$

                        That is,
                        $$
                        q_n^2equiv(-1)^npmod{p_n}tag7
                        $$






                        share|cite|improve this answer
























                          1












                          1








                          1






                          I think a bit more detail about the recursion is useful.





                          As noted in the answer by Guus Palmer,
                          $$
                          begin{align}
                          frac{p_n}{p_{n-1}}
                          &=left(a_n;frac{p_{n-1}}{p_{n-2}}right)\
                          &=left(a_n;a_{n-1},frac{p_{n-2}}{p_{n-3}}right)\
                          &=left(a_n;a_{n-1},a_{n-2},dots,a_1,color{#C00}{frac{p_0}{p_{-1}}}right)\[6pt]
                          &=left(a_n;a_{n-1},a_{n-2},dots,a_1,color{#C00}{a_0}right)tag1
                          end{align}
                          $$

                          $$ %begin{align} frac{p_n}{p_{n-1}} &=a_n+cfrac1{frac{p_{n-1}}{p_{n-2}}}\ &=a_n+cfrac1{a_{n-1}+cfrac1{frac{p_{n-2}}{p_{n-3}}}}\ &,,vdots\ &=a_n+cfrac1{a_{n-1}+cfrac1{a_{n-2}+cfrac1{begin{matrix}ddots&lower{18pt}{a_1+cfrac1{color{#C00}{frac{p_0}{p_{-1}}}}}end{matrix}}}}\ &=a_n+cfrac1{a_{n-1}+cfrac1{a_{n-2}+cfrac1{begin{matrix}ddots&lower{18pt}{a_1+cfrac1{color{#C00}{a_0}}}end{matrix}}}}\ end{align} $$



                          Since $p_{-2}=0$ and $p_{-1}=1$ in the standard recursion.





                          However, note that the sequence of denominators also follows the same initial recursion:
                          $$
                          begin{align}
                          frac{q_n}{q_{n-1}}
                          &=left(a_n;frac{q_{n-1}}{q_{n-2}}right)\
                          &=left(a_n;a_{n-1},frac{q_{n-2}}{q_{n-3}}right)\
                          &=left(a_n;a_{n-1},a_{n-2},dots,a_2,color{#C00}{frac{q_1}{q_0}}right)\[6pt]
                          &=left(a_n;a_{n-1},a_{n-2},dots,a_2,color{#C00}{a_1}right)tag2
                          end{align}
                          $$

                          $$ %begin{align} frac{q_n}{q_{n-1}} &=a_n+cfrac1{frac{q_{n-1}}{q_{n-2}}}\ &=a_n+cfrac1{a_{n-1}+cfrac1{frac{q_{n-2}}{q_{n-3}}}}\ &,,vdots\ &=a_n+cfrac1{a_{n-1}+cfrac1{a_{n-2}+cfrac1{begin{matrix}ddots&lower{18pt}{a_2+cfrac1{color{#C00}{frac{q_1}{q_0}}}}end{matrix}}}}\ &=a_n+cfrac1{a_{n-1}+cfrac1{a_{n-2}+cfrac1{begin{matrix}ddots&lower{18pt}{a_2+cfrac1{color{#C00}{a_1}}}end{matrix}}}}\ end{align} $$



                          Since $q_{-2}=1$ and $q_{-1}=0$ in the standard recursion, we cannot extend the continued fraction to include $frac{q_0}{q_{-1}}$ as we did with $frac{p_n}{p_{n-1}}$.





                          So we need to be careful about considering the beginning of the continued fraction without being careful of the ending terms. Although the later terms are less significant, in this case, they are important.





                          The rest of the answer is fine. For sequential approximants of any continued fraction, we have
                          $$
                          p_{k-1}q_k-p_kq_{k-1}=(-1)^ktag3
                          $$

                          Since
                          $$
                          frac{p_n}{q_n}=(a_0;a_1,a_2,dots,a_{n-1},a_n)tag4
                          $$

                          is a palindromic continued fraction, we have from $(1)$ and $(4)$
                          $$
                          frac{p_n}{q_n}=frac{p_n}{p_{n-1}}tag5
                          $$

                          and applying $(5)$ to $(3)$, with $k=n$, we get
                          $$
                          q_n^2-p_nq_{n-1}=(-1)^ntag6
                          $$

                          That is,
                          $$
                          q_n^2equiv(-1)^npmod{p_n}tag7
                          $$






                          share|cite|improve this answer












                          I think a bit more detail about the recursion is useful.





                          As noted in the answer by Guus Palmer,
                          $$
                          begin{align}
                          frac{p_n}{p_{n-1}}
                          &=left(a_n;frac{p_{n-1}}{p_{n-2}}right)\
                          &=left(a_n;a_{n-1},frac{p_{n-2}}{p_{n-3}}right)\
                          &=left(a_n;a_{n-1},a_{n-2},dots,a_1,color{#C00}{frac{p_0}{p_{-1}}}right)\[6pt]
                          &=left(a_n;a_{n-1},a_{n-2},dots,a_1,color{#C00}{a_0}right)tag1
                          end{align}
                          $$

                          $$ %begin{align} frac{p_n}{p_{n-1}} &=a_n+cfrac1{frac{p_{n-1}}{p_{n-2}}}\ &=a_n+cfrac1{a_{n-1}+cfrac1{frac{p_{n-2}}{p_{n-3}}}}\ &,,vdots\ &=a_n+cfrac1{a_{n-1}+cfrac1{a_{n-2}+cfrac1{begin{matrix}ddots&lower{18pt}{a_1+cfrac1{color{#C00}{frac{p_0}{p_{-1}}}}}end{matrix}}}}\ &=a_n+cfrac1{a_{n-1}+cfrac1{a_{n-2}+cfrac1{begin{matrix}ddots&lower{18pt}{a_1+cfrac1{color{#C00}{a_0}}}end{matrix}}}}\ end{align} $$



                          Since $p_{-2}=0$ and $p_{-1}=1$ in the standard recursion.





                          However, note that the sequence of denominators also follows the same initial recursion:
                          $$
                          begin{align}
                          frac{q_n}{q_{n-1}}
                          &=left(a_n;frac{q_{n-1}}{q_{n-2}}right)\
                          &=left(a_n;a_{n-1},frac{q_{n-2}}{q_{n-3}}right)\
                          &=left(a_n;a_{n-1},a_{n-2},dots,a_2,color{#C00}{frac{q_1}{q_0}}right)\[6pt]
                          &=left(a_n;a_{n-1},a_{n-2},dots,a_2,color{#C00}{a_1}right)tag2
                          end{align}
                          $$

                          $$ %begin{align} frac{q_n}{q_{n-1}} &=a_n+cfrac1{frac{q_{n-1}}{q_{n-2}}}\ &=a_n+cfrac1{a_{n-1}+cfrac1{frac{q_{n-2}}{q_{n-3}}}}\ &,,vdots\ &=a_n+cfrac1{a_{n-1}+cfrac1{a_{n-2}+cfrac1{begin{matrix}ddots&lower{18pt}{a_2+cfrac1{color{#C00}{frac{q_1}{q_0}}}}end{matrix}}}}\ &=a_n+cfrac1{a_{n-1}+cfrac1{a_{n-2}+cfrac1{begin{matrix}ddots&lower{18pt}{a_2+cfrac1{color{#C00}{a_1}}}end{matrix}}}}\ end{align} $$



                          Since $q_{-2}=1$ and $q_{-1}=0$ in the standard recursion, we cannot extend the continued fraction to include $frac{q_0}{q_{-1}}$ as we did with $frac{p_n}{p_{n-1}}$.





                          So we need to be careful about considering the beginning of the continued fraction without being careful of the ending terms. Although the later terms are less significant, in this case, they are important.





                          The rest of the answer is fine. For sequential approximants of any continued fraction, we have
                          $$
                          p_{k-1}q_k-p_kq_{k-1}=(-1)^ktag3
                          $$

                          Since
                          $$
                          frac{p_n}{q_n}=(a_0;a_1,a_2,dots,a_{n-1},a_n)tag4
                          $$

                          is a palindromic continued fraction, we have from $(1)$ and $(4)$
                          $$
                          frac{p_n}{q_n}=frac{p_n}{p_{n-1}}tag5
                          $$

                          and applying $(5)$ to $(3)$, with $k=n$, we get
                          $$
                          q_n^2-p_nq_{n-1}=(-1)^ntag6
                          $$

                          That is,
                          $$
                          q_n^2equiv(-1)^npmod{p_n}tag7
                          $$







                          share|cite|improve this answer












                          share|cite|improve this answer



                          share|cite|improve this answer










                          answered Dec 13 at 17:00









                          robjohn

                          264k27303623




                          264k27303623






























                              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.





                              Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                              Please pay close attention to the following guidance:


                              • 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.


                              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%2f3031393%2fsymmetric-continued-fractions-property-where-q2-equiv-1n-mod-p%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

                              Bressuire

                              Cabo Verde

                              Gyllenstierna