I have a function called n ( x ) such that:
⎩ ⎪ ⎨ ⎪ ⎧ if { x } < 0 . 5 then n ( x ) = ⌊ x ⌋ if { x } = 0 . 5 then n ( x ) = x if { x } > 0 . 5 then n ( x ) = ⌊ x ⌋ + 1
What is a good approximation of n ( x ) ?
Note
{ ⋅ } is the fractional part function
⌊ ⋅ ⌋ is the floor function
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Great, but it should be ⌊ x + 0 . 5 ⌋ = { ⌊ x ⌋ if ( x ) < 0 . 5 ⌊ x ⌋ + 1 if ( x ) > 0 . 5 because every problem that I made if I say nothing then that means it applied to real numbers, not just 0 < x < 1 .
Log in to reply
Oh right, I forgot about that. Now I've corrected it.
Problem Loading...
Note Loading...
Set Loading...
The cases ( x ) < 0 . 5 and ( x ) > 0 . 5 mean that x is closer to the next integer smaller (for ( x ) < 0 . 5 ) or larger (for ( x ) > 0 . 5 ) than x. Rounding down in both cases, but adding 1 in the second case is the same as rounding to the nearest integer.
⌊ x + 0 . 5 ⌋ does exactly that:
0 ≤ ( x ) ≤ 1 ⇔ 0 . 5 ≤ x + 0 . 5 ≤ 1 . 5 . After rounding down, ⌊ x + 0 . 5 ⌋ = { ⌊ x ⌋ + 0 , ⌊ x ⌋ + 1 , if ( x ) < 0 . 5 if ( x ) > 0 . 5 .
So ⌊ x + 0 . 5 ⌋ only differs at one point from the given function which makes it a good aproximation.