Graphics, Figures & TablesGreatest Integer Function

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
coachbennett1981
Posts: 274
Joined: Fri Feb 05, 2010 10:15 pm

Greatest Integer Function

Post by coachbennett1981 »

I am trying to plot the greatest integer function, just the basic f(x)=int(x). Does anyone know a code to do this? I have tried several things including the code below:

Code: Select all


\documentclass[12pt]{exam}
\usepackage{amsmath,amssymb,pstricks,pstricks-add}

 \begin{pspicture}(-12,-2)(5,-2)
	 	\psset{unit=.75cm}
\psaxes[linewidth=1.5pt]{<->}(0,0)(-5,-5)(5,5)[$x$-axis,-90][$y$-axis,180]
\psplot[algebraic,linecolor=red,linewidth=1.5pt,arrows=<->]{0.25}{4}{int(x)} %floor(x), int x also
\end{pspicture}
\end{document}

Last edited by coachbennett1981 on Fri Nov 12, 2010 1:57 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am

Greatest Integer Function

Post by CrazyHorse »

coachbennett1981 wrote:I am trying to plot the greatest integer function, just the basic f(x)=int(x). Does anyone know a code to do this? I have tried several things including the code below:

Code: Select all

\documentclass[12pt]{article}
\usepackage{pstricks-add}

\begin{document}
\begin{pspicture}(-5,-5)(5,5)
\psset{unit=.75cm}
\psaxes[linewidth=1.5pt]{<->}(0,0)(-5,-5)(5,5)[$x$-axis,-90][$y$-axis,180]
\psplot[linecolor=red,linewidth=1.5pt,arrows=<->,
  plotpoints=5000]{0.25}{4}{x floor} 
\end{pspicture}

\end{document}
It would be a good idea, if you can test your own code (!), before
posting such examples, e.g. missing \begin{document}, special
documentclass, ...

Herbert
coachbennett1981
Posts: 274
Joined: Fri Feb 05, 2010 10:15 pm

Re: Greatest Integer Function

Post by coachbennett1981 »

Sorry about that, I did not copy the preamble directly from the document. Your figure was the same figure that I got. I wanted to know if there was an easy way to try the attached figure using pstricks, or would I use something like the \psline feature.

Thank you for you help..
Attachments
Greatest Integer Function
Greatest Integer Function
Screen shot 2010-11-04 at 7.33.22 PM.png (25.05 KiB) Viewed 6960 times
CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am

Greatest Integer Function

Post by CrazyHorse »

coachbennett1981 wrote:Sorry about that, I did not copy the preamble directly from the document. Your figure was the same figure that I got. I wanted to know if there was an easy way to try the attached figure using pstricks, or would I use something like the \psline feature.

Code: Select all

\documentclass[12pt]{article}
\usepackage{pstricks-add}

\begin{document}
\begin{pspicture}(-4.5,-4.5)(4.5,4.5)
\psset{unit=.75cm}
\psaxes[labelFontSize=\scriptstyle]{<->}%
  (0,0)(-5,-5)(5,5)[$x$-axis,-90][$y$-axis,180]
\multido{\iA=-4+1}{8}{\psline[linewidth=1.5pt,
  linecolor=red]{*-o}(\iA,\iA)(!\iA\space 1 add \iA)}
\end{pspicture}

\end{document}
Herbert
coachbennett1981
Posts: 274
Joined: Fri Feb 05, 2010 10:15 pm

Re: Greatest Integer Function

Post by coachbennett1981 »

Thank you, this is perfect
Post Reply