Is it possible to implement an equivalent syntax of (*x {\f(x)}) but the ordinate is specified first?

PSTricks provides us with a useful syntax (*x {\f(x)}) to specify a point with abscissa x and ordinate \f(x). For example, let \def\f(#1){#1+.5}, a point (1,1.5) can be written as (*1 {\f(x)}).

I want to have the opposite way in which the ordinate is given first and the abscissa is calculated by the given expression \g(y). For example, let \def\g(#1){#1-.5}, I want to have a point (1,1.5) but it has to be represented in the form (**{\g(y)} 1.5).

Is it possible to implement it? I will give 4 bounties of 500 each if you can implement it.

• What should (+{\f(x)} 4) return with \def\f(#1){#1*#1}? Functions happen to be non invertible. – egreg Jun 24 '13 at 17:42
• If the function is $f(x)=x^2$, giving the value 4 doesn't determine $x$ such that $x^2=4$. But even if the function is invertible, the inverse cannot generally be computed easily. Think to $f(x)=x+e^x$; only with numeric methods you can approximate the point where its value is 20. – egreg Jun 24 '13 at 17:50
• god damn non invertible functions. – Nicholas Hamilton Jun 26 '13 at 19:45
• Finding g(y) which is the inverse of f(x) is beyond the scope of this question. Therefore this question was given as is without considering the issue of inverse function. – kiss my armpit Jun 26 '13 at 19:53

\documentclass[pstricks,border=5mm]{standalone}
\usepackage{pst-node}
\makeatletter
\define@boolkey[psset]{}[Pst@]{exchange}[true]{}
\psset{exchange=false}

\def\alg@@@coor#1 #2{%          algebraic PostScript code
\edef\pst@coor{%
/x #1 def
/Func (#2) AlgParser cvx def
x Func \ifPst@exchange exch \fi
\tx@ScreenCoor }}
\makeatother
\begin{document}

\def\f(#1){#1^2}
\begin{pspicture}[showgrid](5,5)
\psline{->}(*2 {x^2})
\psline[exchange]{->}(*2 {x^2})
{\psset{exchange}\pnode(*2 {\f(x)}){A}}
\psline[linecolor=red](1,1)(A)(2;45)(*2 {\f(x)})
\end{pspicture}
\end{document}

or with the current version of pstricks.tex from http://texnik.dante.de/tex/generic/pstricks/

\documentclass[pstricks,border=5mm]{standalone}
\usepackage{pst-node}
\begin{document}

\def\f(#1){#1^2}
\def\y{2}
\begin{pspicture}[showgrid](5,5)
\psline{->}(*2 {x^2})
\psline{->}(**{y^2} 2)
\psline[linecolor=red](1,1)(**{\f(y)} 2.2)(2;45)(*2 {\f(x)})

\psline[linecolor=blue]{->}(+{sqrt(2),\f(x)})
\psline[linecolor=blue]{->}(+{sqrt(3)},{\f(x)})
\psline(+1,x+.5)
\end{pspicture}
\end{document} • (+x,f(x)) is not possible because TeX takes the first ) as closing delimiter for the complete coordinate argument. This is the way how TeX reads arguments. You have to choose ({+x,f(x)}) or (+x,{f(x)}). It is the same as for optional arguments: [foo=[x]] must be written as [foo={[x]}]. However I uploaded a new version for the other problem. – user2478 Jun 25 '13 at 6:55
• \psarc{->}{5}{0}{90} is possible, but not\psarc{5}{0}{90}. Otherwise we have to do a special check for the first argument if it is an arrow or not. – user2478 Jun 25 '13 at 17:57