How to solve for x and y to get x +y summation to reach maximum possible number?

110 Views Asked by At

Sorry if the tags are wrong

The goal here is to solve for x and y but x + y = 100 with no negative numbers. Where "max" is simply the maximum output possible.

To figure out the best ratio between x and y, ie 60/40, etc.

The below syntax is not right but will show what I am attempting

((((.04 * (59/(100+x)) / .6) * x) + ((.04 * (40/(100+y)) / .6) * y))) / 100 = max

As an example of what a ratio would look like of x being 60% of 100 and y being 40% of 100: (this is not the correct answer but just an example of what i mean by ratios of 100)

((((.04 * (59/(100+60)) / .6) * 60) + ((.04 * (40/(100+40)) / .6) * 40))) / 100 = 0.022369

But the goal here is to figure out, what x and y need to be to have the actual result be the highest number possible with x + y = 100

Some notes: the 100's, all 3, 59, 40, are unrelated to each over if that matters. All of the other hard coded numbers like .04, .6, etc. can also change depending on the formula. For instance the formula could change in other sequences to being ((((.04 * (59/(100+x)) / .6) * x) + ((.01 * (10/(120+y)) / .9) * y))) / 100 = max. This is a smaller part of an algorithm i am attempting to create where there can be more than 2 equations in one. In the above, there are technically 2 equations we are trying to combine to find the best dispersing of amounts.

1

There are 1 best solutions below

7
On BEST ANSWER

You want to maximize a function $$f(x,y)=\frac{1}{100}\left(\frac{0.04\cdot59x}{0.6(100+x)} + \frac{0.04\cdot40y}{0.6(100+y)}\right)$$ of two nonnegative variables $x$ and $y$ subject to $x+y=100$. Equivalently, maximize $$g(x)=f(x,100-x)=\frac{1}{100}\left(\frac{0.04\cdot59x}{0.6(100+x)} + \frac{0.04\cdot40(100-x)}{0.6(100+(100-x))}\right)$$ subject to $0 \le x \le 100$. This is a single-variable calculus problem. Differentiate, yielding $$g'(x)= \frac{19 x^2 - 31600 x + 1960000}{15(x + 100)^2 (200 - x)^2}.$$ Now solve $g'(x)=0$ by setting the numerator to $0$ and using the quadratic formula, yielding two values of $x$, only one of which is in the interval $[0,100]$. Examine the three critical points, including the end points $0$ and $100$. For the resulting optimal value $x^*$, which turns out to be approximately $64.529$, you can recover the corresponding optimal $y^*$ as $y^*=100-x^*$.