Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Maximum value of two variables

  1. Jan 23, 2015 #1
    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.

  2. jcsd
  3. Jan 23, 2015 #2


    User Avatar
    Staff Emeritus
    Science Advisor

    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 [tex]\frac{Y^2 cos(30)+ (K^2+ (X/2)^2)^{1/2}}{cos(30)}[/tex],
    the derivative with respect to X is [tex]\frac{X}{2cos(30)(\sqrt{K^2+ (X/2)^{1/2}})}[/tex] and the derivative with respect to Y is [tex]2Y[/tex].
  4. Jan 23, 2015 #3


    User Avatar
    Science Advisor

    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...
  5. Jan 23, 2015 #4
    Good point, sorry.
    I meant like the maximum of the sum of the two variables (biggest X + Y combination to satisfy the equation)

    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.
  6. Jan 23, 2015 #5


    User Avatar
    Science Advisor

    If you want to maximize y+x and you already have y = f(x), then define z = y + x = f(x) + x....
  7. Jan 23, 2015 #6

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


    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?
  8. Jan 23, 2015 #7


    User Avatar
    Science Advisor

    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.
  9. Jan 23, 2015 #8
    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.
  10. Jan 24, 2015 #9


    User Avatar
    Science Advisor

    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.
  11. Jan 24, 2015 #10
    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?
  12. Jan 24, 2015 #11


    User Avatar
    Science Advisor

    In what sense? Do you want to minimize Y - X or |Y - X| or...?
  13. Jan 24, 2015 #12
    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.
  14. Jan 24, 2015 #13


    User Avatar
    Science Advisor

    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...
  15. Jan 24, 2015 #14
    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...
  16. Jan 24, 2015 #15


    User Avatar
    Science Advisor

    Check your arithmetic! There are several errors here.
  17. Jan 24, 2015 #16
    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: Jan 24, 2015
  18. Jan 24, 2015 #17


    User Avatar
    Science Advisor

    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.
    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.
  19. Jan 24, 2015 #18
    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.
  20. Jan 24, 2015 #19
    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?
  21. Jan 24, 2015 #20


    User Avatar
    Science Advisor

    No. (Y - X) = - (X - Y) and (-a)2 = a2
    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.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: Maximum value of two variables
  1. Maximum value of f(r) (Replies: 5)

  2. Maximum mean value (Replies: 2)