3
$\begingroup$

I am trying to determine if a function is always positive given a set of assumptions. I am using NMinimize following the advice of previous posts in this site. However, I am getting a global minimum that does not satisfy the assumptions.

I use the following code:

assumptions = {w3 > 0 && w2 > w3 && w1 > 2 w2 - w3 && 0 < b < w3 && 0 < l < 1};
NMinimize[
  {1/6 
     ((2 b l + 2 w1 + 5 w2 - 3 l w2 - 7 w3 + 3 l w3) / (w2 - l w2 - w3 + l w3) - 
       Sqrt[
         (4 b^2 l^2 + 4 b l (2 w1 + 5 w2 - 3 l w2 - 7 w3 + 3 l w3) + 
         (-2 w1 + w2 - 3 l w2 + w3 + 3 l w3)^2) / ((-1 + l)^2 (w2 - w3)^2)]) - 
   (2 w1 - w2 - w3)/(b*2 l + 2 w1 - w2 - w3), 
   assumptions}, 
  {b, l, w1, w2, w3}]

However, Mathematica returns

{-5.32491,
{b -> 0.0796325, l -> 0.0617359, w1 -> 0.52956, w2 -> 0.14148, w3 -> 0.189851}}

where w2 < w3.

I have tried adding the assumptions directly to NMinimize or to write a function for the expression, but the results are the same.

Does someone know a better way to solve this problem?

$\endgroup$
  • $\begingroup$ @Akku14 you should write this as an answer and show the result of the Simplify. $\endgroup$ – chris Jul 12 at 10:10
4
$\begingroup$

Reduce the function to be minimized to only one Denominator with Together.

assumptions = {w3 > 0 && w2 > w3 && w1 > 2 w2 - w3 && 0 < b < w3 && 
               0 < l < 1};

si[b_, l_, w1_, w2_, w3_] = 
    1/6 ((2 b l + 2 w1 + 5 w2 - 3 l w2 - 7 w3 + 3 l w3)/(w2 - l w2 - w3 +
       l w3) - 
   Sqrt[(4 b^2 l^2 + 
       4 b l (2 w1 + 5 w2 - 3 l w2 - 7 w3 + 3 l w3) + (-2 w1 + 
          w2 - 3 l w2 + w3 + 3 l w3)^2)/((-1 + l)^2 (w2 - 
          w3)^2)]) - (2 w1 - w2 - w3)/(b*2 l + 2 w1 - w2 - w3) // 
Together // Simplify[#, assumptions] & 

(*   -(-4 b^2 l^2 + 
2 b l (-4 w1 - 4 w2 + 3 l w2 + 8 w3 - 3 l w3 + Sqrt[
   4 b^2 l^2 - 
    4 b l (-2 w1 - 5 w2 + 3 l w2 + 7 w3 - 3 l w3) + (-2 w1 + w2 - 
      3 l w2 + w3 + 3 l w3)^2]) + (2 w1 - w2 - w3) (-2 w1 + w2 - 
   3 l w2 + w3 + 3 l w3 + Sqrt[
   4 b^2 l^2 - 
    4 b l (-2 w1 - 5 w2 + 3 l w2 + 7 w3 - 3 l w3) + (-2 w1 + w2 - 
      3 l w2 + w3 + 3 l w3)^2]))/(6 (-1 + l) (w2 - w3) (-2 b l - 
  2 w1 + w2 + w3))   *)

NMinimize[{si[b,l,w1,w2,w3], assumptions}, {b, l, w1, 
w2, w3}]

(*   {-3.58991*10^-15, {b -> 0.0547977, l -> 2.47803*10^-7, w1 -> 0.69935, 
       w2 -> 0.0934508, w3 -> 0.0864639}}   *)

Edit

A plot of the function shows, the whole lines with b==0 and l==0 reach the minimum zero.

Manipulate[
  Plot3D[si[b, l, w1, w2, w3], {b, 10^-3, 10}, {l, 10^-3, 1}, 
RegionFunction -> Function[{b}, 0 < b < w3], PlotPoints -> 50, 
AxesLabel -> {"b", "l", "si"}, ImageSize -> 400], {{w1, 9}, 
2 w2 - w3, 2 w2 - w3 + 10, Appearance -> "Labeled"}, {{w2, 7}, w3, 
w3 + 10, Appearance -> "Labeled"}, {{w3, 6}, 10^-5, 10, 
Appearance -> "Labeled"}, ContinuousAction -> False]

enter image description here

Attention. If the sliders show a red point, you are outside the allowed variable range.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thank you very much! It was very helpful. But then I could say that the function is greater or equal than zero? As I see that the global minimum is almost 0. $\endgroup$ – pau1996 Jul 12 at 10:25
  • $\begingroup$ Attention. With NMinimize you can not be sure, you got the global minimum. I am trying to do the job with Minimize, but it doesn't like the squareroot. $\endgroup$ – Akku14 Jul 12 at 11:00
  • $\begingroup$ That was very useful Akku14! Thank you very much! However, I can not run your command in my Mathematica. I just have to coppy and paste your answer in My Mathematica file and just run it? I think I have a problem on running the Together and Simplify line $\endgroup$ – pau1996 Jul 12 at 14:08
  • $\begingroup$ On my pc it works well (version 8.0). Quit the kernel with Quit and then copy my entire code and paste. $\endgroup$ – Akku14 Jul 12 at 17:45
  • $\begingroup$ Thanks "@Akku14, It worked now! Thanks again for the help. $\endgroup$ – pau1996 Jul 12 at 20:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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