TransWikia.com

Something does not work when minimizing a function

Mathematica Asked on June 14, 2021

So basically I am trying to minimizing a function. I use the command "FindMinimum" since "Minimize" just returns the input.

FindMinimum gives me the minimized potential and the value of the two variables that minimize it. But… then I tried to vary parameters which gave me a different minimum, but the two variables still took the same value, which makes no sense to me.

Since I am dealing with very large and small numbers I suspect Mathematica cannot handle it.

For instance,

FindMinimum[((0.1) x^(-3) + (1/50000000) x^(-4/3)  + (80000^2 E^(-200 [Pi] y) [Pi]^2   Sqrt[y])/ 3 x - (4000 [Pi]  y E^(-100 [Pi] y))/(x^2)) / (800000000 [Pi]), {x, y}]

$$Big(frac{0.1}{x^3} + frac{1}{5 times 10^6 x^{4/3}} + frac{8 times 10^{8} e^{-200 pi y} pi^2 sqrt{y}}{3x} – frac{4000 e^{-100 pi y} pi y}{x^2} Big) frac{1}{8 times 10^8 pi}$$

As can be seen, this function is dominated by the first term. The output is

{3.97887*10^-11, {x -> 1., y -> 1.}}]

However, if I tweak the first term, letting $0.1 rightarrow 1$:
$$Big( frac{1}{x^3} + frac{1}{5 times 10^6 x^{4/3}} + frac{8 times 10^{8} e^{-200 pi y} pi^2 sqrt{y}}{3x} – frac{4000 e^{-100 pi y} pi y}{x^2} Big) frac{1}{8 times 10^8 pi}$$

FindMinimum[((1) x^(-3) + (1/50000000) x^(-4/3)  + (80000^2 E^(-200 [Pi] y) [Pi]^2   Sqrt[y])/ 3 x - (4000 [Pi]  y E^(-100 [Pi] y))/(x^2)) / (800000000 [Pi]), {x, y}]

now gives the output

{3.97887*10^-10, {x -> 1., y -> 1.}}

Notice that the value of the function changed but not x and y. Why is that? Are these numbers too hard for Mathematica to handle? If so, something I can do about it? I am a bit confused. My objective is to find x and y that minimizes the function.

2 Answers

Clear["Global`*"]

f[x_, y_, t_] := (t x^(-3) + (1/
       50000000) x^(-4/3) + (80000^2 E^(-200 π y) π^2 Sqrt[y])/
      3 x - (4000 π y E^(-100 π y))/(x^2))/(800000000 π)

FunctionDomain[f[x, y, t], {x, y}]

(* x > 0 && y >= 0 *)

Since you "know approximately the values on x and y that minimizes the function", add constraints and use NMinimize. From documentation, "NMinimize always attempts to find a global minimum of f subject to the constraints given." However, that is not a guarantee that the global minimum is found, and certainly not if the constraints do not include the global minimum.

NMinimize[{f[x, y, 1/10], 0 < x < 2, 0 <= y < 2}, {x, y}, 
  WorkingPrecision -> 20] // N

(* {4.98816*10^-12, {x -> 1.99805, y -> 1.29799}} *)

NMinimize[{f[x, y, 1], 0 < x < 2, 0 <= y < 2}, {x, y}, 
  WorkingPrecision -> 20] // N

(* {4.97359*10^-11, {x -> 2., y -> 1.29799}} *)

Correct answer by Bob Hanlon on June 14, 2021

Things get a bit better if you remove the multiplicative constant:

f[x_, y_, t_] := (t x^(-3) 
   + (1/50000000) x^(-4/3) 
   + (80000^2 E^(-200 [Pi] y) [Pi]^2 Sqrt[y])/3 x 
   - (4000 [Pi] y E^(-100 [Pi] y))/(x^2));
FindMinimum[f[x, y, .1], {x, y}]
  (* {2.40011*10^-19, {x -> 1.55095*10^8, y -> 1.}} *)

However note that

Limit[f[x, x, 1], x -> [Infinity]]
(* 0 *)

Answered by A.G. on June 14, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP