# Exponential function with a sum of 1

I have a problem where i have n-elements and the size of these elements must be 1 all together (sum), but they need to be exponentially sized. Lets say I have 5 elements, the first one needs to be 0.5, 2nd 0.25, 3rd 0.15, 4th 7, 5th 3 (the sizes should be proportionally distributed, but the first one should be 0.5).

I have tried to implement exponential decay, but how can I set it as a sum? Should I solve this problem in any other way...with exponential series?

I am a developer and I don't have an idea how to solve this math problem. The solution should look as a chart graph where the next bar is lower than the previous one, but they need to have a combined height of 1.

Help appreciated!

• After 2 years and 7 months (!!) being a member of this site I'd say it is about time to write mathematics properly... – DonAntonio Mar 6 '17 at 11:51
• Thanks for the comment, anyone can be a member...it doesn't imply that I need to master it. However I forgot many stuff... – box Mar 6 '17 at 11:54
• True...and the fact is you already got your answer and that's what matters. – DonAntonio Mar 6 '17 at 12:10

You can use a geometric series. Say you have a starting element $a$, then your terms are given by $ar^n$ for $n = 0,...,N-1$, where $N$ is the total number of elements. You then have that $$\sum\limits_{n=0}^{N-1}ar^n = \frac{a(r^N-1)}{r-1} = 1.$$ Given $N$, then solve for $r\in\mathbb{R}$.
Example. Let $a = 1/2$ be the starting element and $N = 5$. Then $$\frac12\frac{r^5-1}{r-1} = 1\quad\quad\implies\quad\quad r=0.518790...$$
Your terms are then $(1/2)\cdot (0.518790...)^n$ for $n = 0,...,4$, i.e. $$0.5,\quad 0.2593950318..., \quad 0.134571565..., \quad 0.06981439...,\quad 0.03621901...$$
• If your start element is $a$ and your total number of elements is $N$, then you simply need to solve $$\frac{a(r^N-1)}{r-1} = 1.$$ If $a$ and $N$ are given, then we only need to find $r$ and this should work in general. – Eff Mar 6 '17 at 12:06