Nearest Integer Function

Author

Eric W. Weisstein
February 16, 2008

This notebook downloaded from http://mathworld.wolfram.com/notebooks/SpecialFunctions/NearestIntegerFunction.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/NearestIntegerFunction.html.

©2008 Wolfram Research, Inc. except for portions noted otherwise

Graphics

<<Utilities`Plot`
<<Utilities`Typesetting`

Real Axis

PlotDiscontinuous[Round[x],{x,Sequence@@Range[-7/2,7/2]},AxesLabel->TraditionalForm/@{x,Round[x]},PlotRange->All]

PlotDiscontinuous[Round[x],{x,-4,Sequence@@Range[-7/2,7/2],4},AxesLabel->TraditionalForm/@{x,Round[x]},PlotRange->All]

PlotDiscontinuous[Round[x],{x,-3,Sequence@@Range[-5/2,5/2],3},AxesLabel->TraditionalForm/@{x,Round[x]},PlotRange->All]

f[x_,n_]:=#-Round[#]&[x^(1/n)]

GraphicsGrid[Partition[{
PlotDiscontinuous[f[x,1],{x,-2,Sequence@@Range[-3/2,3/2],2},AxesLabel->{x,Round[x]-x},PlotRange->All],
PlotDiscontinuous[f[x,2],{x,0,Sequence@@({0,2,6,12}+1/4),15},AxesLabel->{x,Round[Sqrt[x]]-Sqrt[x]},PlotRange->All],
PlotDiscontinuous[f[x,3],{x,0,Sequence@@{1/8,3+3/8,15+5/8},30},AxesLabel->{x,Round[x^(1/3)]-x^(1/3)},PlotRange->All]
},2,2,{1,1},{}],ImageSize->500]

Complex Plane

ComplexPlot3D[Round[z],{z,-3,3},ComplexPlotLabel->nint[z],Mesh->False,PlotPoints->30]

ComplexContourPlot[Round[z],{z,-3,3},ComplexPlotLabel->nint[z]]

Zeros

FindRoot[f[x,2]==0,{x,.1,.5}]

FindRoot[f[x,2]==0,{x,2,2.5}]

FindRoot[f[x,2]==0,{x,6,7}]

FindRoot[f[x,2]==0,{x,12,13}]

FindRoot[f[x,3]==0,{x,.1,.2}]

FindRoot[f[x,3]==0,{x,3,4}]

FindRoot[f[x,3]==0,{x,15,16}]