NB. Elliptic Curve Julia Sets
NB. Cliff Reiter -- revisiting work with Beth Golebewski 
NB. and Sandy Balkin that appeared in 
NB. Sandy D. Balkin, Elizabeth L. Golebiewski, and Clifford A. Reiter,
NB. Chaos and Elliptic Curves, Computers & Graphics, 18 1 (1994)113-117.

require 'fvj2\chaotica+'

NB. adverb to create f(x) from list of coefficients
EC=:1 : '%:@((m.,1)&p.)'

f4=: 0.008j_0.186 0 0j1 EC  NB. f for figure 4 from the reference

NB. creates the julia escape time step
j_step=:1 : 'u.@{. , >:@{:'
j_test=:1e20 255"_ *./ . > |

NB. finds the sample points
zl_clur2=: 4 : 0
w=.-~/9 o.y.
h=.-~/11 o.y.
(j.h-(+:h)*(i.%<:)>.x.*2*h%w) +/ ({.y.)+w*(i.%<:)x.

NB. [pixsize cenleft upright] f mk_julia filename.bmp
mk_julia=:1 : 0
100 _2 2j2 u. mk_julia y.
z=.({.x.) zl_clur2 }.x.
b=.({:@(u. j_step^:j_test^:_)@j_pre)"0 z
(P256;cln254 b*255~:b) writebmp8 y.

NB. leftmost argument is the pixel size
NB. this runs the function and creates the image file
120 _2 2j2 f4 mk_julia 'ec_julia.bmp'