2
$\begingroup$

Why does Mathematica fails to find the minima of the two variable function with real coefficients. The function and my attempt is given below.

Input:

 FindMinimum[
     a (x - vh^2/2)^2 + b (y - vs^2/2)^2,  {a, b, vh, vs} \[Element] 
      Real]

output:

FindMinimum::ivar`

Note that I want a minimum w.r.t to both x and y. Any suggestions, please.

How if the a,b -> \sqrt[a], \sqrt[b] ?

$\endgroup$
3
  • 1
    $\begingroup$ You didn't mentioned you get the FindMinimum::ivar error. The community expects: ✅: A clear description of an on-topic problem or goal. ✅: A minimal working Wolfram Language code example, formatted, easy to copy&paste. ❌. An example of what you expect as output. ❌. Some proof of minimal Mathematica knowledge. ❌. Minimum due diligence: Share how you have searched the site and documentation, your attempts and reasons to believe an answer exists. $\endgroup$
    – rhermans
    Dec 2, 2022 at 12:52
  • 1
    $\begingroup$ Maybe Minimize[ a (x - vh^2/2)^2 + b (y - vs^2/2)^2 + c (x - vh^2/2) (y - vs^2/2), {x, y}] $\endgroup$
    – cvgmt
    Dec 2, 2022 at 12:57
  • $\begingroup$ We only need to consider a*u^2+b*v^2+c*u*v. $\endgroup$
    – cvgmt
    Dec 2, 2022 at 13:20

2 Answers 2

3
$\begingroup$

As mentioned by Ulrich Neumann (+1), the correct function for what you want is Minimize, not FindMinimum, see below why your attempt didn't work.

Solution

You can use Minimize, but unless you constraint the values for your variables (In this case using Assuming), you get a very complicated expression. Here I show you the simplest case for positive parameters and $4 a b >c^2$:

Assuming[
    And[
        {a, b, c, vh, vs} ∈ PositiveReals, 
        4 a b > c^2
    ],
    FullSimplify@Minimize[
        a (x - vh^2/2)^2 + b (y - vs^2/2)^2 +  c (x - vh^2/2) (y - vs^2/2)
        , {x, y}
    ]
]

enter image description here


Your mistake

Your code didn't work for many reasons:

  • Real is not the same as Reals.
  • FindMinimum[ f[x], {x,xo} ] needs to evaluate f[x] to a number, but you have undefined parameters {a, b, c, vh, vs}
  • Your syntax is not what FindMinimum expects
$\endgroup$
5
  • $\begingroup$ Nice answer! Do you know how mathematica find these minima? $\endgroup$
    – SciJewel
    Dec 2, 2022 at 13:18
  • $\begingroup$ I want to know the underlying method where mathematica us first or second order derivative or without it. $\endgroup$
    – SciJewel
    Dec 2, 2022 at 13:19
  • $\begingroup$ @SciJewel No, we don't know in detail how is done, the documentation doesn't say and TracePrint doesn't reveal anything useful. In general Wolfram doesn't disclose implementation details. Presumably, it does something similar you would do, solving for derivative roots. $\endgroup$
    – rhermans
    Dec 2, 2022 at 13:50
  • $\begingroup$ Do you also find another minimum as I do for 4 a b == c^2. In this case I find different terms for x and y. If I change the order of the variable that is, Minimize[f{x,y}, {x,y}] and Minimize[f{x,y}, {y,x}], the minima are different and interchanged. $\endgroup$
    – SciJewel
    Dec 2, 2022 at 14:44
  • $\begingroup$ When I use \sqrt[a], \sqrt[b] instead of a, b, it cannot find find the solutions. I even changed the assumption to \sqrt[a], \sqrt[b] as Positive reals. Still, doesn't work. could you please check it. Thanks $\endgroup$
    – SciJewel
    Dec 16, 2022 at 12:50
3
$\begingroup$

FindMinimum expects numerical input, try Minimize:

mini=Minimize[a (x - vh^2/2)^2 + b (y - vs^2/2)^2 + c (x - vh^2/2) (y - vs^2/2), {x, y}]

Simplify[mini, a > 0 && b > 0 && c > 0]

enter image description here

gives minimum -Infinity if 4 a b <c^2 and several other solutions.

$\endgroup$
1
  • 1
    $\begingroup$ It cannot be infinity. $\endgroup$
    – SciJewel
    Dec 2, 2022 at 13:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.