Calculating DCT with DFT












0












$begingroup$


The discrete cosine transform is given by




(DCT($f$))$_j$= $sumlimits_{k=0}^{n-1}f_k cos(frac{pi}{2}(k+frac{1}{2})j)$



with reference points $x_k=frac{pi}{2n}(2k+1)$




How do we show that (DCT$(f))_j$=2n(DFT($hat{f}))_j$



where $hat{f}=(0,f_0,0,f_1,...,f_{n-1},0,f_{n-1},0,f_{n-2},...,0,f_1,0,f_0)$?










share|cite|improve this question











$endgroup$

















    0












    $begingroup$


    The discrete cosine transform is given by




    (DCT($f$))$_j$= $sumlimits_{k=0}^{n-1}f_k cos(frac{pi}{2}(k+frac{1}{2})j)$



    with reference points $x_k=frac{pi}{2n}(2k+1)$




    How do we show that (DCT$(f))_j$=2n(DFT($hat{f}))_j$



    where $hat{f}=(0,f_0,0,f_1,...,f_{n-1},0,f_{n-1},0,f_{n-2},...,0,f_1,0,f_0)$?










    share|cite|improve this question











    $endgroup$















      0












      0








      0


      0



      $begingroup$


      The discrete cosine transform is given by




      (DCT($f$))$_j$= $sumlimits_{k=0}^{n-1}f_k cos(frac{pi}{2}(k+frac{1}{2})j)$



      with reference points $x_k=frac{pi}{2n}(2k+1)$




      How do we show that (DCT$(f))_j$=2n(DFT($hat{f}))_j$



      where $hat{f}=(0,f_0,0,f_1,...,f_{n-1},0,f_{n-1},0,f_{n-2},...,0,f_1,0,f_0)$?










      share|cite|improve this question











      $endgroup$




      The discrete cosine transform is given by




      (DCT($f$))$_j$= $sumlimits_{k=0}^{n-1}f_k cos(frac{pi}{2}(k+frac{1}{2})j)$



      with reference points $x_k=frac{pi}{2n}(2k+1)$




      How do we show that (DCT$(f))_j$=2n(DFT($hat{f}))_j$



      where $hat{f}=(0,f_0,0,f_1,...,f_{n-1},0,f_{n-1},0,f_{n-2},...,0,f_1,0,f_0)$?







      fourier-transform






      share|cite|improve this question















      share|cite|improve this question













      share|cite|improve this question




      share|cite|improve this question








      edited Jan 15 at 18:29







      babemcnuggets

















      asked Jan 13 at 3:58









      babemcnuggetsbabemcnuggets

      1129




      1129






















          1 Answer
          1






          active

          oldest

          votes


















          0












          $begingroup$

          After understanding better I came up with a solution myself.
          The DFT($f$)$_j$ I am using is



          DFT($f$)$_j = frac{1}{n}sumlimits_{k=0}^{n-1} f_k e^{-j2pifrac{1}{n}ki}$



          So $2n$*DFT($hat{f}$)$_j$ = $2nfrac{1}{4n}sumlimits_{k=0}^{4n-1} hat{f}_k e^{-j2pifrac{1}{4n}ki}$ = $frac{1}{2}sumlimits_{k=0}^{4n-1} hat{f}_k e^{-jpifrac{1}{2n}ki}$.



          Now we see that only the odd $hat{f}_k$ matter here so we rewrite it as:



          $frac{1}{2}sumlimits_{k=0}^{2n-1} hat{f}_{2k+1} e^{-jpifrac{1}{2n}(2k+1)i}$ = $frac{1}{2}(sumlimits_{k=0}^{n-1} hat{f}_{2k+1} e^{-jpifrac{1}{2n}(2k+1)i}$+ $sumlimits_{k=n}^{2n-1} hat{f}_{2k+1} e^{-jpifrac{1}{2n}(2k+1)i})$



          Let $f=(f_0,f_1...,f_{n-1})$. We see that we can replace $hat{f}_{2k+1}$ in the first sum with $f_k$. We then want the other sum to also "be" $f$ and let the second sum run from the end to the start meaning :



          $frac{1}{2}(sumlimits_{k=0}^{n-1} f_k e^{-jpifrac{1}{2n}(2k+1)i}$+ $sumlimits_{k=n}^{2n-1} hat{f}_{2(2n-1-k)+1} e^{-jpifrac{1}{2n}(2(2n-1-k)+1)i})$



          We can't put those two sums together yet, so we substitute $m=2n-1-k$ which means $k=2n-1-m$ and brings us to:



          $frac{1}{2}(sumlimits_{k=0}^{n-1} f_k e^{-jpifrac{1}{2n}(2k+1)i}$+ $sumlimits_{m=0}^{n-1} hat{f}_{2m+1} e^{-jpifrac{1}{2n}(2m+1)i})$



          Finally we have that for identical $m$ and $k$ that $f_k = hat{f}_2m+1$ and we take the two sums together:



          $frac{1}{2}sumlimits_{k=0}^{n-1} f_k (e^{-jpifrac{1}{2n}(2k+1)i}+e^{-jpifrac{1}{2n}(2(2n-1-k)+1)i})$=$frac{1}{2}sumlimits_{k=0}^{n-1} f_k (e^{-jpifrac{1}{2n}(2k+1)i}+e^{-jpifrac{1}{2n}(4n-2k+1)i})$ = $frac{1}{2}sumlimits_{k=0}^{n-1} f_k (e^{-jpifrac{1}{2n}(2k+1)i}+e^{-j2pi}e^{jpifrac{1}{2n} (2k+1)i)}$ = $frac{1}{2}sumlimits_{k=0}^{n-1} f_k (e^{-jpifrac{1}{2n}(2k+1)i}+e^{jpifrac{1}{2n} (2k+1)i)}$



          Now remember that $cos(x)=frac{1}{2}(e^{ix}+e^{-ix})$ or $2cos(x)=(e^{ix}+e^{-ix})$. Concluding you have:



          $frac{1}{2}sumlimits_{k=0}^{n-1} f_k 2cos(frac{pi}{2}(2k+1)j)$=$sumlimits_{k=0}^{n-1} f_k cos(pi(k+frac{1}{2})j)$ which had to be shown.






          share|cite|improve this answer









          $endgroup$













            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%2f3071692%2fcalculating-dct-with-dft%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0












            $begingroup$

            After understanding better I came up with a solution myself.
            The DFT($f$)$_j$ I am using is



            DFT($f$)$_j = frac{1}{n}sumlimits_{k=0}^{n-1} f_k e^{-j2pifrac{1}{n}ki}$



            So $2n$*DFT($hat{f}$)$_j$ = $2nfrac{1}{4n}sumlimits_{k=0}^{4n-1} hat{f}_k e^{-j2pifrac{1}{4n}ki}$ = $frac{1}{2}sumlimits_{k=0}^{4n-1} hat{f}_k e^{-jpifrac{1}{2n}ki}$.



            Now we see that only the odd $hat{f}_k$ matter here so we rewrite it as:



            $frac{1}{2}sumlimits_{k=0}^{2n-1} hat{f}_{2k+1} e^{-jpifrac{1}{2n}(2k+1)i}$ = $frac{1}{2}(sumlimits_{k=0}^{n-1} hat{f}_{2k+1} e^{-jpifrac{1}{2n}(2k+1)i}$+ $sumlimits_{k=n}^{2n-1} hat{f}_{2k+1} e^{-jpifrac{1}{2n}(2k+1)i})$



            Let $f=(f_0,f_1...,f_{n-1})$. We see that we can replace $hat{f}_{2k+1}$ in the first sum with $f_k$. We then want the other sum to also "be" $f$ and let the second sum run from the end to the start meaning :



            $frac{1}{2}(sumlimits_{k=0}^{n-1} f_k e^{-jpifrac{1}{2n}(2k+1)i}$+ $sumlimits_{k=n}^{2n-1} hat{f}_{2(2n-1-k)+1} e^{-jpifrac{1}{2n}(2(2n-1-k)+1)i})$



            We can't put those two sums together yet, so we substitute $m=2n-1-k$ which means $k=2n-1-m$ and brings us to:



            $frac{1}{2}(sumlimits_{k=0}^{n-1} f_k e^{-jpifrac{1}{2n}(2k+1)i}$+ $sumlimits_{m=0}^{n-1} hat{f}_{2m+1} e^{-jpifrac{1}{2n}(2m+1)i})$



            Finally we have that for identical $m$ and $k$ that $f_k = hat{f}_2m+1$ and we take the two sums together:



            $frac{1}{2}sumlimits_{k=0}^{n-1} f_k (e^{-jpifrac{1}{2n}(2k+1)i}+e^{-jpifrac{1}{2n}(2(2n-1-k)+1)i})$=$frac{1}{2}sumlimits_{k=0}^{n-1} f_k (e^{-jpifrac{1}{2n}(2k+1)i}+e^{-jpifrac{1}{2n}(4n-2k+1)i})$ = $frac{1}{2}sumlimits_{k=0}^{n-1} f_k (e^{-jpifrac{1}{2n}(2k+1)i}+e^{-j2pi}e^{jpifrac{1}{2n} (2k+1)i)}$ = $frac{1}{2}sumlimits_{k=0}^{n-1} f_k (e^{-jpifrac{1}{2n}(2k+1)i}+e^{jpifrac{1}{2n} (2k+1)i)}$



            Now remember that $cos(x)=frac{1}{2}(e^{ix}+e^{-ix})$ or $2cos(x)=(e^{ix}+e^{-ix})$. Concluding you have:



            $frac{1}{2}sumlimits_{k=0}^{n-1} f_k 2cos(frac{pi}{2}(2k+1)j)$=$sumlimits_{k=0}^{n-1} f_k cos(pi(k+frac{1}{2})j)$ which had to be shown.






            share|cite|improve this answer









            $endgroup$


















              0












              $begingroup$

              After understanding better I came up with a solution myself.
              The DFT($f$)$_j$ I am using is



              DFT($f$)$_j = frac{1}{n}sumlimits_{k=0}^{n-1} f_k e^{-j2pifrac{1}{n}ki}$



              So $2n$*DFT($hat{f}$)$_j$ = $2nfrac{1}{4n}sumlimits_{k=0}^{4n-1} hat{f}_k e^{-j2pifrac{1}{4n}ki}$ = $frac{1}{2}sumlimits_{k=0}^{4n-1} hat{f}_k e^{-jpifrac{1}{2n}ki}$.



              Now we see that only the odd $hat{f}_k$ matter here so we rewrite it as:



              $frac{1}{2}sumlimits_{k=0}^{2n-1} hat{f}_{2k+1} e^{-jpifrac{1}{2n}(2k+1)i}$ = $frac{1}{2}(sumlimits_{k=0}^{n-1} hat{f}_{2k+1} e^{-jpifrac{1}{2n}(2k+1)i}$+ $sumlimits_{k=n}^{2n-1} hat{f}_{2k+1} e^{-jpifrac{1}{2n}(2k+1)i})$



              Let $f=(f_0,f_1...,f_{n-1})$. We see that we can replace $hat{f}_{2k+1}$ in the first sum with $f_k$. We then want the other sum to also "be" $f$ and let the second sum run from the end to the start meaning :



              $frac{1}{2}(sumlimits_{k=0}^{n-1} f_k e^{-jpifrac{1}{2n}(2k+1)i}$+ $sumlimits_{k=n}^{2n-1} hat{f}_{2(2n-1-k)+1} e^{-jpifrac{1}{2n}(2(2n-1-k)+1)i})$



              We can't put those two sums together yet, so we substitute $m=2n-1-k$ which means $k=2n-1-m$ and brings us to:



              $frac{1}{2}(sumlimits_{k=0}^{n-1} f_k e^{-jpifrac{1}{2n}(2k+1)i}$+ $sumlimits_{m=0}^{n-1} hat{f}_{2m+1} e^{-jpifrac{1}{2n}(2m+1)i})$



              Finally we have that for identical $m$ and $k$ that $f_k = hat{f}_2m+1$ and we take the two sums together:



              $frac{1}{2}sumlimits_{k=0}^{n-1} f_k (e^{-jpifrac{1}{2n}(2k+1)i}+e^{-jpifrac{1}{2n}(2(2n-1-k)+1)i})$=$frac{1}{2}sumlimits_{k=0}^{n-1} f_k (e^{-jpifrac{1}{2n}(2k+1)i}+e^{-jpifrac{1}{2n}(4n-2k+1)i})$ = $frac{1}{2}sumlimits_{k=0}^{n-1} f_k (e^{-jpifrac{1}{2n}(2k+1)i}+e^{-j2pi}e^{jpifrac{1}{2n} (2k+1)i)}$ = $frac{1}{2}sumlimits_{k=0}^{n-1} f_k (e^{-jpifrac{1}{2n}(2k+1)i}+e^{jpifrac{1}{2n} (2k+1)i)}$



              Now remember that $cos(x)=frac{1}{2}(e^{ix}+e^{-ix})$ or $2cos(x)=(e^{ix}+e^{-ix})$. Concluding you have:



              $frac{1}{2}sumlimits_{k=0}^{n-1} f_k 2cos(frac{pi}{2}(2k+1)j)$=$sumlimits_{k=0}^{n-1} f_k cos(pi(k+frac{1}{2})j)$ which had to be shown.






              share|cite|improve this answer









              $endgroup$
















                0












                0








                0





                $begingroup$

                After understanding better I came up with a solution myself.
                The DFT($f$)$_j$ I am using is



                DFT($f$)$_j = frac{1}{n}sumlimits_{k=0}^{n-1} f_k e^{-j2pifrac{1}{n}ki}$



                So $2n$*DFT($hat{f}$)$_j$ = $2nfrac{1}{4n}sumlimits_{k=0}^{4n-1} hat{f}_k e^{-j2pifrac{1}{4n}ki}$ = $frac{1}{2}sumlimits_{k=0}^{4n-1} hat{f}_k e^{-jpifrac{1}{2n}ki}$.



                Now we see that only the odd $hat{f}_k$ matter here so we rewrite it as:



                $frac{1}{2}sumlimits_{k=0}^{2n-1} hat{f}_{2k+1} e^{-jpifrac{1}{2n}(2k+1)i}$ = $frac{1}{2}(sumlimits_{k=0}^{n-1} hat{f}_{2k+1} e^{-jpifrac{1}{2n}(2k+1)i}$+ $sumlimits_{k=n}^{2n-1} hat{f}_{2k+1} e^{-jpifrac{1}{2n}(2k+1)i})$



                Let $f=(f_0,f_1...,f_{n-1})$. We see that we can replace $hat{f}_{2k+1}$ in the first sum with $f_k$. We then want the other sum to also "be" $f$ and let the second sum run from the end to the start meaning :



                $frac{1}{2}(sumlimits_{k=0}^{n-1} f_k e^{-jpifrac{1}{2n}(2k+1)i}$+ $sumlimits_{k=n}^{2n-1} hat{f}_{2(2n-1-k)+1} e^{-jpifrac{1}{2n}(2(2n-1-k)+1)i})$



                We can't put those two sums together yet, so we substitute $m=2n-1-k$ which means $k=2n-1-m$ and brings us to:



                $frac{1}{2}(sumlimits_{k=0}^{n-1} f_k e^{-jpifrac{1}{2n}(2k+1)i}$+ $sumlimits_{m=0}^{n-1} hat{f}_{2m+1} e^{-jpifrac{1}{2n}(2m+1)i})$



                Finally we have that for identical $m$ and $k$ that $f_k = hat{f}_2m+1$ and we take the two sums together:



                $frac{1}{2}sumlimits_{k=0}^{n-1} f_k (e^{-jpifrac{1}{2n}(2k+1)i}+e^{-jpifrac{1}{2n}(2(2n-1-k)+1)i})$=$frac{1}{2}sumlimits_{k=0}^{n-1} f_k (e^{-jpifrac{1}{2n}(2k+1)i}+e^{-jpifrac{1}{2n}(4n-2k+1)i})$ = $frac{1}{2}sumlimits_{k=0}^{n-1} f_k (e^{-jpifrac{1}{2n}(2k+1)i}+e^{-j2pi}e^{jpifrac{1}{2n} (2k+1)i)}$ = $frac{1}{2}sumlimits_{k=0}^{n-1} f_k (e^{-jpifrac{1}{2n}(2k+1)i}+e^{jpifrac{1}{2n} (2k+1)i)}$



                Now remember that $cos(x)=frac{1}{2}(e^{ix}+e^{-ix})$ or $2cos(x)=(e^{ix}+e^{-ix})$. Concluding you have:



                $frac{1}{2}sumlimits_{k=0}^{n-1} f_k 2cos(frac{pi}{2}(2k+1)j)$=$sumlimits_{k=0}^{n-1} f_k cos(pi(k+frac{1}{2})j)$ which had to be shown.






                share|cite|improve this answer









                $endgroup$



                After understanding better I came up with a solution myself.
                The DFT($f$)$_j$ I am using is



                DFT($f$)$_j = frac{1}{n}sumlimits_{k=0}^{n-1} f_k e^{-j2pifrac{1}{n}ki}$



                So $2n$*DFT($hat{f}$)$_j$ = $2nfrac{1}{4n}sumlimits_{k=0}^{4n-1} hat{f}_k e^{-j2pifrac{1}{4n}ki}$ = $frac{1}{2}sumlimits_{k=0}^{4n-1} hat{f}_k e^{-jpifrac{1}{2n}ki}$.



                Now we see that only the odd $hat{f}_k$ matter here so we rewrite it as:



                $frac{1}{2}sumlimits_{k=0}^{2n-1} hat{f}_{2k+1} e^{-jpifrac{1}{2n}(2k+1)i}$ = $frac{1}{2}(sumlimits_{k=0}^{n-1} hat{f}_{2k+1} e^{-jpifrac{1}{2n}(2k+1)i}$+ $sumlimits_{k=n}^{2n-1} hat{f}_{2k+1} e^{-jpifrac{1}{2n}(2k+1)i})$



                Let $f=(f_0,f_1...,f_{n-1})$. We see that we can replace $hat{f}_{2k+1}$ in the first sum with $f_k$. We then want the other sum to also "be" $f$ and let the second sum run from the end to the start meaning :



                $frac{1}{2}(sumlimits_{k=0}^{n-1} f_k e^{-jpifrac{1}{2n}(2k+1)i}$+ $sumlimits_{k=n}^{2n-1} hat{f}_{2(2n-1-k)+1} e^{-jpifrac{1}{2n}(2(2n-1-k)+1)i})$



                We can't put those two sums together yet, so we substitute $m=2n-1-k$ which means $k=2n-1-m$ and brings us to:



                $frac{1}{2}(sumlimits_{k=0}^{n-1} f_k e^{-jpifrac{1}{2n}(2k+1)i}$+ $sumlimits_{m=0}^{n-1} hat{f}_{2m+1} e^{-jpifrac{1}{2n}(2m+1)i})$



                Finally we have that for identical $m$ and $k$ that $f_k = hat{f}_2m+1$ and we take the two sums together:



                $frac{1}{2}sumlimits_{k=0}^{n-1} f_k (e^{-jpifrac{1}{2n}(2k+1)i}+e^{-jpifrac{1}{2n}(2(2n-1-k)+1)i})$=$frac{1}{2}sumlimits_{k=0}^{n-1} f_k (e^{-jpifrac{1}{2n}(2k+1)i}+e^{-jpifrac{1}{2n}(4n-2k+1)i})$ = $frac{1}{2}sumlimits_{k=0}^{n-1} f_k (e^{-jpifrac{1}{2n}(2k+1)i}+e^{-j2pi}e^{jpifrac{1}{2n} (2k+1)i)}$ = $frac{1}{2}sumlimits_{k=0}^{n-1} f_k (e^{-jpifrac{1}{2n}(2k+1)i}+e^{jpifrac{1}{2n} (2k+1)i)}$



                Now remember that $cos(x)=frac{1}{2}(e^{ix}+e^{-ix})$ or $2cos(x)=(e^{ix}+e^{-ix})$. Concluding you have:



                $frac{1}{2}sumlimits_{k=0}^{n-1} f_k 2cos(frac{pi}{2}(2k+1)j)$=$sumlimits_{k=0}^{n-1} f_k cos(pi(k+frac{1}{2})j)$ which had to be shown.







                share|cite|improve this answer












                share|cite|improve this answer



                share|cite|improve this answer










                answered Jan 15 at 23:13









                babemcnuggetsbabemcnuggets

                1129




                1129






























                    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%2f3071692%2fcalculating-dct-with-dft%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

                    MongoDB - Not Authorized To Execute Command

                    How to fix TextFormField cause rebuild widget in Flutter

                    in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith