NB. Cauchy Curve Examples
NB. J Script, September 2008
NB. William R. Jones & Cliff Reiter
NB. Run in small selections to see
NB. all the samples

require 'plot'

NB. path to save images if desired
NB. pathf=:'c:\temp\'

NB. utilities and addon
require 'plot bmp'
require '~addons/media/image3/prevare.ijs'

NB. save plot utility
splot=:3 : 0
pd 'save bmp c:\temp\temp.bmp 720 720'
b=.readbmp 'c:\temp\temp.bmp'
(256 256 256#:b)write_image y
)

NB. complex parametrization of unit circle
r=: ^@j.

r steps 0 2p1 3

$C=:r steps 0 2p1 10000

cplot=: 'Aspect 1;pensize 2'&plot

cplot C
NB. splot pathf,'fig01.png'

NB. differences approx differential
diff=: }. - }:

mdpt=: [: -: }. + }:

f=:1 + 3 * ^&3

+/(f mdpt C) * diff C

cplot +/\(f mdpt C) * diff C

NB. CAUchycuRVE
chycu=:1 : 0
0,+/\(u mdpt y) * diff y
:
x&u chycu y
)

NB. plot cauchy curve
cplot f chycu C
NB. splot pathf,'fig02.png'

NB. cauchy curve and magnitude
cplot ^&5 chycu C

cmplot=: 1 : 0
z=.u chycu y
opts=.'pensize 2;aspect 1;penstyle 0 1'
opts plot z,:(|z)r. 12 o.y
)

NB. see dashes with fewer points
^&5 cmplot sC=:r steps 0 2p1 200
NB. splot pathf,'fig03.png'

(1+9*^&8) cmplot sC
NB. splot pathf,'fig04.png'

NB. rational functions
f=:1 0 0 0 0 0 2&p.%1.01+^&12
lC=:r steps 0 2p1 30000
cplot f chycu lC
NB. splot pathf,'fig05.png'

NB. plots cauchy path for all x&u
NB. show a family
cfplot=:1 : 0
:
opts=.'pensize 2;aspect 1;itemcolor '
opts=.opts,":,Hue steps 0 2r3 ,#x
opts plot x u chycu"_1 _ y
)

NB. circles
(2+i.11) (]^[) cfplot C
NB. splot pathf,'fig06.png'

NB. heart family
fh6=:1 0 0 0 0 0 2&p.@] % 1.01+]^[
lC=:r steps 0 2p1 30000
({.,{:)a=: 12*1.07^ steps 0 0.36 100
a fh6 cfplot lC
NB. splot pathf,'fig07.png'

NB. cos family
({.,{:) a=: 4*0.9^steps 0 1 50
a cos@:([**:@]) cfplot C
NB. splot pathf,'fig08.png'

NB. alternate initial paths
NB. pp: point to point adverb
pp=: 2 : '(m&*@-.+n&*)@(1&|)'
ss=: _1j_1 pp  1j_1
ee=: 1j_1 pp  1j1
nn=: 1j1  pp _1j1
ww=: _1j1  pp _1j_1

NB. rsq: complex para of +-1 square
rsq=:ss`ee`nn`ww@.(4|<.)"0

sq=: rsq steps 0 4 50000

(2+i.11) (]^[) cfplot sq
NB. splot pathf,'fig09.png'

$ell=:(cos j. 0.9 * sin)steps 0 2p1 30000

(12*1.07^ steps 0 0.5 100) fh6 cfplot ell
NB. splot pathf,'fig10.png'

NB. 3 mk_html_gallery _320 _280 images_in pathf