Solve a double summation in R












2















Is there any way of solving the following sum in R:



enter image description here










share|improve this question





























    2















    Is there any way of solving the following sum in R:



    enter image description here










    share|improve this question



























      2












      2








      2








      Is there any way of solving the following sum in R:



      enter image description here










      share|improve this question
















      Is there any way of solving the following sum in R:



      enter image description here







      r






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 20 '18 at 18:18









      m0nhawk

      15.6k83262




      15.6k83262










      asked Nov 20 '18 at 18:18









      Nasir AbbasNasir Abbas

      186




      186
























          2 Answers
          2






          active

          oldest

          votes


















          4














          You can calculate this without any for loops:



          double_sum <- function(j) {
          sum(sapply(1:j, function(i) sum(1/i:j))^2) / j^2
          }


          And then calculate for each j:



          > sapply(1:50, outer_sum)
          [1] 1.00000000 0.62500000 0.46296296 0.36979167 0.30866667 0.26527778 0.23279883 0.20753348 0.18729669 0.17071032
          [11] 0.15686052 0.14511659 0.13502879 0.12626754 0.11858565 0.11179403 0.10574549 0.10032374 0.09543562 0.09100565
          [21] 0.08697198 0.08328344 0.07989737 0.07677785 0.07389447 0.07122127 0.06873600 0.06641942 0.06425487 0.06222779
          [31] 0.06032545 0.05853663 0.05685142 0.05526106 0.05375773 0.05233445 0.05098496 0.04970367 0.04848551 0.04732591
          [41] 0.04622074 0.04516625 0.04415901 0.04319591 0.04227410 0.04139098 0.04054415 0.03973142 0.03895077 0.03820032


          Or something strange (built upper triangle matrix for coefficient and then sum rows and results):



          mat_sum <- function(j) {
          d <- outer(rep(1, j), 1:j, FUN="/")
          d[lower.tri(d)] <- 0
          sum(rowSums(d)^2) / j^2
          }


          And benchmarks:



          > s <- 1:100
          > microbenchmark::microbenchmark(for_sum=sapply(s, sumfun), double_sum=sapply(s, double_sum), mat_sum=sapply(s, mat_sum))
          Unit: milliseconds
          expr min lq mean median uq max neval
          for_sum 9.601222 10.261159 11.996525 10.774037 11.894962 30.56077 100
          double_sum 6.075801 6.678923 8.787946 7.373223 8.697266 21.37783 100
          mat_sum 7.809572 8.770058 13.766358 10.190758 18.500802 46.18336 100





          share|improve this answer


























          • Manually I checked, the second value of sum (for j=2) is 0.375. There is something wrong with the code.

            – Nasir Abbas
            Nov 21 '18 at 5:31











          • In Wolfram Mathematica I'm getting the same result, as in R. The exact value for j=2 is 5/8. Check the Wolfram|Alpha.

            – m0nhawk
            Nov 21 '18 at 16:10













          • Please, recheck your calculations, you took the square of each term, but you need to take the square of the whole inner sum. Here is the result for j=2: (1/2 + 1/4)^2 + (1/4)^2 = 5/8, and you calculated: (1/2)^2 + (1/4)^2 + (1/4)^2 = 3/8.

            – m0nhawk
            Nov 21 '18 at 16:41



















          2














          sumfun <- function(j) {
          res <- 0
          for(i in 1:j) {
          temp <- 0
          for(k in i:j) {
          temp <- temp + 1/(k*j)
          }
          res <- res + temp^2
          }
          return(res)
          }

          sapply(1:50, sumfun)





          [1] 1.00000000 0.62500000 0.46296296 0.36979167 0.30866667 0.26527778 0.23279883 0.20753348 0.18729669 0.17071032 0.15686052
          [12] 0.14511659 0.13502879 0.12626754 0.11858565 0.11179403 0.10574549 0.10032374 0.09543562 0.09100565 0.08697198 0.08328344
          [23] 0.07989737 0.07677785 0.07389447 0.07122127 0.06873600 0.06641942 0.06425487 0.06222779 0.06032545 0.05853663 0.05685142
          [34] 0.05526106 0.05375773 0.05233445 0.05098496 0.04970367 0.04848551 0.04732591 0.04622074 0.04516625 0.04415901 0.04319591
          [45] 0.04227410 0.04139098 0.04054415 0.03973142 0.03895077 0.03820032





          share|improve this answer


























          • Manually I checked, the second value of sum (for j=2) is 0.375. There is something wrong with the code.

            – Nasir Abbas
            Nov 21 '18 at 5:33











          • Check your work. The double sum for J=2 is (1/2 + 1/4)^2 + 1/4^2 = 10/16 = 0.625.

            – Dan Y
            Nov 21 '18 at 5:45











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          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
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53399150%2fsolve-a-double-summation-in-r%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









          4














          You can calculate this without any for loops:



          double_sum <- function(j) {
          sum(sapply(1:j, function(i) sum(1/i:j))^2) / j^2
          }


          And then calculate for each j:



          > sapply(1:50, outer_sum)
          [1] 1.00000000 0.62500000 0.46296296 0.36979167 0.30866667 0.26527778 0.23279883 0.20753348 0.18729669 0.17071032
          [11] 0.15686052 0.14511659 0.13502879 0.12626754 0.11858565 0.11179403 0.10574549 0.10032374 0.09543562 0.09100565
          [21] 0.08697198 0.08328344 0.07989737 0.07677785 0.07389447 0.07122127 0.06873600 0.06641942 0.06425487 0.06222779
          [31] 0.06032545 0.05853663 0.05685142 0.05526106 0.05375773 0.05233445 0.05098496 0.04970367 0.04848551 0.04732591
          [41] 0.04622074 0.04516625 0.04415901 0.04319591 0.04227410 0.04139098 0.04054415 0.03973142 0.03895077 0.03820032


          Or something strange (built upper triangle matrix for coefficient and then sum rows and results):



          mat_sum <- function(j) {
          d <- outer(rep(1, j), 1:j, FUN="/")
          d[lower.tri(d)] <- 0
          sum(rowSums(d)^2) / j^2
          }


          And benchmarks:



          > s <- 1:100
          > microbenchmark::microbenchmark(for_sum=sapply(s, sumfun), double_sum=sapply(s, double_sum), mat_sum=sapply(s, mat_sum))
          Unit: milliseconds
          expr min lq mean median uq max neval
          for_sum 9.601222 10.261159 11.996525 10.774037 11.894962 30.56077 100
          double_sum 6.075801 6.678923 8.787946 7.373223 8.697266 21.37783 100
          mat_sum 7.809572 8.770058 13.766358 10.190758 18.500802 46.18336 100





          share|improve this answer


























          • Manually I checked, the second value of sum (for j=2) is 0.375. There is something wrong with the code.

            – Nasir Abbas
            Nov 21 '18 at 5:31











          • In Wolfram Mathematica I'm getting the same result, as in R. The exact value for j=2 is 5/8. Check the Wolfram|Alpha.

            – m0nhawk
            Nov 21 '18 at 16:10













          • Please, recheck your calculations, you took the square of each term, but you need to take the square of the whole inner sum. Here is the result for j=2: (1/2 + 1/4)^2 + (1/4)^2 = 5/8, and you calculated: (1/2)^2 + (1/4)^2 + (1/4)^2 = 3/8.

            – m0nhawk
            Nov 21 '18 at 16:41
















          4














          You can calculate this without any for loops:



          double_sum <- function(j) {
          sum(sapply(1:j, function(i) sum(1/i:j))^2) / j^2
          }


          And then calculate for each j:



          > sapply(1:50, outer_sum)
          [1] 1.00000000 0.62500000 0.46296296 0.36979167 0.30866667 0.26527778 0.23279883 0.20753348 0.18729669 0.17071032
          [11] 0.15686052 0.14511659 0.13502879 0.12626754 0.11858565 0.11179403 0.10574549 0.10032374 0.09543562 0.09100565
          [21] 0.08697198 0.08328344 0.07989737 0.07677785 0.07389447 0.07122127 0.06873600 0.06641942 0.06425487 0.06222779
          [31] 0.06032545 0.05853663 0.05685142 0.05526106 0.05375773 0.05233445 0.05098496 0.04970367 0.04848551 0.04732591
          [41] 0.04622074 0.04516625 0.04415901 0.04319591 0.04227410 0.04139098 0.04054415 0.03973142 0.03895077 0.03820032


          Or something strange (built upper triangle matrix for coefficient and then sum rows and results):



          mat_sum <- function(j) {
          d <- outer(rep(1, j), 1:j, FUN="/")
          d[lower.tri(d)] <- 0
          sum(rowSums(d)^2) / j^2
          }


          And benchmarks:



          > s <- 1:100
          > microbenchmark::microbenchmark(for_sum=sapply(s, sumfun), double_sum=sapply(s, double_sum), mat_sum=sapply(s, mat_sum))
          Unit: milliseconds
          expr min lq mean median uq max neval
          for_sum 9.601222 10.261159 11.996525 10.774037 11.894962 30.56077 100
          double_sum 6.075801 6.678923 8.787946 7.373223 8.697266 21.37783 100
          mat_sum 7.809572 8.770058 13.766358 10.190758 18.500802 46.18336 100





          share|improve this answer


























          • Manually I checked, the second value of sum (for j=2) is 0.375. There is something wrong with the code.

            – Nasir Abbas
            Nov 21 '18 at 5:31











          • In Wolfram Mathematica I'm getting the same result, as in R. The exact value for j=2 is 5/8. Check the Wolfram|Alpha.

            – m0nhawk
            Nov 21 '18 at 16:10













          • Please, recheck your calculations, you took the square of each term, but you need to take the square of the whole inner sum. Here is the result for j=2: (1/2 + 1/4)^2 + (1/4)^2 = 5/8, and you calculated: (1/2)^2 + (1/4)^2 + (1/4)^2 = 3/8.

            – m0nhawk
            Nov 21 '18 at 16:41














          4












          4








          4







          You can calculate this without any for loops:



          double_sum <- function(j) {
          sum(sapply(1:j, function(i) sum(1/i:j))^2) / j^2
          }


          And then calculate for each j:



          > sapply(1:50, outer_sum)
          [1] 1.00000000 0.62500000 0.46296296 0.36979167 0.30866667 0.26527778 0.23279883 0.20753348 0.18729669 0.17071032
          [11] 0.15686052 0.14511659 0.13502879 0.12626754 0.11858565 0.11179403 0.10574549 0.10032374 0.09543562 0.09100565
          [21] 0.08697198 0.08328344 0.07989737 0.07677785 0.07389447 0.07122127 0.06873600 0.06641942 0.06425487 0.06222779
          [31] 0.06032545 0.05853663 0.05685142 0.05526106 0.05375773 0.05233445 0.05098496 0.04970367 0.04848551 0.04732591
          [41] 0.04622074 0.04516625 0.04415901 0.04319591 0.04227410 0.04139098 0.04054415 0.03973142 0.03895077 0.03820032


          Or something strange (built upper triangle matrix for coefficient and then sum rows and results):



          mat_sum <- function(j) {
          d <- outer(rep(1, j), 1:j, FUN="/")
          d[lower.tri(d)] <- 0
          sum(rowSums(d)^2) / j^2
          }


          And benchmarks:



          > s <- 1:100
          > microbenchmark::microbenchmark(for_sum=sapply(s, sumfun), double_sum=sapply(s, double_sum), mat_sum=sapply(s, mat_sum))
          Unit: milliseconds
          expr min lq mean median uq max neval
          for_sum 9.601222 10.261159 11.996525 10.774037 11.894962 30.56077 100
          double_sum 6.075801 6.678923 8.787946 7.373223 8.697266 21.37783 100
          mat_sum 7.809572 8.770058 13.766358 10.190758 18.500802 46.18336 100





          share|improve this answer















          You can calculate this without any for loops:



          double_sum <- function(j) {
          sum(sapply(1:j, function(i) sum(1/i:j))^2) / j^2
          }


          And then calculate for each j:



          > sapply(1:50, outer_sum)
          [1] 1.00000000 0.62500000 0.46296296 0.36979167 0.30866667 0.26527778 0.23279883 0.20753348 0.18729669 0.17071032
          [11] 0.15686052 0.14511659 0.13502879 0.12626754 0.11858565 0.11179403 0.10574549 0.10032374 0.09543562 0.09100565
          [21] 0.08697198 0.08328344 0.07989737 0.07677785 0.07389447 0.07122127 0.06873600 0.06641942 0.06425487 0.06222779
          [31] 0.06032545 0.05853663 0.05685142 0.05526106 0.05375773 0.05233445 0.05098496 0.04970367 0.04848551 0.04732591
          [41] 0.04622074 0.04516625 0.04415901 0.04319591 0.04227410 0.04139098 0.04054415 0.03973142 0.03895077 0.03820032


          Or something strange (built upper triangle matrix for coefficient and then sum rows and results):



          mat_sum <- function(j) {
          d <- outer(rep(1, j), 1:j, FUN="/")
          d[lower.tri(d)] <- 0
          sum(rowSums(d)^2) / j^2
          }


          And benchmarks:



          > s <- 1:100
          > microbenchmark::microbenchmark(for_sum=sapply(s, sumfun), double_sum=sapply(s, double_sum), mat_sum=sapply(s, mat_sum))
          Unit: milliseconds
          expr min lq mean median uq max neval
          for_sum 9.601222 10.261159 11.996525 10.774037 11.894962 30.56077 100
          double_sum 6.075801 6.678923 8.787946 7.373223 8.697266 21.37783 100
          mat_sum 7.809572 8.770058 13.766358 10.190758 18.500802 46.18336 100






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 20 '18 at 19:19

























          answered Nov 20 '18 at 18:40









          m0nhawkm0nhawk

          15.6k83262




          15.6k83262













          • Manually I checked, the second value of sum (for j=2) is 0.375. There is something wrong with the code.

            – Nasir Abbas
            Nov 21 '18 at 5:31











          • In Wolfram Mathematica I'm getting the same result, as in R. The exact value for j=2 is 5/8. Check the Wolfram|Alpha.

            – m0nhawk
            Nov 21 '18 at 16:10













          • Please, recheck your calculations, you took the square of each term, but you need to take the square of the whole inner sum. Here is the result for j=2: (1/2 + 1/4)^2 + (1/4)^2 = 5/8, and you calculated: (1/2)^2 + (1/4)^2 + (1/4)^2 = 3/8.

            – m0nhawk
            Nov 21 '18 at 16:41



















          • Manually I checked, the second value of sum (for j=2) is 0.375. There is something wrong with the code.

            – Nasir Abbas
            Nov 21 '18 at 5:31











          • In Wolfram Mathematica I'm getting the same result, as in R. The exact value for j=2 is 5/8. Check the Wolfram|Alpha.

            – m0nhawk
            Nov 21 '18 at 16:10













          • Please, recheck your calculations, you took the square of each term, but you need to take the square of the whole inner sum. Here is the result for j=2: (1/2 + 1/4)^2 + (1/4)^2 = 5/8, and you calculated: (1/2)^2 + (1/4)^2 + (1/4)^2 = 3/8.

            – m0nhawk
            Nov 21 '18 at 16:41

















          Manually I checked, the second value of sum (for j=2) is 0.375. There is something wrong with the code.

          – Nasir Abbas
          Nov 21 '18 at 5:31





          Manually I checked, the second value of sum (for j=2) is 0.375. There is something wrong with the code.

          – Nasir Abbas
          Nov 21 '18 at 5:31













          In Wolfram Mathematica I'm getting the same result, as in R. The exact value for j=2 is 5/8. Check the Wolfram|Alpha.

          – m0nhawk
          Nov 21 '18 at 16:10







          In Wolfram Mathematica I'm getting the same result, as in R. The exact value for j=2 is 5/8. Check the Wolfram|Alpha.

          – m0nhawk
          Nov 21 '18 at 16:10















          Please, recheck your calculations, you took the square of each term, but you need to take the square of the whole inner sum. Here is the result for j=2: (1/2 + 1/4)^2 + (1/4)^2 = 5/8, and you calculated: (1/2)^2 + (1/4)^2 + (1/4)^2 = 3/8.

          – m0nhawk
          Nov 21 '18 at 16:41





          Please, recheck your calculations, you took the square of each term, but you need to take the square of the whole inner sum. Here is the result for j=2: (1/2 + 1/4)^2 + (1/4)^2 = 5/8, and you calculated: (1/2)^2 + (1/4)^2 + (1/4)^2 = 3/8.

          – m0nhawk
          Nov 21 '18 at 16:41













          2














          sumfun <- function(j) {
          res <- 0
          for(i in 1:j) {
          temp <- 0
          for(k in i:j) {
          temp <- temp + 1/(k*j)
          }
          res <- res + temp^2
          }
          return(res)
          }

          sapply(1:50, sumfun)





          [1] 1.00000000 0.62500000 0.46296296 0.36979167 0.30866667 0.26527778 0.23279883 0.20753348 0.18729669 0.17071032 0.15686052
          [12] 0.14511659 0.13502879 0.12626754 0.11858565 0.11179403 0.10574549 0.10032374 0.09543562 0.09100565 0.08697198 0.08328344
          [23] 0.07989737 0.07677785 0.07389447 0.07122127 0.06873600 0.06641942 0.06425487 0.06222779 0.06032545 0.05853663 0.05685142
          [34] 0.05526106 0.05375773 0.05233445 0.05098496 0.04970367 0.04848551 0.04732591 0.04622074 0.04516625 0.04415901 0.04319591
          [45] 0.04227410 0.04139098 0.04054415 0.03973142 0.03895077 0.03820032





          share|improve this answer


























          • Manually I checked, the second value of sum (for j=2) is 0.375. There is something wrong with the code.

            – Nasir Abbas
            Nov 21 '18 at 5:33











          • Check your work. The double sum for J=2 is (1/2 + 1/4)^2 + 1/4^2 = 10/16 = 0.625.

            – Dan Y
            Nov 21 '18 at 5:45
















          2














          sumfun <- function(j) {
          res <- 0
          for(i in 1:j) {
          temp <- 0
          for(k in i:j) {
          temp <- temp + 1/(k*j)
          }
          res <- res + temp^2
          }
          return(res)
          }

          sapply(1:50, sumfun)





          [1] 1.00000000 0.62500000 0.46296296 0.36979167 0.30866667 0.26527778 0.23279883 0.20753348 0.18729669 0.17071032 0.15686052
          [12] 0.14511659 0.13502879 0.12626754 0.11858565 0.11179403 0.10574549 0.10032374 0.09543562 0.09100565 0.08697198 0.08328344
          [23] 0.07989737 0.07677785 0.07389447 0.07122127 0.06873600 0.06641942 0.06425487 0.06222779 0.06032545 0.05853663 0.05685142
          [34] 0.05526106 0.05375773 0.05233445 0.05098496 0.04970367 0.04848551 0.04732591 0.04622074 0.04516625 0.04415901 0.04319591
          [45] 0.04227410 0.04139098 0.04054415 0.03973142 0.03895077 0.03820032





          share|improve this answer


























          • Manually I checked, the second value of sum (for j=2) is 0.375. There is something wrong with the code.

            – Nasir Abbas
            Nov 21 '18 at 5:33











          • Check your work. The double sum for J=2 is (1/2 + 1/4)^2 + 1/4^2 = 10/16 = 0.625.

            – Dan Y
            Nov 21 '18 at 5:45














          2












          2








          2







          sumfun <- function(j) {
          res <- 0
          for(i in 1:j) {
          temp <- 0
          for(k in i:j) {
          temp <- temp + 1/(k*j)
          }
          res <- res + temp^2
          }
          return(res)
          }

          sapply(1:50, sumfun)





          [1] 1.00000000 0.62500000 0.46296296 0.36979167 0.30866667 0.26527778 0.23279883 0.20753348 0.18729669 0.17071032 0.15686052
          [12] 0.14511659 0.13502879 0.12626754 0.11858565 0.11179403 0.10574549 0.10032374 0.09543562 0.09100565 0.08697198 0.08328344
          [23] 0.07989737 0.07677785 0.07389447 0.07122127 0.06873600 0.06641942 0.06425487 0.06222779 0.06032545 0.05853663 0.05685142
          [34] 0.05526106 0.05375773 0.05233445 0.05098496 0.04970367 0.04848551 0.04732591 0.04622074 0.04516625 0.04415901 0.04319591
          [45] 0.04227410 0.04139098 0.04054415 0.03973142 0.03895077 0.03820032





          share|improve this answer















          sumfun <- function(j) {
          res <- 0
          for(i in 1:j) {
          temp <- 0
          for(k in i:j) {
          temp <- temp + 1/(k*j)
          }
          res <- res + temp^2
          }
          return(res)
          }

          sapply(1:50, sumfun)





          [1] 1.00000000 0.62500000 0.46296296 0.36979167 0.30866667 0.26527778 0.23279883 0.20753348 0.18729669 0.17071032 0.15686052
          [12] 0.14511659 0.13502879 0.12626754 0.11858565 0.11179403 0.10574549 0.10032374 0.09543562 0.09100565 0.08697198 0.08328344
          [23] 0.07989737 0.07677785 0.07389447 0.07122127 0.06873600 0.06641942 0.06425487 0.06222779 0.06032545 0.05853663 0.05685142
          [34] 0.05526106 0.05375773 0.05233445 0.05098496 0.04970367 0.04848551 0.04732591 0.04622074 0.04516625 0.04415901 0.04319591
          [45] 0.04227410 0.04139098 0.04054415 0.03973142 0.03895077 0.03820032






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 20 '18 at 18:44

























          answered Nov 20 '18 at 18:32









          Dan YDan Y

          3,7211627




          3,7211627













          • Manually I checked, the second value of sum (for j=2) is 0.375. There is something wrong with the code.

            – Nasir Abbas
            Nov 21 '18 at 5:33











          • Check your work. The double sum for J=2 is (1/2 + 1/4)^2 + 1/4^2 = 10/16 = 0.625.

            – Dan Y
            Nov 21 '18 at 5:45



















          • Manually I checked, the second value of sum (for j=2) is 0.375. There is something wrong with the code.

            – Nasir Abbas
            Nov 21 '18 at 5:33











          • Check your work. The double sum for J=2 is (1/2 + 1/4)^2 + 1/4^2 = 10/16 = 0.625.

            – Dan Y
            Nov 21 '18 at 5:45

















          Manually I checked, the second value of sum (for j=2) is 0.375. There is something wrong with the code.

          – Nasir Abbas
          Nov 21 '18 at 5:33





          Manually I checked, the second value of sum (for j=2) is 0.375. There is something wrong with the code.

          – Nasir Abbas
          Nov 21 '18 at 5:33













          Check your work. The double sum for J=2 is (1/2 + 1/4)^2 + 1/4^2 = 10/16 = 0.625.

          – Dan Y
          Nov 21 '18 at 5:45





          Check your work. The double sum for J=2 is (1/2 + 1/4)^2 + 1/4^2 = 10/16 = 0.625.

          – Dan Y
          Nov 21 '18 at 5:45


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • 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%2fstackoverflow.com%2fquestions%2f53399150%2fsolve-a-double-summation-in-r%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

          Guess what letter conforming each word

          Port of Spain

          Run scheduled task as local user group (not BUILTIN)