Mathematica Asked by Ahmed Kamal Kassem on November 19, 2020
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}}*)
addendum
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}}*)
Answered by Ulrich Neumann on November 19, 2020
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*)
Answered by user64494 on November 19, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP