# Maximum value of two variables

## Main Question or Discussion Point

I'm just doing some geometry and I can't remember how to find the maximum values of two variables in the same equation. Like, if you differentiate the equation partially for one, then again from the begining partially for the other and add them together or something.

The equation is something like (where C and K are constants)
[Y*cos(30) +(K^2 + (X/2)^2)^0.5] / cos(30) = C

It's been a long time since I did something like this, though simple it may be, I vaguly remember doing something similar for the maximum size of a rectangle or something.

Thanks

HallsofIvy
Homework Helper
Your question is not clear. You ask about "how to find the maximum values of two variables in the same equation" but I don't think that is what you want to do. I thing that what you want to do is to find the value of two variables in a function (not equation) that make the value of the function (not the variables) maximum.

To do that take the partial derivative of the function, with respect to the two variables, set them both equal to 0 and solve those two equations for the two variables, not "add them together".

In your example, I think the function you want to maximize is $$\frac{Y^2 cos(30)+ (K^2+ (X/2)^2)^{1/2}}{cos(30)}$$,
the derivative with respect to X is $$\frac{X}{2cos(30)(\sqrt{K^2+ (X/2)^{1/2}})}$$ and the derivative with respect to Y is $$2Y$$.

Svein
If C and K are constants, you have just a convoluted way of expressing y=f(x). If you want to maximize for y, just do it...

Your question is not clear. You ask about "how to find the maximum values of two variables in the same equation" but I don't think that is what you want to do.
If C and K are constants, you have just a convoluted way of expressing y=f(x). If you want to maximize for y, just do it...
Good point, sorry.
I meant like the maximum of the sum of the two variables (biggest X + Y combination to satisfy the equation)

In your example, I think the function you want to maximize is
Y2cos(30)+(K2+(X/2)2)1/2cos(30)​
\frac{Y^2 cos(30)+ (K^2+ (X/2)^2)^{1/2}}{cos(30)},
the derivative with respect to X is
X2cos(30)(K2+(X/2)1/2−−−−−−−−−−−−√)​
\frac{X}{2cos(30)(\sqrt{K^2+ (X/2)^{1/2}})} and the derivative with respect to Y is
2Y
That's great thanks, except there was no y^2, with that in mind, are you saying the maximum of of the equation is:
X/ [2cos(30)*((K^2+ (X/2)^(1/2))] = 0

Because y' = 0

I still can't remember though, so I've added them both together, is the sum of the partial derivitives still = 0
or is it equal to a the constant 'C'?
And how is this finding the values of the variables, under which they are at maximum values satisfying the equation.
Sorry I am SO rusty.

Svein
I meant like the maximum of the sum of the two variables (biggest X + Y combination to satisfy the equation)
If you want to maximize y+x and you already have y = f(x), then define z = y + x = f(x) + x....

If you want to maximize y+x and you already have y = f(x), then define z = y + x = f(x) + x...
So:

Y = [C - (K^2 + (X/2)^2)^0.5] / cos(30) ] / cos(30)

then

Z = [C - (K^2 + (X/2)^2)^0.5] / cos(30) ] / cos(30) + X
Then Z' = X/ [2cos(30)*((K^2+ (X/2)^(1/2))] + 1 = 0 ?

So then rearrange for X maximum value?

If so, then do I just put that value back into the original equation for Y's maximum value?

Svein
So then rearrange for X maximum value?

If so, then do I just put that value back into the original equation for Y's maximum value?
Well, solve for X and the calculate Y. You just maximized X + Y.

You keep getting back to solving for X and Y. But your function specifies that Y depends on X. Therefore you cannot look for the maximum of X and Y separately since, given X, the value of Y is also given.

You keep getting back to solving for X and Y. But your function specifies that Y depends on X. Therefore you cannot look for the maximum of X and Y separately since, given X, the value of Y is also given.
I wasn't the one that said it was Y = f(X), as far as I am concerned it is just an expression with two independant variables. Where the Left hand side has to equal the constant C. And I want X and Y to be fairly ballanced out, not just one big variable and one small one.

Svein
The equation is something like (where C and K are constants)
[Y*cos(30) +(K^2 + (X/2)^2)^0.5] / cos(30) = C
This equation sets up a relation between X and Y. If you choose X, then Y is given by the formula above. If you choose Y, then you get two values of X. Thus, X and Y are not independent.

Yes, that's true, although I did realise the implications of that, thanks for pointing out that I did misuse the term 'independent'. I should choose more clearly and carefully.
Is my question clear though now? You can choose a value for X or Y, so how do I calculate which value to choose for X or Y that will result in X and Y being closest to eachother?
Thanks

Svein
Is my question clear though now? You can choose a value for X or Y, so how do I calculate which value to choose for X or Y that will result in X and Y being closest to eachother?
In what sense? Do you want to minimize Y - X or |Y - X| or...?

In what sense? Do you want to minimize Y - X or |Y - X| or...?
Well I don't mind which is bigger, X or Y, but like if Z1 = X - Y or Z2 = Y - X, then Z1 or Z2 is as small as possible.
So if X and Y are on a seesaw they're as close as being ballanced as possible.

Svein
Well I don't mind which is bigger, X or Y, but like if Z1 = X - Y or Z2 = Y - X, then Z1 or Z2 is as small as possible.
So if X and Y are on a seesaw they're as close as being ballanced as possible.
Then I propose that you minimize (Y - X)2. So y - x = (C -(K^2 - (x/2)^2)^(0.5)/cos(30))/cos(30) -x.
Square it and observe that cos(30) = √3/2. Derive and set equal to zero...

Why (Y - X)2 and not (X - Y)2? I can't say I understand what you're getting at, but never the less:

(Y - X)2 = [(2C/√3) - √(K2-(X/2)2)*4/3]2 - X2

d[(Y - X)2] /dx = (4/3)2*2*X/2 - 2X = 0
= (16/9)X-2X = 0
which I don't think makes sense...

Svein
(Y - X)2 = [(2C/√3) - √(K2-(X/2)2)*4/3]2 - X2
Check your arithmetic! There are several errors here.

Check your arithmetic! There are several errors here.
All I really did was sub in for √3/2 for the two Cos, and then simplify so it became 4/3.
I'm not seeing my errors, sorry.

It would help if I understood the theory behind why we're taking the difference and squaring it.
As a simplified analogy. Say for instance you had a rectangle, and you had X and Y lengths and you wanted to find the closest you could make X and Y to make a shape of some constant surface area. Well we know intuitively that you can make X = Y and it will be a square, this is the same thing but it's a bit more complex so I don't know intutively what values of X and Y are the closest most ballenced values.

Last edited:
Svein
All I really did was sub in for √3/2 for the two Cos, and then simplify so it became 4/3.
I'm not seeing my errors, sorry.
y - x = (C -(K^2 - (x/2)^2)^(0.5)/cos(30))/cos(30) -x. Substitute Cos(30)=√3/2 and get y - x = C - √(K^2 - (x/2)^2))*2/√3 - x. Square that, and get
(y-x)^2 = (C - x)^2 -2(C-x)*√(K^2 - (x/2)^2))*2/√3 + (K^2 - (x/2)^2))*4/3. Multiply and reorder:
(y-x)^2 = (C^2 + 4(K^2)/3) - 2Cx + (4x^2)/3+ 2(C-x)√(K^2 - (x/2)^2))*2/√3. Now do the rest.
It would help if I understood the theory behind why we're taking the difference and squaring it.
Because you specified that you wanted to minimize the difference between Y and X. Now the difference between Y and X may be negative and a large negative number is a valid minimum. You could minimize |Y - X|, but this is troublesome mathematically. Minimizing the square of the difference is better mathematically and removes the problem with negative differences.

I see, I rearranged Y to be the wrong function in the first place, so:

[Y*cos(30) +(K^2 + (X/2)^2)^0.5] / cos(30) = C

Y = C - [√(K^2 + (X/2)^2) ] / cos(30) = C - 2*[√(K^2 + (X/2)^2) ] / √3

That's interesting, so you treated "C - X" as one term and expanded the right hand side as a perfect square? I didn't think to do that.
You still didn't answer me about : "Why (Y - X)2 and not (X - Y)2?" Is there no difference?

So back to your method, that product and chain rule is a nightmare:
d [(Y - X)2 ] /dx = -2C + 8X/3 - [2XC−4X^2+8k^2] / [√3*√(2k−X)*√(X+2k)] = 0

(I used a derivative calculator)

X = something too complicated for me to work out because of that nasty fraction...

At this point I think I'd be better off trying to plot curves of the equation graphically in Excel or something and find a cross over point or something to tell me the smallest difference between X and Y satisfying the expression.

I think I'd prefer to do away with all this and start again, say I had the equation 3X + Y = 100

same basic set-up, but a jolly lot simpler, so If I wanted to find the closest values of X and Y to eachother to satisfy the equation, how would I do it?
Cheers!!

Svein
Why (Y - X)2 and not (X - Y)2?" Is there no difference?
No. (Y - X) = - (X - Y) and (-a)2 = a2
I think I'd prefer to do away with all this and start again, say I had the equation 3X + Y = 100

same basic set-up, but a jolly lot simpler, so If I wanted to find the closest values of X and Y to eachother to satisfy the equation, how would I do it?
Cheers!!
Same procedure. Your equations says Y = 100 - 3X and you want to minimize (Y - X). (Y - X) = 100 - 4X. (Y - X)2 = 10000 - 800X + 16X2.
The derivative is -800 + 32X, giving X = 25 and therefore Y = 100 - 3X = 100 - 75 = 25.

No. (Y - X) = - (X - Y) and (-a)2 = a2
Ooh, so that's what you meant

Same procedure. Your equations says Y = 100 - 3X and you want to minimize (Y - X). (Y - X) = 100 - 4X. (Y - X)2 = 10000 - 800X + 16X2.
The derivative is -800 + 32X, giving X = 25 and therefore Y = 100 - 3X = 100 - 75 = 25
You're brilliant, thanks HEAPS.
I should have asked a simple version of the question like that in the first place!