# Minimizing simple function of three variables fails

I need to minimize simple function with all variables are positive integers, but the out is the same as the input. No solution

    Clear[α, k, β, g];
g = (1 + Sqrt[5])/2;
f[α_, k_, β_, g_] := Abs[π - (α/β)*g^k;]
Assuming[α > 0 && k > 0 && β > 0 ,
Minimize[f[α, k, β, g], {α, k, β},
Integers]]


My version is 12.1

Any help

Thanks

First correct the definition of f (semicolon inside argument brackets)

g = (1 + Sqrt[5])/2;
f[\[Alpha]_, k_, \[Beta]_, g_] := Abs[\[Pi] - (\[Alpha]/\[Beta])*g^k]


Use NMinimize with constraints instead of assumptions:

NMinimize[{f[\[Alpha], k, \[Beta], g],Element[{\[Alpha], k, \[Beta]}, PositiveIntegers]}, {\[Alpha],k, \[Beta]} , MaxIterations -> 500]
(*{


0.0354583, {[Alpha] -> 3, k -> 3, [Beta] -> 4}}*)

Restricting the parameterrange {\[Alpha] -<10, k<10, \[Beta] <10} helps NMinimize finding the "right" minimum

NMinimize[{f[\[Alpha], k, \[Beta], g], \[Alpha] < 10, k < 10, \[Beta] < 10,Element[{\[Alpha], k, \[Beta]},PositiveIntegers]}, {\[Alpha],k, \[Beta]}  , MaxIterations -> 500]
(*{0.0000481329, {\[Alpha] -> 6, k -> 2, \[Beta] -> 5}}*)

• I wonder the upvoters. The answer is wrong. Commented Oct 29, 2020 at 10:54
• Indeed this answer is wrong. If you take the square of f and later the sqrt of the minimum, you can even use Minimize. f2[\[Alpha]_, k_, \[Beta]_, g] = (\[Pi] - (\[Alpha]/\[Beta])*g^k)^2 // ExpandAll;  {{min, vars} = Minimize[{f2[\[Alpha], k, \[Beta], g], 0 < \[Alpha] < 300, 0 < k < 10, 0 < \[Beta] < 200, Element[{\[Alpha], k, \[Beta]}, Integers]}, {\[Alpha], k, \[Beta]}], Sqrt[min] // N}  gives 8.4126*10^-6  as minimum of f. Minimum shows to be for k == 1 and it tends to zero. Use 262000 < \[Alpha] < 263000, 134000 < \[Beta] < 136000  in above cmd, set k=1. Commented Oct 29, 2020 at 16:06
• @Akku14 Nothing is wrong! If you take the same parameter range \[Alpha] < 10, k < 10, \[Beta] < 10 as I did , you' ll get the solution given in my answer! Commented Oct 29, 2020 at 20:04
• @user64494 It worked for me Commented Oct 30, 2020 at 3:53
• @Ulrich Neumann, the OP is looking for the global minimum for {alpha,beta, k} are PositiveIntegers. This global minimum is not 0.0000481329 as you got with a restricted parameter range. In fact it is as i wrote "Minimum shows to be for k == 1 and it tends to zero" , although it never reaches exact zero. If you take a restricted parameter range, you don't answer the OP and you don't give " the "right" minimum" as you stated. Commented Oct 30, 2020 at 6:48

The infimum under consideration equals zero. Put k=1, then you approximate a number Pi/g==2*Pi/(1+Sqrt[5]) by a rational number \[Alpha]/\[Beta]. This can be done with an arbitrary accuracy, e.g.

RealAbs[FromContinuedFraction[ContinuedFraction[(2 \[Pi])/(1 + Sqrt[5]),
20]] - (2 \[Pi])/(1 + Sqrt[5])] // N
(*2.22045*10^-16*)
FromContinuedFraction[ContinuedFraction[(2 \[Pi])/(1 + Sqrt[5]),20]]
(*107070177060/55145018711*)

• Even simpler: N[RealAbs[ Rationalize[(2 Pi)/(1 + Sqrt[5]), 10^-30] - (2 Pi)/(1 + Sqrt[5])], 30] performs 6.33234721355549660014137078117*10^-31. Commented Oct 29, 2020 at 16:10