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