When substitution runs out
You have 10 units to split between and and want to maximize the product . The constraint lets you eliminate a variable: , so you maximize , set the derivative to zero, and get with product 25.
That trick needs a constraint you can cleanly solve for one variable. On the circle , solving gives : two branches, a square root, and endpoints to check separately. A portfolio with 50 weights, a budget constraint and a return target is worse. You could solve for one weight, but the algebra buries the structure of the problem.
The unconstrained method from Optimization: Gradients, the Hessian and Gradient Descent sets and finds the top of the hill. With a constraint, the top of the hill is usually off limits. The best you can do is the highest point along the path you are forced to walk, and at that point is typically nonzero. We need a condition that holds at a constrained optimum and treats every variable the same way.