Nearest integer

Algebra Level pending

I have a function called n ( x ) 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 \begin{cases}~\text{if}~\{x\}<0.5~\text{then}~n(x)=\lfloor x \rfloor \\ \text{if}~\{x\}=0.5~\text{then}~n(x)=x \\ \text{if}~\{x\}>0.5~\text{then}~n(x)=\lfloor x \rfloor+1 \end{cases}

What is a good approximation of n ( x ) n(x) ?

Note

x 0.5 \lfloor x-0.5 \rfloor x + 0.5 x+0.5 x + 0.5 \lfloor x+0.5 \rfloor

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.

1 solution

Henry U
Oct 14, 2018

The cases ( x ) < 0.5 (x) < 0.5 and ( x ) > 0.5 (x) > 0.5 mean that x x is closer to the next integer smaller (for ( x ) < 0.5 (x) < 0.5 ) or larger (for ( x ) > 0.5 (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 \lfloor x+0.5 \rfloor does exactly that:

0 ( x ) 1 0.5 x + 0.5 1.5 0 \leq (x) \leq 1 \Leftrightarrow 0.5 \leq x+0.5 \leq 1.5 . After rounding down, x + 0.5 = { x + 0 , if ( x ) < 0.5 x + 1 , if ( x ) > 0.5 \lfloor x+0.5 \rfloor = \begin{cases} \lfloor x \rfloor + 0, & \text{if } (x)<0.5 \\ \lfloor x \rfloor + 1, & \text{if } (x)>0.5 \end{cases} .

So x + 0.5 \boxed{\lfloor x+0.5 \rfloor} only differs at one point from the given function which makes it a good aproximation.

Great, but it should be x + 0.5 = { x if ( x ) < 0.5 x + 1 if ( x ) > 0.5 \lfloor x+0.5 \rfloor=\begin{cases} \lfloor x \rfloor~\text{if}~(x)<0.5 \\ \lfloor x \rfloor+1~\text{if}~(x)>0.5 \end{cases} because every problem that I made if I say nothing then that means it applied to real numbers, not just 0 < x < 1 0<x<1 .

Gia Hoàng Phạm - 2 years, 7 months ago

Log in to reply

Oh right, I forgot about that. Now I've corrected it.

Henry U - 2 years, 7 months ago

1 pending report

Vote up reports you agree with

×

Problem Loading...

Note Loading...

Set Loading...