Algorithm for Generating Percentage Amounts

  • Context: Undergrad 
  • Thread starter Thread starter natedgreat3
  • Start date Start date
  • Tags Tags
    Algorithm
Click For Summary

Discussion Overview

The discussion revolves around formulating an algorithm to generate percentage amounts for wedges in a pie chart, where each wedge is a specified percentage larger than the previous one, and the total must equal 100%. The focus includes mathematical reasoning and potential algorithmic approaches.

Discussion Character

  • Exploratory
  • Mathematical reasoning

Main Points Raised

  • One participant describes the problem of generating a pie chart with wedges that increase in size by a specified percentage, seeking a method to calculate the initial wedge size directly.
  • Another participant identifies that the sizes of the wedges form a geometric series, suggesting that this mathematical concept could be relevant to the solution.
  • A different participant points out that a geometric series does not inherently sum to a specific total, such as 100%, which is a requirement in this case.
  • One participant proposes a mathematical equation to express the relationship between the wedges and their sizes, indicating how to solve for the initial wedge size.
  • Another participant offers a numerical example using a starting wedge size of 1, demonstrating how to scale the sizes to achieve a total of 100%.

Areas of Agreement / Disagreement

Participants express differing views on the application of geometric series to the problem, with some agreeing on its relevance while others highlight its limitations in this specific context. The discussion remains unresolved regarding the most effective method to calculate the initial wedge size.

Contextual Notes

There are limitations in the assumptions made about the geometric series and its application to the problem, as well as the dependence on the specific percentage increase between wedges.

natedgreat3
Messages
3
Reaction score
0
Hey guys,

Not totally sure this thread belongs in this section, feel free to move.

I'm trying to formulate an algorithm for an unusual problem.

- Generate a pie chart with X number of wedges.
- Each wedge is X percentage bigger then the one before it.
- Percentage amounts of all wedges must add up to 100 (thereby completing the pie chart)

So for example, in Excel I can create a pie chart with 5 wedges, and each wedge is 20% bigger then the previous one. It gives me these numbers (rounded).

Wedge 1: 13.43797%
Wedge 2: 16.125564%
Wedge 3: 19.3506768%
Wedge 4: 23.22081216%
Wedge 5: 27.86497459%

But I got that result by trial and error of Wedge 1's value until the final output of the pie chart hit 100%. How do I calculate Wedge 1's value simply based off the number of wedges in the pie, and the percentage amounts from one wedge to the next?

I appreciate any help you guys can provide =]
 
Physics news on Phys.org
Okay cool, except a geometric series doesn't have to add up to a maximum amount, in this case 100% =/
 
That's where doing math comes in. If your starting wedge has a%, then you want
a + 1.2a + (1.2)2a + 1.23a + 1.24a = 100

Notice that 1.2 a is 20% larger than a, and 1.22a is 20% larger than 1.2a, etc. Now all you have to do is solve for a.
 
If you don't like algebra, suppose the first wedge is size 1.
You then have 5 wedges with sizes 1, 1.2, 1.44, 1.728, 2.0736 which add up to 7.4416
So you need to scale up the sizes by 100 / 7.4416 = 13.43797 - which is what you got by trial and error.
 
Thanks guys, you rock =]
 

Similar threads

  • · Replies 142 ·
5
Replies
142
Views
10K
  • · Replies 56 ·
2
Replies
56
Views
11K
Replies
9
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 30 ·
2
Replies
30
Views
7K