[pstricks] Modifying psPolynomial

Vince McGarry vmcgarry at austin.rr.com
Tue Mar 16 01:33:22 CET 2004


Thanks to Herbert Voss, I've been using psPolynomial for graphing arbitrary
polynomials. BTW, Herbert, I finally had a chance to analyze the PS code for
Horner. I have been trying to extend the code to make it more useful to my
particular circumstances. The following works fine:

\newcommand\MyFunction[1][x]{\PolyFunction[xval=#1,coeff=0 -5 0 1]}
\begin{squaregraph}{8}{12pt}{5}
    \psset{linewidth=1.2pt,arrows=-,plotpoints=200,minx=-8,maxx=8}
    \MyFunction % Plots f(x)=x^3-5x on [-8,8]
    \MyFunction[-2] % Plots the point (-2,f(-2))
\end{squaregraph}

Where squaregraph is an environment I created for automating \psaxis and
\psgrid and the macros are:


\def\psset at coeff#1{\edef\psk at coeff{#1}}
\def\psset at xval#1{\edef\psk at xval{#1}}
\def\psset at minx#1{\edef\psk at minx{#1}}
\def\psset at maxx#1{\edef\psk at maxx{#1}}
\psset{coeff=1,xval=x,minx=-10,maxx=10}
\def\v at rflag{x}
%
\def\Horner{%
    aload length
    dup 2 add -1 roll
    exch 1 sub {
        dup 4 1 roll
        mul add exch
    } repeat
    pop
}

\def\PolyFuncProc{\psk at xval [\psk at coeff] \Horner}

\def\PolyFunction{\@ifnextchar[{\PolyFunction at i}{\PolyFunction at i[]}}
\def\PolyFunction at i[#1]{%
    \psset{#1}
    \ifx\psk at xval\v at rflag%
        \psplot{\psk at minx}{\psk at maxx}{\PolyFuncProc}%
    \else
        \psdots(!\psk at xval\space\PolyFuncProc)% ****See this line below***
    \fi
}

What I would like, however, is to call \psdots from my program, like

\psdots(!-2 \MyFunction[-2])

However, I've tried this by changing the line indicated above to

\PolyFuncProc

And \space\PolyFuncProc

But both give an error message stating that I have an extra }. Any help
would be appreciated and, once again, thanks for the help Herbert.
 
Vince McGarry
Austin Community College
Rio Grande Campus
1212 Rio Grande Street
Austin, TX  78701

Phone: (512)-223-3358
email: vince at austincc.edu
       vmcgarry at austin.rr.com







More information about the PSTricks mailing list