How do I calculate the average interest rate for a dollar cost averaging investment?












0












$begingroup$


Say I invested $100 every month into the S&P 500 since January 2004. If I sold out on 2019-01-11 (not considering fees or dividends), I will have invested $18,100 and my investment would be worth $32,331.15.



How do I calculate my average yearly return (interest rate) on this investment?





What I've tried so far



My starting equation is
$$
totalValue = monthlyAmount cdot interest^{numYears} + monthlyAmount cdot interest^{numYears - 1/12} + dots + monthlyAmount cdot interest^{1/12}
$$



I can then extract $monthlyAmount$ to simplify the expression:



$$
totalValue = monthlyAmount cdot (interest^{numYears} + interest^{numYears - 1/12} + dots + interest^{1/12})
$$



The part in the parentheses, if I'm not mistaken, seems to be the sum of a geometric sequence - where both the first term and the common ratio is $interest^{1/12}$. If so, then I can use the formula for calculating the sum of the first $n$ terms of a geometric sequence:



$$
totalValue = monthlyAmount cdot frac{interest^{1/12} cdot (1-interest^{1/12})}{1-interest^{numYears}}
$$



Alright, given the values in the introduction, I have an equation with a single unknown - the $interest$:



$$
32331.15 = 100 cdot frac{interest^{1/12} cdot (1-interest^{1/12})}{1-interest^{15}}
$$



I gave this to WolframAlpha, and it gave me a solution of 1.074 (i.e. 7.4%). That's nice, but how do I arrive at the solution?



I'm writing a program that calculates this in the general case, so I'm ideally looking for some sort of algorithm that can be written in code.





Source of financial information: https://finance.yahoo.com/quote/%5EGSPC/history?p=%5EGSPC










share|cite|improve this question











$endgroup$












  • $begingroup$
    Hint: write it out as a sum involving the rate and note that you have a geometric series.
    $endgroup$
    – lulu
    Jan 22 at 23:04










  • $begingroup$
    @lulu No, because the stock price changes.
    $endgroup$
    – Acccumulation
    Jan 22 at 23:07










  • $begingroup$
    @Acccumulation Why does that matter? You are looking for a single rate $r$ which would match the return over the period.
    $endgroup$
    – lulu
    Jan 22 at 23:09










  • $begingroup$
    I'ver misread the problem a couple of times now, so let me state how I am currently reading it. I believe the OP is looking for the rate, $r$, such that a monthly investment of $100$ over $181$ periods would result in a total value of $32,331.15$ Thus, the first $100$ will have become $100times (1+frac r{12})^{181}$, the second will have grown to $100times (1+frac r{12})^{180}$ and so on. Is this what was intended?
    $endgroup$
    – lulu
    Jan 22 at 23:14












  • $begingroup$
    @lulu yes, that's what I meant. See my update for more information
    $endgroup$
    – Zoltán
    Jan 22 at 23:15
















0












$begingroup$


Say I invested $100 every month into the S&P 500 since January 2004. If I sold out on 2019-01-11 (not considering fees or dividends), I will have invested $18,100 and my investment would be worth $32,331.15.



How do I calculate my average yearly return (interest rate) on this investment?





What I've tried so far



My starting equation is
$$
totalValue = monthlyAmount cdot interest^{numYears} + monthlyAmount cdot interest^{numYears - 1/12} + dots + monthlyAmount cdot interest^{1/12}
$$



I can then extract $monthlyAmount$ to simplify the expression:



$$
totalValue = monthlyAmount cdot (interest^{numYears} + interest^{numYears - 1/12} + dots + interest^{1/12})
$$



The part in the parentheses, if I'm not mistaken, seems to be the sum of a geometric sequence - where both the first term and the common ratio is $interest^{1/12}$. If so, then I can use the formula for calculating the sum of the first $n$ terms of a geometric sequence:



$$
totalValue = monthlyAmount cdot frac{interest^{1/12} cdot (1-interest^{1/12})}{1-interest^{numYears}}
$$



Alright, given the values in the introduction, I have an equation with a single unknown - the $interest$:



$$
32331.15 = 100 cdot frac{interest^{1/12} cdot (1-interest^{1/12})}{1-interest^{15}}
$$



I gave this to WolframAlpha, and it gave me a solution of 1.074 (i.e. 7.4%). That's nice, but how do I arrive at the solution?



I'm writing a program that calculates this in the general case, so I'm ideally looking for some sort of algorithm that can be written in code.





Source of financial information: https://finance.yahoo.com/quote/%5EGSPC/history?p=%5EGSPC










share|cite|improve this question











$endgroup$












  • $begingroup$
    Hint: write it out as a sum involving the rate and note that you have a geometric series.
    $endgroup$
    – lulu
    Jan 22 at 23:04










  • $begingroup$
    @lulu No, because the stock price changes.
    $endgroup$
    – Acccumulation
    Jan 22 at 23:07










  • $begingroup$
    @Acccumulation Why does that matter? You are looking for a single rate $r$ which would match the return over the period.
    $endgroup$
    – lulu
    Jan 22 at 23:09










  • $begingroup$
    I'ver misread the problem a couple of times now, so let me state how I am currently reading it. I believe the OP is looking for the rate, $r$, such that a monthly investment of $100$ over $181$ periods would result in a total value of $32,331.15$ Thus, the first $100$ will have become $100times (1+frac r{12})^{181}$, the second will have grown to $100times (1+frac r{12})^{180}$ and so on. Is this what was intended?
    $endgroup$
    – lulu
    Jan 22 at 23:14












  • $begingroup$
    @lulu yes, that's what I meant. See my update for more information
    $endgroup$
    – Zoltán
    Jan 22 at 23:15














0












0








0





$begingroup$


Say I invested $100 every month into the S&P 500 since January 2004. If I sold out on 2019-01-11 (not considering fees or dividends), I will have invested $18,100 and my investment would be worth $32,331.15.



How do I calculate my average yearly return (interest rate) on this investment?





What I've tried so far



My starting equation is
$$
totalValue = monthlyAmount cdot interest^{numYears} + monthlyAmount cdot interest^{numYears - 1/12} + dots + monthlyAmount cdot interest^{1/12}
$$



I can then extract $monthlyAmount$ to simplify the expression:



$$
totalValue = monthlyAmount cdot (interest^{numYears} + interest^{numYears - 1/12} + dots + interest^{1/12})
$$



The part in the parentheses, if I'm not mistaken, seems to be the sum of a geometric sequence - where both the first term and the common ratio is $interest^{1/12}$. If so, then I can use the formula for calculating the sum of the first $n$ terms of a geometric sequence:



$$
totalValue = monthlyAmount cdot frac{interest^{1/12} cdot (1-interest^{1/12})}{1-interest^{numYears}}
$$



Alright, given the values in the introduction, I have an equation with a single unknown - the $interest$:



$$
32331.15 = 100 cdot frac{interest^{1/12} cdot (1-interest^{1/12})}{1-interest^{15}}
$$



I gave this to WolframAlpha, and it gave me a solution of 1.074 (i.e. 7.4%). That's nice, but how do I arrive at the solution?



I'm writing a program that calculates this in the general case, so I'm ideally looking for some sort of algorithm that can be written in code.





Source of financial information: https://finance.yahoo.com/quote/%5EGSPC/history?p=%5EGSPC










share|cite|improve this question











$endgroup$




Say I invested $100 every month into the S&P 500 since January 2004. If I sold out on 2019-01-11 (not considering fees or dividends), I will have invested $18,100 and my investment would be worth $32,331.15.



How do I calculate my average yearly return (interest rate) on this investment?





What I've tried so far



My starting equation is
$$
totalValue = monthlyAmount cdot interest^{numYears} + monthlyAmount cdot interest^{numYears - 1/12} + dots + monthlyAmount cdot interest^{1/12}
$$



I can then extract $monthlyAmount$ to simplify the expression:



$$
totalValue = monthlyAmount cdot (interest^{numYears} + interest^{numYears - 1/12} + dots + interest^{1/12})
$$



The part in the parentheses, if I'm not mistaken, seems to be the sum of a geometric sequence - where both the first term and the common ratio is $interest^{1/12}$. If so, then I can use the formula for calculating the sum of the first $n$ terms of a geometric sequence:



$$
totalValue = monthlyAmount cdot frac{interest^{1/12} cdot (1-interest^{1/12})}{1-interest^{numYears}}
$$



Alright, given the values in the introduction, I have an equation with a single unknown - the $interest$:



$$
32331.15 = 100 cdot frac{interest^{1/12} cdot (1-interest^{1/12})}{1-interest^{15}}
$$



I gave this to WolframAlpha, and it gave me a solution of 1.074 (i.e. 7.4%). That's nice, but how do I arrive at the solution?



I'm writing a program that calculates this in the general case, so I'm ideally looking for some sort of algorithm that can be written in code.





Source of financial information: https://finance.yahoo.com/quote/%5EGSPC/history?p=%5EGSPC







linear-algebra






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Jan 22 at 23:29







Zoltán

















asked Jan 22 at 22:57









ZoltánZoltán

1156




1156












  • $begingroup$
    Hint: write it out as a sum involving the rate and note that you have a geometric series.
    $endgroup$
    – lulu
    Jan 22 at 23:04










  • $begingroup$
    @lulu No, because the stock price changes.
    $endgroup$
    – Acccumulation
    Jan 22 at 23:07










  • $begingroup$
    @Acccumulation Why does that matter? You are looking for a single rate $r$ which would match the return over the period.
    $endgroup$
    – lulu
    Jan 22 at 23:09










  • $begingroup$
    I'ver misread the problem a couple of times now, so let me state how I am currently reading it. I believe the OP is looking for the rate, $r$, such that a monthly investment of $100$ over $181$ periods would result in a total value of $32,331.15$ Thus, the first $100$ will have become $100times (1+frac r{12})^{181}$, the second will have grown to $100times (1+frac r{12})^{180}$ and so on. Is this what was intended?
    $endgroup$
    – lulu
    Jan 22 at 23:14












  • $begingroup$
    @lulu yes, that's what I meant. See my update for more information
    $endgroup$
    – Zoltán
    Jan 22 at 23:15


















  • $begingroup$
    Hint: write it out as a sum involving the rate and note that you have a geometric series.
    $endgroup$
    – lulu
    Jan 22 at 23:04










  • $begingroup$
    @lulu No, because the stock price changes.
    $endgroup$
    – Acccumulation
    Jan 22 at 23:07










  • $begingroup$
    @Acccumulation Why does that matter? You are looking for a single rate $r$ which would match the return over the period.
    $endgroup$
    – lulu
    Jan 22 at 23:09










  • $begingroup$
    I'ver misread the problem a couple of times now, so let me state how I am currently reading it. I believe the OP is looking for the rate, $r$, such that a monthly investment of $100$ over $181$ periods would result in a total value of $32,331.15$ Thus, the first $100$ will have become $100times (1+frac r{12})^{181}$, the second will have grown to $100times (1+frac r{12})^{180}$ and so on. Is this what was intended?
    $endgroup$
    – lulu
    Jan 22 at 23:14












  • $begingroup$
    @lulu yes, that's what I meant. See my update for more information
    $endgroup$
    – Zoltán
    Jan 22 at 23:15
















$begingroup$
Hint: write it out as a sum involving the rate and note that you have a geometric series.
$endgroup$
– lulu
Jan 22 at 23:04




$begingroup$
Hint: write it out as a sum involving the rate and note that you have a geometric series.
$endgroup$
– lulu
Jan 22 at 23:04












$begingroup$
@lulu No, because the stock price changes.
$endgroup$
– Acccumulation
Jan 22 at 23:07




$begingroup$
@lulu No, because the stock price changes.
$endgroup$
– Acccumulation
Jan 22 at 23:07












$begingroup$
@Acccumulation Why does that matter? You are looking for a single rate $r$ which would match the return over the period.
$endgroup$
– lulu
Jan 22 at 23:09




$begingroup$
@Acccumulation Why does that matter? You are looking for a single rate $r$ which would match the return over the period.
$endgroup$
– lulu
Jan 22 at 23:09












$begingroup$
I'ver misread the problem a couple of times now, so let me state how I am currently reading it. I believe the OP is looking for the rate, $r$, such that a monthly investment of $100$ over $181$ periods would result in a total value of $32,331.15$ Thus, the first $100$ will have become $100times (1+frac r{12})^{181}$, the second will have grown to $100times (1+frac r{12})^{180}$ and so on. Is this what was intended?
$endgroup$
– lulu
Jan 22 at 23:14






$begingroup$
I'ver misread the problem a couple of times now, so let me state how I am currently reading it. I believe the OP is looking for the rate, $r$, such that a monthly investment of $100$ over $181$ periods would result in a total value of $32,331.15$ Thus, the first $100$ will have become $100times (1+frac r{12})^{181}$, the second will have grown to $100times (1+frac r{12})^{180}$ and so on. Is this what was intended?
$endgroup$
– lulu
Jan 22 at 23:14














$begingroup$
@lulu yes, that's what I meant. See my update for more information
$endgroup$
– Zoltán
Jan 22 at 23:15




$begingroup$
@lulu yes, that's what I meant. See my update for more information
$endgroup$
– Zoltán
Jan 22 at 23:15










2 Answers
2






active

oldest

votes


















1












$begingroup$

Trusting that the schedule of payments I outlined in the comments are correct, the problem comes down to the following: $$100times sum_{i=1}^{181}left(1+frac r{12}right)^i=32,311.15$$



Now, it's possible to evaluate that sum as a rational function, but as that leads to a polynomial of degree $182$ in $r$ you'll be stuck with numerical methods anyway. Instead, I'd leave the function as it stands and work numerically. A simple binary search converges rapidly and we get $$rapprox 7.056%$$






share|cite|improve this answer









$endgroup$





















    1












    $begingroup$

    Considering the general case, you want to solve for $x$ the equation
    $$k=frac TM=sum_{i=1}^n(1+x)^i=frac{(x+1) left((x+1)^n-1right)}{x}$$ where $T$ is the total value, $M$ the monthly amount, $n$ the number of months and $x$ the monthly interest.



    As lulu explained, you need some numerical method (Newton method would be the easiest).



    You can have good estimates of the solution considering that $x ll 1$. So, let us expand the summation as a Taylor series (or use the binomial theorem) and get
    $$k=n+frac{n (n+1)}{2} x+frac{(n-1)n(n+1)}{6} n x^2+Oleft(x^3right)$$



    Neglecting the higher order terms, you just face a quadratic equation in $x$ anf then
    $$x_0=frac{sqrt{24(n-1)n(n+1)k-3n^2(5 n^2-6 n-11) }-3n(n+1) } {2(n-1)n(n+1) }$$



    For your example, this would give as an estimate $x=0.00626955$ corresponding to $7.52$%. Newton iterates would be



    $$left(
    begin{array}{cc}
    n & x_n \
    0 & 0.0062695483 \
    1 & 0.0058852014 \
    2 & 0.0058753116 \
    3 & 0.0058753053
    end{array}
    right)$$
    and then the answer $7.050366$%.



    We could have a better estimate (still at the price of a quadratic equation in $x$) using, instead of Taylor series, a simple Padé approximant. This would give
    $$k=frac{n+frac{1}{10} left(n^2+13 nright) x+frac{1}{60} left(n^3+3 n^2+20 nright)
    x^2 } {1-frac{2}{5} (n-2) x+frac{1}{20} left(n^2-3 n+2right) x^2 }$$
    Applied to the example, this would give as an estimate $x=0.00587785$ corresponding to $7.053$%.



    Edit



    We can even avoid solving quadratic equations building at $x=0$ the $[1,p]$ Padé approximant of
    $$frac{(x+1) left((x+1)^n-1right)}{x}-k=frac{(k-n)+a_{(p)} x}{1+sum_{j=1}^p b_j x^j}implies x_{(p)}=frac{n-k}{a_{(p)} }$$



    For the simplest , the required coefficient is given by
    $$a_{(1)}=frac{1}{6} n (n+5)+frac{1}{3} k (n-1)$$
    $$a_{(2)}=frac{3 n^2 (n+3)+2 (n-1) n (n+4)k+ (n-2) (n-1)k^2 } {2 n (n+5)+4 (n-1)k }$$ The formula becomes really long for $p geq 3$ but they will be very easy to code.



    Applied to the example, this would give
    $$x_{(1)}approx 0.00568499implies 6.82198text{ %}$$
    $$x_{(2)}approx 0.00585822implies 7.02987text{ %}$$
    $$x_{(3)}approx 0.00587585implies 7.05102text{ %}$$
    $$x_{(4)}approx 0.00587561implies 7.05073text{ %}$$
    $$x_{(5)}approx 0.00587532implies 7.05039text{ %}$$






    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%2f3083834%2fhow-do-i-calculate-the-average-interest-rate-for-a-dollar-cost-averaging-investm%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












      $begingroup$

      Trusting that the schedule of payments I outlined in the comments are correct, the problem comes down to the following: $$100times sum_{i=1}^{181}left(1+frac r{12}right)^i=32,311.15$$



      Now, it's possible to evaluate that sum as a rational function, but as that leads to a polynomial of degree $182$ in $r$ you'll be stuck with numerical methods anyway. Instead, I'd leave the function as it stands and work numerically. A simple binary search converges rapidly and we get $$rapprox 7.056%$$






      share|cite|improve this answer









      $endgroup$


















        1












        $begingroup$

        Trusting that the schedule of payments I outlined in the comments are correct, the problem comes down to the following: $$100times sum_{i=1}^{181}left(1+frac r{12}right)^i=32,311.15$$



        Now, it's possible to evaluate that sum as a rational function, but as that leads to a polynomial of degree $182$ in $r$ you'll be stuck with numerical methods anyway. Instead, I'd leave the function as it stands and work numerically. A simple binary search converges rapidly and we get $$rapprox 7.056%$$






        share|cite|improve this answer









        $endgroup$
















          1












          1








          1





          $begingroup$

          Trusting that the schedule of payments I outlined in the comments are correct, the problem comes down to the following: $$100times sum_{i=1}^{181}left(1+frac r{12}right)^i=32,311.15$$



          Now, it's possible to evaluate that sum as a rational function, but as that leads to a polynomial of degree $182$ in $r$ you'll be stuck with numerical methods anyway. Instead, I'd leave the function as it stands and work numerically. A simple binary search converges rapidly and we get $$rapprox 7.056%$$






          share|cite|improve this answer









          $endgroup$



          Trusting that the schedule of payments I outlined in the comments are correct, the problem comes down to the following: $$100times sum_{i=1}^{181}left(1+frac r{12}right)^i=32,311.15$$



          Now, it's possible to evaluate that sum as a rational function, but as that leads to a polynomial of degree $182$ in $r$ you'll be stuck with numerical methods anyway. Instead, I'd leave the function as it stands and work numerically. A simple binary search converges rapidly and we get $$rapprox 7.056%$$







          share|cite|improve this answer












          share|cite|improve this answer



          share|cite|improve this answer










          answered Jan 23 at 1:03









          lulululu

          42.9k25080




          42.9k25080























              1












              $begingroup$

              Considering the general case, you want to solve for $x$ the equation
              $$k=frac TM=sum_{i=1}^n(1+x)^i=frac{(x+1) left((x+1)^n-1right)}{x}$$ where $T$ is the total value, $M$ the monthly amount, $n$ the number of months and $x$ the monthly interest.



              As lulu explained, you need some numerical method (Newton method would be the easiest).



              You can have good estimates of the solution considering that $x ll 1$. So, let us expand the summation as a Taylor series (or use the binomial theorem) and get
              $$k=n+frac{n (n+1)}{2} x+frac{(n-1)n(n+1)}{6} n x^2+Oleft(x^3right)$$



              Neglecting the higher order terms, you just face a quadratic equation in $x$ anf then
              $$x_0=frac{sqrt{24(n-1)n(n+1)k-3n^2(5 n^2-6 n-11) }-3n(n+1) } {2(n-1)n(n+1) }$$



              For your example, this would give as an estimate $x=0.00626955$ corresponding to $7.52$%. Newton iterates would be



              $$left(
              begin{array}{cc}
              n & x_n \
              0 & 0.0062695483 \
              1 & 0.0058852014 \
              2 & 0.0058753116 \
              3 & 0.0058753053
              end{array}
              right)$$
              and then the answer $7.050366$%.



              We could have a better estimate (still at the price of a quadratic equation in $x$) using, instead of Taylor series, a simple Padé approximant. This would give
              $$k=frac{n+frac{1}{10} left(n^2+13 nright) x+frac{1}{60} left(n^3+3 n^2+20 nright)
              x^2 } {1-frac{2}{5} (n-2) x+frac{1}{20} left(n^2-3 n+2right) x^2 }$$
              Applied to the example, this would give as an estimate $x=0.00587785$ corresponding to $7.053$%.



              Edit



              We can even avoid solving quadratic equations building at $x=0$ the $[1,p]$ Padé approximant of
              $$frac{(x+1) left((x+1)^n-1right)}{x}-k=frac{(k-n)+a_{(p)} x}{1+sum_{j=1}^p b_j x^j}implies x_{(p)}=frac{n-k}{a_{(p)} }$$



              For the simplest , the required coefficient is given by
              $$a_{(1)}=frac{1}{6} n (n+5)+frac{1}{3} k (n-1)$$
              $$a_{(2)}=frac{3 n^2 (n+3)+2 (n-1) n (n+4)k+ (n-2) (n-1)k^2 } {2 n (n+5)+4 (n-1)k }$$ The formula becomes really long for $p geq 3$ but they will be very easy to code.



              Applied to the example, this would give
              $$x_{(1)}approx 0.00568499implies 6.82198text{ %}$$
              $$x_{(2)}approx 0.00585822implies 7.02987text{ %}$$
              $$x_{(3)}approx 0.00587585implies 7.05102text{ %}$$
              $$x_{(4)}approx 0.00587561implies 7.05073text{ %}$$
              $$x_{(5)}approx 0.00587532implies 7.05039text{ %}$$






              share|cite|improve this answer











              $endgroup$


















                1












                $begingroup$

                Considering the general case, you want to solve for $x$ the equation
                $$k=frac TM=sum_{i=1}^n(1+x)^i=frac{(x+1) left((x+1)^n-1right)}{x}$$ where $T$ is the total value, $M$ the monthly amount, $n$ the number of months and $x$ the monthly interest.



                As lulu explained, you need some numerical method (Newton method would be the easiest).



                You can have good estimates of the solution considering that $x ll 1$. So, let us expand the summation as a Taylor series (or use the binomial theorem) and get
                $$k=n+frac{n (n+1)}{2} x+frac{(n-1)n(n+1)}{6} n x^2+Oleft(x^3right)$$



                Neglecting the higher order terms, you just face a quadratic equation in $x$ anf then
                $$x_0=frac{sqrt{24(n-1)n(n+1)k-3n^2(5 n^2-6 n-11) }-3n(n+1) } {2(n-1)n(n+1) }$$



                For your example, this would give as an estimate $x=0.00626955$ corresponding to $7.52$%. Newton iterates would be



                $$left(
                begin{array}{cc}
                n & x_n \
                0 & 0.0062695483 \
                1 & 0.0058852014 \
                2 & 0.0058753116 \
                3 & 0.0058753053
                end{array}
                right)$$
                and then the answer $7.050366$%.



                We could have a better estimate (still at the price of a quadratic equation in $x$) using, instead of Taylor series, a simple Padé approximant. This would give
                $$k=frac{n+frac{1}{10} left(n^2+13 nright) x+frac{1}{60} left(n^3+3 n^2+20 nright)
                x^2 } {1-frac{2}{5} (n-2) x+frac{1}{20} left(n^2-3 n+2right) x^2 }$$
                Applied to the example, this would give as an estimate $x=0.00587785$ corresponding to $7.053$%.



                Edit



                We can even avoid solving quadratic equations building at $x=0$ the $[1,p]$ Padé approximant of
                $$frac{(x+1) left((x+1)^n-1right)}{x}-k=frac{(k-n)+a_{(p)} x}{1+sum_{j=1}^p b_j x^j}implies x_{(p)}=frac{n-k}{a_{(p)} }$$



                For the simplest , the required coefficient is given by
                $$a_{(1)}=frac{1}{6} n (n+5)+frac{1}{3} k (n-1)$$
                $$a_{(2)}=frac{3 n^2 (n+3)+2 (n-1) n (n+4)k+ (n-2) (n-1)k^2 } {2 n (n+5)+4 (n-1)k }$$ The formula becomes really long for $p geq 3$ but they will be very easy to code.



                Applied to the example, this would give
                $$x_{(1)}approx 0.00568499implies 6.82198text{ %}$$
                $$x_{(2)}approx 0.00585822implies 7.02987text{ %}$$
                $$x_{(3)}approx 0.00587585implies 7.05102text{ %}$$
                $$x_{(4)}approx 0.00587561implies 7.05073text{ %}$$
                $$x_{(5)}approx 0.00587532implies 7.05039text{ %}$$






                share|cite|improve this answer











                $endgroup$
















                  1












                  1








                  1





                  $begingroup$

                  Considering the general case, you want to solve for $x$ the equation
                  $$k=frac TM=sum_{i=1}^n(1+x)^i=frac{(x+1) left((x+1)^n-1right)}{x}$$ where $T$ is the total value, $M$ the monthly amount, $n$ the number of months and $x$ the monthly interest.



                  As lulu explained, you need some numerical method (Newton method would be the easiest).



                  You can have good estimates of the solution considering that $x ll 1$. So, let us expand the summation as a Taylor series (or use the binomial theorem) and get
                  $$k=n+frac{n (n+1)}{2} x+frac{(n-1)n(n+1)}{6} n x^2+Oleft(x^3right)$$



                  Neglecting the higher order terms, you just face a quadratic equation in $x$ anf then
                  $$x_0=frac{sqrt{24(n-1)n(n+1)k-3n^2(5 n^2-6 n-11) }-3n(n+1) } {2(n-1)n(n+1) }$$



                  For your example, this would give as an estimate $x=0.00626955$ corresponding to $7.52$%. Newton iterates would be



                  $$left(
                  begin{array}{cc}
                  n & x_n \
                  0 & 0.0062695483 \
                  1 & 0.0058852014 \
                  2 & 0.0058753116 \
                  3 & 0.0058753053
                  end{array}
                  right)$$
                  and then the answer $7.050366$%.



                  We could have a better estimate (still at the price of a quadratic equation in $x$) using, instead of Taylor series, a simple Padé approximant. This would give
                  $$k=frac{n+frac{1}{10} left(n^2+13 nright) x+frac{1}{60} left(n^3+3 n^2+20 nright)
                  x^2 } {1-frac{2}{5} (n-2) x+frac{1}{20} left(n^2-3 n+2right) x^2 }$$
                  Applied to the example, this would give as an estimate $x=0.00587785$ corresponding to $7.053$%.



                  Edit



                  We can even avoid solving quadratic equations building at $x=0$ the $[1,p]$ Padé approximant of
                  $$frac{(x+1) left((x+1)^n-1right)}{x}-k=frac{(k-n)+a_{(p)} x}{1+sum_{j=1}^p b_j x^j}implies x_{(p)}=frac{n-k}{a_{(p)} }$$



                  For the simplest , the required coefficient is given by
                  $$a_{(1)}=frac{1}{6} n (n+5)+frac{1}{3} k (n-1)$$
                  $$a_{(2)}=frac{3 n^2 (n+3)+2 (n-1) n (n+4)k+ (n-2) (n-1)k^2 } {2 n (n+5)+4 (n-1)k }$$ The formula becomes really long for $p geq 3$ but they will be very easy to code.



                  Applied to the example, this would give
                  $$x_{(1)}approx 0.00568499implies 6.82198text{ %}$$
                  $$x_{(2)}approx 0.00585822implies 7.02987text{ %}$$
                  $$x_{(3)}approx 0.00587585implies 7.05102text{ %}$$
                  $$x_{(4)}approx 0.00587561implies 7.05073text{ %}$$
                  $$x_{(5)}approx 0.00587532implies 7.05039text{ %}$$






                  share|cite|improve this answer











                  $endgroup$



                  Considering the general case, you want to solve for $x$ the equation
                  $$k=frac TM=sum_{i=1}^n(1+x)^i=frac{(x+1) left((x+1)^n-1right)}{x}$$ where $T$ is the total value, $M$ the monthly amount, $n$ the number of months and $x$ the monthly interest.



                  As lulu explained, you need some numerical method (Newton method would be the easiest).



                  You can have good estimates of the solution considering that $x ll 1$. So, let us expand the summation as a Taylor series (or use the binomial theorem) and get
                  $$k=n+frac{n (n+1)}{2} x+frac{(n-1)n(n+1)}{6} n x^2+Oleft(x^3right)$$



                  Neglecting the higher order terms, you just face a quadratic equation in $x$ anf then
                  $$x_0=frac{sqrt{24(n-1)n(n+1)k-3n^2(5 n^2-6 n-11) }-3n(n+1) } {2(n-1)n(n+1) }$$



                  For your example, this would give as an estimate $x=0.00626955$ corresponding to $7.52$%. Newton iterates would be



                  $$left(
                  begin{array}{cc}
                  n & x_n \
                  0 & 0.0062695483 \
                  1 & 0.0058852014 \
                  2 & 0.0058753116 \
                  3 & 0.0058753053
                  end{array}
                  right)$$
                  and then the answer $7.050366$%.



                  We could have a better estimate (still at the price of a quadratic equation in $x$) using, instead of Taylor series, a simple Padé approximant. This would give
                  $$k=frac{n+frac{1}{10} left(n^2+13 nright) x+frac{1}{60} left(n^3+3 n^2+20 nright)
                  x^2 } {1-frac{2}{5} (n-2) x+frac{1}{20} left(n^2-3 n+2right) x^2 }$$
                  Applied to the example, this would give as an estimate $x=0.00587785$ corresponding to $7.053$%.



                  Edit



                  We can even avoid solving quadratic equations building at $x=0$ the $[1,p]$ Padé approximant of
                  $$frac{(x+1) left((x+1)^n-1right)}{x}-k=frac{(k-n)+a_{(p)} x}{1+sum_{j=1}^p b_j x^j}implies x_{(p)}=frac{n-k}{a_{(p)} }$$



                  For the simplest , the required coefficient is given by
                  $$a_{(1)}=frac{1}{6} n (n+5)+frac{1}{3} k (n-1)$$
                  $$a_{(2)}=frac{3 n^2 (n+3)+2 (n-1) n (n+4)k+ (n-2) (n-1)k^2 } {2 n (n+5)+4 (n-1)k }$$ The formula becomes really long for $p geq 3$ but they will be very easy to code.



                  Applied to the example, this would give
                  $$x_{(1)}approx 0.00568499implies 6.82198text{ %}$$
                  $$x_{(2)}approx 0.00585822implies 7.02987text{ %}$$
                  $$x_{(3)}approx 0.00587585implies 7.05102text{ %}$$
                  $$x_{(4)}approx 0.00587561implies 7.05073text{ %}$$
                  $$x_{(5)}approx 0.00587532implies 7.05039text{ %}$$







                  share|cite|improve this answer














                  share|cite|improve this answer



                  share|cite|improve this answer








                  edited Jan 24 at 7:33

























                  answered Jan 23 at 6:24









                  Claude LeiboviciClaude Leibovici

                  124k1157135




                  124k1157135






























                      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%2f3083834%2fhow-do-i-calculate-the-average-interest-rate-for-a-dollar-cost-averaging-investm%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

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

                      How to fix TextFormField cause rebuild widget in Flutter