2

I realize that my title is not clear but I currently don't master math terms well enough to write a better title or to enter meaningful tags. Any correction to my question, tags and title would be very welcome and I hope to learn fast.

This is my problem: let

$$P_1 = 10$$

$$N = 5$$

$$H = 100$$

I calculate the values of the $P$ series from $P_2$ to $P_N$ like this:

$$P_k = X P_{k-1}$$

for $K$ going from $2$ to $N$ .

I am trying to find an $X$ so that $P_1 + P_2 + ... + P_N = H$ for known $P_1,N$ and $H$.

If I take $X \approx 1.35$, I get:

$$P_1 = 10.00$$

$$P_2 \approx 13.50$$

$$P_3 \approx 18.23$$

$$P_4 \approx 24.60$$

$$P_5 \approx 33.22$$

which gives a sum quite close to 100.

However, I had let $$X \approx 1.35$$ just because I knew that in that way, given those values of $P_1$ and $N$, the sum of all the elements of the $P$ series would be $\approx$ $H$ , which is the requirement.

So I'm trying to figure out how to calculate $X$ as a function of $P_1$, $N$ and $H$ such that the sum of all the resulting elements of the $P$ series is = $H$.

Glen_b
  • 2,273
  • Thanks for the downvote, but if you had written what was the issue I could have used that information to learn how to ask a better question, and maybe even to fix this one accordingly if that was possible. –  Oct 16 '15 at 15:07

2 Answers2

1

Let $P$ be your starting value, and $X$ be the ratio between elements.

The sum of the first $N$ elements is going to be:
$H = P+XP+X^2P+X^3P+...+X^{N-1}P$
We can then multiply by $X$ to increment the exponents:
$XH = XP+X^2P+...+X^NP$
Now almost every term is the same between these two, so we can cancel most of them by subtracting:
$H-XH = P - X^NP$
$H-P = XH-X^NP$

Plugging in your values for $H$, $P$, and $N$ should then leave you with a messy but calculable* polynomial for $X$.

*Finding a nice closed form gets complicated for $N>4$, but once you have a polynomial you can approximate it with Newton's method vel sim and get as much numerical precision as you need.

Draconis
  • 1,443
  • Solvable in what sense? – Glen_b Oct 17 '15 at 07:58
  • @Glen_b In the sense that, worst case, you can run Newton's method vel sim and get as close an answer as you need, since finding the derivative of a polynomial is much easier than the derivative of a lengthy series. Maybe "calculable" is a better term? – Draconis Oct 17 '15 at 08:13
  • Yes, I think so. The reason I asked you to be explicit is the OP may not know how to solve a general polynomial equation via iterative methods already. – Glen_b Oct 17 '15 at 08:23
  • @Glen_b A very good point. I added some elaboration to my answer to point them in the right direction. – Draconis Oct 17 '15 at 16:06
  • Thanks for walking me through the calculation steps, I was able to follow and that was a valuable process for me to learn how to approach similar problems. As @Glen_b correctly hypothesized I definitely do not know how to solve a general polynomial equation via iterative methods, but understanding the process that led there was very useful. – SantiBailors Oct 19 '15 at 11:51
0

It's possible to write the equation in terms of a polynomial equation, but above degree 4, you can't write explicit general solutions; there are iterative methods (start with a guess and repeatedly improve it) to get solutions of varying sophistication. One example is Newton's method, though there are other approaches more directly suited to solving polynomial equations.

Fortunately, if you only want a numerical solution you can nearly always get one easily in a spreadsheet like Excel or LibreOffice's Calc.

This is because your problem is directly analogous to an internal rate of return problem in finance. Here we treat it as if there were a constant sequence of payments which interest would increase in the geometric fashion you describe, and the rate of interest that made that worth the same as the required total (at the end of the sequence of payments) is one less than your $X$.

That is, if your first payment is $P_1$ and there are a total of $N$ payments which have to total $H$, put in a column $N-1$ rows with $P_1$ in it and one row with $P_1-H$ in it and then use the internal rate of return function IRR (or equivalent) in the spreadsheet, which returns one less than the $X$ value.

Here's an example done in Calc; Excel works in the same fashion:

enter image description here

The internal rate of return is 35.24% = 0.3524; this means your $X$ should be about 1.3524.

Neat, huh?

Glen_b
  • 2,273
  • Yes, neat ! Thanks a lot, also for the example in Calc. Although my P series is not payments you are right that this case comes from the financial field; it's just part of an automated trading system I'm helping to write on TradeStation platform, and the P values represent the amount of shares to trade in percentage of the initial capital (in a very few words); that's why their sum must be 100. I'm quite confident that TradeStation has the equivalent of the IRR function of Calc so I believe I can use your system directly. – SantiBailors Oct 19 '15 at 11:58