# Parametric minimization of a quadratic expression in two variables

I am not an expert in using Mathematica, and I do not understand the following result (apologies if it appears trivial). I want to find the general solution to minimize the following expression over $$x$$ and $$y$$, where $$a, b, c, d, e$$ are real parameters:

$$a x^2+ b y^2 - c x - d y + e x y\,.$$

With the command Minimize[a*x^2+b*y^2-c*x-d*y+e*x*y, {x,y}] I obtain the following solution: when no parameter is null and the solution exists, the minimum is (d (a d - c e) + b c^2)/(e^2 - 4 a b) and is achieved if

{{x, y} ->
ConditionalExpression[{x, y},
b == (a d^2)/c^2 \[Or] 4 b == e^2/a \[Or]
c^2/(a d) == 2 ((c x)/d + y) \[Or] (2 a d)/c == e \[Or]
x == (2 b c)/(4 a b - e^2) \[Or] x == (d e)/(e^2 - 4 a b) \[Or]
2 x == c/a \[Or] y == -((2 a d)/(e^2 - 4 a b)) \[Or]
y == (c e)/(e^2 - 4 a b) \[Or] y == -((2 a x)/e) \[Or]
2 y == d/b]}


Then, if for instance I try to minimize the above expression by setting the parameters with the command Set[{a, b, c, d, e}, {38, 41, 32, 94, 46}], I obtain

(-(59846/1029)  {x->-(425/1029),y->1418/1029})


Hence, the formula (d (a d-c e)+b c^2)/(e^2-4 a b) provided by Minimize looks correct. However, I am interested also in finding the values of $$x$$ and $$y$$ minimizing this expression, and I do not understand how to find them from the ConditionalExpression of the solution provided by the command Minimize[a*x^2+b*y^2-c*x-d*y+e*x*y, {x,y}].

Question: How can I find the parametric formulas in $$a,b,c,d,e$$ for finding the two values $$x$$ and $$y$$ minimizing the general parametric expression (to quickly calculate for instance x->-(425/1029),y->1418/1029 in the above example)?

• Did you try f[a_, b_, c_, d_, e_] := Minimize[a*x^2 + b*y^2 - c*x - d*y + e*x*y, {x, y}] and then f[38, 41, 32, 94, 46]? May 6 at 15:18

Use a replacement rule to replace explicit values of the parameters in the general conditional solution returned by Maximize:

sol = Minimize[a*x^2 + b*y^2 - c*x - d*y + e*x*y, {x, y}];
sol /. Thread[{a, b, c, d, e} -> {38, 41, 32, 94, 46}]

(* Out: {-(59846/1029), {x -> -(425/1029), y -> 1418/1029}}


You don't have to use Thread there; it was just for convenience. You could write out each value independently:

sol /. {a -> 38, b -> 41, c -> 32, d -> 94, e -> 46}


with the same results.

You seek a single, general expression for the values of $$x$$ and $$y$$ that minimize your expression, as a function of the parameters $$a,b,c,d,e$$. What the output of Minimize is telling you is, that expression is NOT UNIQUE and it may change depending on the values of the parameters themselves. The best approximation is already there in your results though. We can simplify it a bit using Simplify and explicitly adding your assumptions of non-zero values for the parameters to Minimize as well. Since you care for the values of $$(x,y)$$ at minimum, rather than an expression of the value of that minimum, then we can use ArgMin instead of Minimize, just to simplify the output:

Simplify[
ArgMin[
{
a*x^2 + b*y^2 - c*x - d*y + e*x*y,
a != 0, b != 0, c != 0, d != 0, e != 0
}, {x, y}
],
{a != 0, b != 0, c != 0, d != 0, e != 0}
]


As you can see, the answer depends on specific values of the parameters. However, to go out on a limb, it seems that the most general expressions would be the following, which you can manually extract from the Piecewise expressions:

{
x -> (2 b c - d e)/(4 a b - e^2),
y-> (2 a d - c e)/(4 a b - e^2)
}

• Thank you for your answer, I appreciate it. However, I need to "find the parametric formulas in $a,b,c,d,e$ for finding the two values $x$ and $y$ minimizing the general parametric expression" as I asked in my question. I will use them into a Python code to quickly calculate minimizers of thousands of different expressions of that kind, as part of a Python algorithm. Hence, I really need the obtain explicit formulas for the minimizers for $x$ and $y$ and the one of the minimum. At the moment I only have the minimum, which I found by using Minimize: (d (a d - c e) + b c^2)/(e^2 - 4 a b). May 6 at 15:54
• @PenelopeBenenati See if the portion I've added to my answer in my edit is closer to what you need. May 6 at 16:31
• Thank you very much @MarcoB ! It is what I was looking for! I am curious now: would we have been able to find such two values just looking at the answer of Minimize I found writing my question? I see that, for instance for $x$, we have x == (2 b c)/(4 a b - e^2) \[Or] x == (d e)/(e^2 - 4 a b) among the proposed solutions of the general expression , but none of these two values achieve the minimum for $x$... it is precisely their difference which achieve it, that is, as you wrote in your answer, x -> (2 b c - d e)/(4 a b - e^2). Why? May 6 at 18:26
• @PenelopeBenenati I think the answers to both your question is the same: the results shown in my answer are obtained in the presence of constraints (i.e. the parameters are non-zero). You had solved the unconstrained problem before. The two are different problems, so they may well admit different solutions. May 6 at 18:48
• @PenelopeBenenati But they are included! Try e.g. x /. Minimize[a*x^2+b*y^2-c*x-d*y+e*x*y, {x,y}][[2]] and you'll see that the "general" answer is there (it's the 5th case from the top for me). Then you can do the same for $y$ (I.e. y /. Minimize[...][[2]]) and you will find the "general" one for $y$, albeit in a less simplified version in which $b$ could be collected in numerator and denominator and cancelled out. May 7 at 2:30