At the outset, it is known that x is a positive real number.
Determine the minimum value of:
x*floor(x) + floor(1/x) + x + 1/x + x*ceiling(x) + ceiling(1/x)
The desired minimum value is 3 + 2*√2 =~ 5.82842712474619
A computer search shows that a minimum occurs at:
x = 0.707107 which looks a lot like √2/2
f(x) = 5.828427124746326
Zeroing in by narrowing the search finds:
x = 0.707106771
f(x) = 5.82842712474619
Note floor and ceiling of √2/2 are 0 and 1 respectively,
and floor and ceiling of √2 are 1 and 2 respectively.
Expression at √2/2: 0 + 1 + √2/2 + √2 + √2/2 + 2
= 3 + 2*√2 = 5.82842712474619 by direct calculation
Note that the expression is approximated by:
g(x) = 2x^2 + x + 3/x
g'(x) = 4x + 1 - 3/x^2 which if set to zero gives
4x^3 + x^2 - 3 = 0
which has a root at approx. 0.8324
and a minimum at approx. 5.8222
"""
import math
def ceiling(x):
return math.ceil(x)
def floor(x):
return math.floor(x)
def f(x):
return x*floor(x) + floor(1/x) + x + 1/x + x*ceiling(x) + ceiling(1/x)
lo = .5
hi = 1
slices = 1000000
minY = 1000000
minX = 0
for i in range(slices):
x = lo + (hi-lo)*i/slices
y = f(x)
if y < minY:
minY = y
minX = x
print(minX, minY)
print((2**.5)/2 - minX)
Edited on April 17, 2023, 10:12 am
|
Posted by Larry
on 2023-04-17 10:12:31 |