TransWikia.com

$0.5(floor(x)+x $ graph in LaTeX

TeX - LaTeX Asked by kawsar on March 4, 2021

How to draw $0.5(floor(x)+x $ graph in LaTeX. with Using GeoGebra commands, the shape cannot be mapped in Latex.

begin{tikzpicture}
%draw [line width=0.3pt,pink](-3,-4) grid (3,4);
begin{axis}[axis lines=middle]
addplot [
    jump mark mid,
    domain=-3:3,
    samples=600,
    very thick, red
] {((0.5)*floor(x))+x};
draw [color=blue] (1,-2) circle (3pt);
end{axis}
end{tikzpicture}

2 Answers

For fun, it is simple with pstricks:

documentclass[11pt,svgnames, border=3pt]{standalone}
usepackage{pst-plot, multido}

begin{document}

begin{pspicture*}(-1,-1)(5,5)
multido{i=1+1,n=0.5+1.0}{5}{psline[linestyle=dotted, dotsep=2pt, linecolor=LightSteelBlue](i, n)(0,n)}
psaxes[ticksize=2pt, ysubticks=2, labelFontSize=scriptstylecolor{SteelBlue}, showorigin=false, arrows=->,arrowinset=0.12, linecolor=SteelBlue](0,0)(-0.99,-0.99)(5,5)[$x$, -120][$y$,-135]
uput[dl](0,0){$ O $}
psset{linewidth=1pt,linecolor=IndianRed,algebraic, plotpoints=40, dash=2pt 1.5pt}
multido{i=0+1}{5}{psCoordinates[linewidth=0.4pt, linecolor=LightSteelBlue, linestyle= dashed, markPoint=false](i, i)%
psplot[dotsize=2pt, arrows=*-]{i}{i.99}{0.5*(floor(x) + x)}}%
end{pspicture*} 

end{document} 

enter image description here

Answered by Bernard on March 4, 2021

In this case plain tikz would be my choice:

documentclass[border=2mm]{standalone}
usepackage   {tikz}

begin{document}
begin{tikzpicture}[line cap=round]
defminx{-2}
defmaxx {5}
pgfmathtruncatemacromaxi{maxx-1}
useasboundingbox (minx-0.5,minx-0.5) rectangle (maxx+0.5,maxx+0.5);
draw[thin,gray!50] (minx,minx) grid (maxx,maxx);
draw[thick,-latex] (minx,0) -- (maxx,0) node[right] {$x$};
draw[thick,-latex] (0,minx) -- (0,maxx) node[above] {$y$};
foreachi in {minx,...,maxi}
{
  draw[thick,red]      (i,i) --    (i+1,i+0.5);
  fill[red]            (i,i)       circle (0.05);
  draw[red,fill=white] (i+1,i+0.5) circle (0.05);
}
end{tikzpicture}
end{document}

enter image description here

Answered by Juan Castaño on March 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP