# X = p * y. Find x, y when both are as close to 1 as possible

1. Mar 20, 2015

### simplex1

Knowing that:

x = p * y where p = (0, 1] and x, y = (0, 2]

find x and y in such a way that both of them be as close as possible to 1 simultaneously.

I guess that the solution is x = 1/y = sqrt(p) but I do not know how to prove it.

2. Mar 20, 2015

### Staff: Mentor

What does p = (0, 1] mean? What does x, y = (0, 2] mean? Does the first one mean $x \in (0, 1]$?
Can you pick p = 1, and then let x = y = 1?

3. Mar 20, 2015

### simplex1

- Yes, x,y=(0,2] means x∈(0,2] and y∈(0,2].
- p is a given constant. In my specific case p = 0.457.

4. Mar 20, 2015

### Staff: Mentor

Since p is a constant, then for a given x value, the y value is y = x/p = x/.457 .
If you let w = (x - 1)2 + (x/.457 - 1)2, you're looking for the value of x that minimizes w.

Edited above to fix my earlier mistake.

Last edited: Mar 21, 2015
5. Mar 20, 2015

### simplex1

I believe it should be w(x) = (x - 1)^2 + (x/p - 1)^2 = minim which has the solution:
x = p(p+1)/(p^2+1)
It appears that x is not sqrt(p).

6. Mar 21, 2015

### Staff: Mentor

Yes, I switched p and x due to a silly mistake on my part. I have edited my earlier post.

7. Mar 21, 2015

### simplex1

I want now to minimize $w(x) = (x - 1)^2 + (y - 1)^2$ knowing that $px^3+qx^2y+rxy^2+ty^3=0$ but without solving the equation to obtain y as a function of x and then replace it in $w(x)$ because this appears to be impractical. Is it possible?

8. Mar 23, 2015

### HallsofIvy

Use "Lagrange multipliers". Since $w(x,y)= (x- 1)^2+ (y- 1)^2$, $\nabla w= 2(x- 1)\vec{i}+ 2(y- 1)\vec{j}$. Writing the constraint as $f(x,y)= px^3+ qx^2y+ rxy^2+ ty^3$, $\nabla f= (3px^2+ 2qxy+ ry^2)\vec{i}+ (qx^2+ 3rxy+ 3ty^3)\vec{j}$. At a max or min of w, with constraint f, those two gradient vectors must be parallel. That is, there must exist a number, $\lambda$ (the "Lagrange Multiplier") such that $2(x- 1)\vec{i}+ 2(y- 1)\vec{j}$$= \lambda[(3px^2+ 2qxy+ ry^2)\vec{i}+ (qx^2+ 3rxy+ 3ty^3)]\vec{j}$.

That gives the equations $2(x- 1)= \lambda (3px^2+ 2qxy+ ry^2)$ and $2(y- 1)= \lambda(qx^2+ 3rxy+ 3y^3)$ which, together with the constraint, give three equations to solve or x, y, and $\lambda$. Since a value for $\lambda$ is not part of the solution to this problem, I find that it is often simplest to first eliminate $\lambda$ by dividing one equation by the other. Dividing the first of those two equations by the second,
$$\frac{2(x- 1)}{2(y- 1}= \frac{3px^2+ 2qxy+ ry^2}{qx^2+ 2rxy+ 3ty^3}$$.

That is, of course, equivalent to $$(x- 1)(qx^2+ 2rxy+ 3ty^3)= (y- 1)(3px^2+ 2qxy+ ry^2)$$.

9. Mar 24, 2015

### simplex1

Yes, the method of Lagrange is a good idea because numeric solutions for x and y can be found with Mathcad if the parameters are known. Thank you all for your help.