I have now rederived the equations more precisely and formally in terms of the cylinder radius.
If i=horizontal dimension of output, xc=horizontal center, xs is horizontal dimension of input, then the forward equation in width is
i-xc = R*sin((pi/2)*(xs-xc)/xc)
Inverting this, we get
xs = (2*xc/pi)*asin((i-xc)/R) + xc
Thus as an absolute displacement usng fx one has:
infile="img5967.jpg"
radius=40
dx=1
width=`identify -format %w $infile`
height=`identify -format %h $infile`
xc=`echo "scale=1; ($width - 1) / 2" | bc`
ipid2=`echo "scale=6; 1/(2*a(1))" | bc -l`
ffx="ffx=$ipid2*asin(xd);"
[ "$dx" != "1" ] && ffx="ffx=sign(xd)*($ipid2*asin(abs(xd)))^$dx;"
convert -monitor $tmpA -virtual-pixel $vp -fx \
"xd=(i-$xc)/$radius; $ffx xs=$xc*ffx+$xc; u.p{xs,j}" \
$outfile
which looks quite reasonable.
Using a relative displacement from composite displace one gets:
radius=40
amp=40
dx=1
width=`identify -format %w $infile`
height=`identify -format %h $infile`
xc=`echo "scale=1; ($width - 1) / 2" | bc`
ipid2=`echo "scale=6; 1/(2*a(1))" | bc -l`
ffx="ffx=$ipid2*asin(xd);"
[ "$dx" != "1" ] && ffx="ffx=sign(xd)*($ipid2*asin(abs(xd)))^$dx;"
convert -monitor -size ${width}x1 xc: -virtual-pixel $vp -fx \
"xd=(i-$xc)/$radius; $ffx xs=0.5*ffx+0.5; xd>1?1:xs" \
-scale ${width}x${height}! \
tmp0.png
composite tmp0.png $infile -virtual-pixel black -displace ${amp}x0 $outfile
which is not quite as similar as I would have expected or liked.
However, if I apply an exponent dx=2 to the formula above for the relative distortion, I do get something more similar to the absolute distortion version (using dx=1)
So I am still puzzled about converting an absolute displacement to a relative one to gain speed without losing precision.
Is this exaggeration needed in the relative distortion to compensate for the fact that in the absolute distortion the range was -1 to +1 (ie a range of 2) and in the relative distortion the range was 0 to 1 (ie a range of 1). Thus some kind of (non-linear?) amplification of a factor of 2 is needed?