Wikipedia:Reference desk/Archives/Mathematics/2014 June 10

= June 10 =

constrained ratios
As you know, Bob, the continued fraction expression of a real number x provides a sequence of "best" rational approximations $$a_i/b_i$$ to x, in the sense that if you cut off the CF at i steps the resulting approximation cannot be improved with smaller integers. But the problem that interests me at the moment requires $$a_i$$ to be odd and $$b_i$$ even. Does the sequence include all the "best" constrained ratios? (I would guess not.) If not, is there an efficient algo that does list them? —Tamfang (talk) 05:35, 10 June 2014 (UTC)


 * Try searching Stern–Brocot tree. I don't know how fast it could be, anyway the tree contains all rationals, so eventually you will find your number in it. --CiaPan (talk) 07:11, 11 June 2014 (UTC)

Maximizing an implicit equation
It's a rather simple problem: Given $$y^2=x-2x^2y$$, find (x,y) that maximizes the value of y. I solved it by using the quadratic formula to solve for y and then taking the derivative with respect to x, leading to the answer x=y=1/2. It was very cumbersome.

But I noticed that finding the derivative implicitly rather than explicitly leads to $$\frac{dy}{dx}=-\frac{4xy-1}{2y+2x^2}$$ from which it follows that I could solve the system of equations $$y^2=x-2x^2y, 4xy=1$$. Would this latter method be the preferred way to solve problems of this kind?--Jasper Deng (talk) 07:03, 10 June 2014 (UTC)
 * You seem to prefer it :) If you have a constrained maximisation / minimisation problem, my favourite way of solving it is to use generalized coordinates that automatically make you satisfy the constraint. If that is not easy or not possible, the next best thing in general is to use Lagrange multipliers. In your example, I don't see a good way to find generalised coordinates that work, and as the function that you want to maximise is so simple, your method is faster than using Lagrange multipliers. But if you want to find the (x,y) that maximises x+y^2, Lagrange multipliers are the way to go. —Kusma (t·c) 08:35, 10 June 2014 (UTC)
 * I thought about Lagrange multipliers, but I don't find them useful for functions that are simply from R to R rather than R2 (and up) to R; y is of course the former case, even if implicit. I thought that I could maybe get away with turning this into a constrained optimization problem using the constraint from the implicit differentiation above, but I'd think that's a dangerous thing to do as applying Lagrange multipliers could lead to phony critical points.--Jasper Deng (talk) 08:37, 10 June 2014 (UTC)
 * I don't see how Lagrange multipliers can lead to phony critical points (do you mean critical points that are not minimisers / maximisers? That can happen in any optimisation problem, and is not made worse by Lagrange multipliers). In your case, they are easy: Set $$F(x,y,\lambda)=y+\lambda(y^2-x+2x^2y)$$, take derivatives with respect to x and y, use the constraint, find $$x=y=\frac12,\lambda=2$$ as the only solution of $$\frac{\partial F}{\partial x}=\frac{\partial F}{\partial y}=\frac{\partial F}{\partial \lambda}=0$$. —Kusma (t·c) 09:13, 10 June 2014 (UTC)
 * Yes, I kinda mean critical points that aren't extrema; it wouldn't be a problem with the method of Lagrange multipliers, but with my proposed constraint $$4xy=1$$ above.--Jasper Deng (talk) 17:27, 10 June 2014 (UTC)

In your problem, you are maximizing the function y subject to the constraint y^2-x+2x^2y=0. An approach to the general problem of constrained optimization which is more in the spirit of the implicit function approach to the problem is to use differentials systematically. To maximize a function f(x,y) subject to a constraint g(x,y)=0, you want to solve the equation df=0 for all infinitely small displacements (dx,dy) that lie on the constraint surface dg=0. If you do this in your example, you recover exactly your approach (this is how implicit differentiation works). Sławomir Biały (talk) 18:25, 10 June 2014 (UTC)
 * For any y you have a quadratic equation in x. Assuming there is a maximal y for which there is a solution for x, with this y you have exactly one solution. So the discriminant, which is $$b^2-4ac=1-8y^3$$, must be 0. So $$y=1/2$$ and then you can find $$x=1/2$$. -- Meni Rosenfeld (talk) 13:54, 16 June 2014 (UTC)

I view this sort of question as finding the algebraic curve $$f(x,y) = x-2x^2 y-y^2 = 0$$. The normal to the curve is $$\left(\frac{\partial f}{\partial x},\frac{\partial f}{\partial y}\right)$$ and when $$\frac{\partial f}{\partial x}=0$$ the tangent is horizontal and you have a turning point. Here $$\frac{\partial f}{\partial x}=1-4 x y$$ intersection of that curve with $$f(x,y)$$ gives the critical point as above. Similar you can find the intersection with $$\frac{\partial f}{\partial y}=-2 x^2-2 y=0$$ to find the two other turning points.--Salix alba (talk): 16:27, 16 June 2014 (UTC)