All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Just Math
Flooring a Floor-Ceiling Function (Posted on 2023-04-17) Difficulty: 3 of 5
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)

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution solution | Comment 3 of 5 |
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

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (6)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information