Fractional Part

Author

Eric W. Weisstein
August 29, 2006

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

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

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

Plots

<<Utilities`Plot`

Real Axis

Plot[FractionalPart[x]-Sign[x](Abs[x]-Floor[Abs[x]]),{x,-5,5},PlotStyle->Red,PlotRange->{-1,1}10^-20]

Function[x,{FractionalPart[x],Sign[x](Abs[x]-Floor[Abs[x]])}]/@Table[Random[Complex,10(I+1){-1,1}],{20}]

FractionalPart[-1]

Plot[FractionalPart[x]-(x-Floor[x]-1),{x,-3,0},PlotStyle->Thickness[.005]]

Mathematica's definition

Frac[x_?Positive]:=x-Floor[x]
Frac[x_?Negative]:=x-Ceiling[x]
PlotDiscontinuous[Frac[x],{x,Sequence@@Range[-4,4]},PlotRange->{{-4.1,4.1},{-1.1,1.1}}]/._If:>{}

PlotDiscontinuous[FractionalPart[x],{x,-4,4},Range[-4,4],{0}]

Graham's definition

Frac2[x_]:=x-Floor[x]

PlotDiscontinuous[Frac2[x],{x,-4,4},Range[-4,4]]

Both

Show[GraphicsArray[{
PlotDiscontinuous[FractionalPart[x],{x,-4,4},Range[-4,4],{0},DisplayFunction->Identity],
PlotDiscontinuous[Frac2[x],{x,-4,4},Range[-4,4],DisplayFunction->Identity]
}]]

Complex Plane

ComplexPlot3D[FractionalPart[z],{z,-3,3}]//Timing

ComplexContourPlot[FractionalPart[z],{z,-3,3}]//Timing

frac(n (lnn))

ListPlot[Table[FractionalPart[n Log[n]],{n,10^4}],AxesLabel->TraditionalForm/@{n,n Log[n]},PlotStyle->{PointSize[.002],Red},ImageSize->500]

Inequalities

Table[(3/4)^n<FractionalPart[(3/2)^n]<1-(3/4)^n,
{n,7}]

Union[Table[(3/4)^n<FractionalPart[(3/2)^n]<1-(3/4)^n,
{n,8,10000}]]

frac((1/x))

Plot[FractionalPart[1/x],{x,0,3},PlotPoints->100,PlotStyle->Red,
AxesLabel->TraditionalForm/@{x,frac[1/x]}]

Integrals

(∫_(1/2)^1)frac((1/x))dx

Piecewise.m

<<Piecewise`

PiecewiseIntegrate[FractionalPart[1/x],{x,1/2,1}]

v4.2

Integrate[FractionalPart[1/x],{x,1/2,1}]

v5.0

Integrate[FractionalPart[1/x],{x,1/2,1}]

v6.0

Integrate[FractionalPart[1/x],{x,1/2,1}]//FullSimplify

Integrate[FractionalPart[1/x],{x,1/3,1/2}]//FullSimplify

Integrate[FractionalPart[1/x],{x,1/4,1/3}]//FullSimplify

Numerical

{NIntegrate[FractionalPart[1/x],{x,1/2,1}],Log[2]-1/2.}

{NIntegrate[FractionalPart[1/x],{x,0,1/7,1/6,1/5,1/4,1/3,1/2,1}],1.-EulerGamma}

(∫_0^1)frac((1/x))dx

Piecewise.m

<<Piecewise`

PiecewiseIntegrate[FractionalPart[1/x],{x,0,1}]

v5.2

Integrate[FractionalPart[1/x],{x,0,1}]

Telescoping Sum

Log[n]-Sum[1/k,{k,2,n}]

Limit[1-HarmonicNumber[n]+Log[n],n->∞]

(∫_1^∞)((frac(x))/(x^2))dx

Plot[FractionalPart[x]/x^2,{x,1,10},PlotStyle->Red,AxesLabel->TraditionalForm/@{x,frac[x]/x^2}]

Piecewise.m

<<Piecewise`

PiecewiseIntegrate[FractionalPart[x]/x^2,{x,1,∞}]

v5.2

Integrate[FractionalPart[x]/x^2,{x,1,∞}]

v6

Integrate[FractionalPart[x]/x^2,{x,1,∞}]

Integrate[FractionalPart[x]/x^2,{x,1,2}]//Simplify

Integrate[FractionalPart[x]/x^2,{x,2,3}]//FullSimplify

Integrate[FractionalPart[x]/x^2,{x,3,4}]//FullSimplify

Telescoping Sum

Sum[-(1/k)+Log[(k/(k-1))],{k,2,∞}]

Integer Part + Fractional Part

Plot[FractionalPart[x]+IntegerPart[x],{x,-4,4},AspectRatio->Automatic]

Identities

frac(x+i y)==frac(x)+i frac(y)

Subtract@@@Table[{FractionalPart[x+I y],FractionalPart[x]+I FractionalPart[y]}/.{x->Random[Real,10{-1,1}],y->Random[Real,10{-1,1}]},{1000}]//Chop//Union

Subtract@@@Table[{FractionalPart[x+I y],FractionalPart[x]+I FractionalPart[y]}/.{x->Random[Integer,10{-1,1}],y->Random[Integer,10{-1,1}]},{1000}]//Chop//Union

FullSimplify[Subtract@@{FractionalPart[x+I y],FractionalPart[x]+I FractionalPart[y]},(x|y)∈Reals]

v5.2

ComplexExpand[Subtract@@{FractionalPart[x+I y],FractionalPart[x]+I FractionalPart[y]}]

v6

ComplexExpand[Subtract@@{FractionalPart[x+I y],FractionalPart[x]+I FractionalPart[y]}]