![绘制 1/floor(1/x) 的安全 PostScript 表达式是什么?](https://linux22.com/image/287303/%E7%BB%98%E5%88%B6%201%2Ffloor(1%2Fx)%20%E7%9A%84%E5%AE%89%E5%85%A8%20PostScript%20%E8%A1%A8%E8%BE%BE%E5%BC%8F%E6%98%AF%E4%BB%80%E4%B9%88%EF%BC%9F.png)
绘制的安全 PostScript 表达式是什么f(x)=1/floor(1/x)
?
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}
\pstVerb{/inv {dup 0 eq {pop e30} {1 exch div} ifelse} bind def}
\begin{document}
\begin{pspicture}(-3,-3)(5,5)
\psaxes{->}(0,0)(-3,-3)(5,5)
\psplot[linecolor=blue,linewidth=2pt]{-1}{4}{x inv floor inv}% plotting f(x)=1/floor(1/x)
\end{pspicture}
\end{document}
答案1
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}
\begin{document}
\psset{unit=4}
\begin{pspicture}(-1.5,-1.2)(1.2,1.2)
\psaxes[Dx=0.5]{->}(0,0)(-1.5,-1.1)(1.1,1.1)
\psplot[algebraic,linecolor=red,VarStep,VarStepEpsilon=1.e-9]{-1.5}{-0.001}{ 1/floor(1/x) }
\psplot[algebraic,linecolor=red,VarStep,VarStepEpsilon=1.e-9]{0.001}{1}{ 1/floor(1/x) }
\end{pspicture}
\end{document}
并绘制为“函数”
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}
\makeatletter
\def\doqp@line{ 2 copy CP Pyth2 1 gt { moveto }{ L } ifelse }
\makeatother
\begin{document}
\psset{unit=4}
\begin{pspicture}(-1.5,-1.2)(1.2,1.2)
\psaxes[Dx=0.5]{->}(0,0)(-1.5,-1.1)(1.1,1.1)
\psset{algebraic,linecolor=red,VarStep,VarStepEpsilon=1.e-9,linewidth=1.5pt}
\psplot{-1.5}{-0.001}{ 1/floor(1/x) }
\psplot{0.001}{1}{ 1/floor(1/x) }
\end{pspicture}
\end{document}
答案2
您的 inv 定义似乎不在范围内,因此我只是内联了一个类似的定义
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}
\pstVerb{/inv {dup 0 eq {pop e30} {1 exch div} ifelse} bind def}
\begin{document}
\begin{pspicture}(-3,-3)(5,5)
\psaxes{->}(0,0)(-3,-3)(5,5)
\psplot[linecolor=blue,linewidth=2pt]{-1}{4}
{1 1 x 0 eq {0.000001} {x} ifelse div floor dup 0 eq {pop 0.000001} {} ifelse div}% plotting f(x)=1/floor(1/x)
\end{pspicture}
\end{document}
答案3
它是1 1 x div floor div
。我不知道该 floor
函数是否在 pstricks 中定义为代数符号。下面是用于绘制此函数的代码,pstricks
可以使用 进行编译pdflatex
;由于 0 中的无限不连续性,您必须分别绘制曲线的两个部分:
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{MinionPro}
\pagestyle{empty}
\usepackage[pdf, svgnames]{pstricks}%
\usepackage{pstricks-add}
\def\myfunc{1 1 x div floor div}
\begin{document}
\psset{unit = 5cm, plotpoints = 1000}
\begin{pspicture}
\psaxes{->}(0,0)(-1.5,-1.5)(1.5,1.5)
%\psplot[linecolor = VioletRed]{0.1}{1}{1 1 x div floor div}
\psset{linecolor = VioletRed}
\psplot[arrows = -*]{0.002}{1}{\myfunc}
\psplot[arrows = *-]{-1}{-0.002}{\myfunc}
\pscircle[linewidth = 0.25pt, fillstyle = solid, fillcolor = white](0,0){0.8pt}
\end{pspicture}
\end{document}
注意:这不是真正的数学曲线,因为垂直段不是它的一部分。用 得到的图\psplot
总是continuous
曲线,而这个不是。绘制真正的曲线会更复杂。