Capping part of a sum

80 Views Asked by At

I have a financial constraint which states that:

spend on x cannot exceed 15% of total spend, where spend on x is part of the sum of total spend, ie:

`total spend` = `spend on x` + `spend on y` + ...
but 
`spend on x` <= 15% * `total spend`

Given the total spend and spend on x, how could I calculate capped spend on x?

1

There are 1 best solutions below

0
On BEST ANSWER

If we start by calculating spend_on_other:

total_spend = spend_on_x + spend_other

therefore

 spend_on_other = total_spend - spend_on_x

Now we want to solve for capped_spend_on_x by assuming that spend_on_x is the maximum value (ie 15%), it follows that spend_on_other will be 85%. Since there is no cap on spend_on_other it follows that

capped_total_spend = capped_spend_on_x + spend_on_other

Given capped_total_spend is t,

t = 0.15t + spend_on_other

therefore

0.85t = spend_on_other

therefore

t = spend_on_other / 0.85

Having then the total capped_total_spend, we need only substitute

capped_spend_on_x = t * 0.15

therefore

capped_spend_on_x = (spend_on_other / 0.85) * 0.15

therefore

capped_spend_on_x = ((total_spend - spend_on_x) / 0.85) * 0.15