Describe ChrisBatho/TestC here.
|
This is The Control Panel
May was the pioneer who first detected the onset of chaos in this population model.
«Mays Equation»=
NB. May's Equation;- xn=rx(1-x)
NB. By Chris Batho and Oleg Kobchenko for J601 v1.01
NB. http://www.jsoftware.com/jwiki/Scripts/mays equation
NB.===========================================================
The main function ie Mays equation.
«Mays Equation»=
may=: 3 : 0 NB. main function
'Rval Rinc'=: y
NB. nom val Rval:- 2.6 2.75 3.00 3.55 3.75 Rinc:-0.00015
r=: Rval
X=: 0.6
[R=: r
[NX=: X
ctr=:0
while. (ctr < 66000) *. (X > 0.01) do.
r=: r + Rinc
z=: (r*X)*(1-X)
X=: z
[R=: R, r
[NX=: NX, X
ctr=: ctr + 1
j=. ctr%450
pct=: (3.994-Rval)%Rinc
j=. (ctr*100)%pct
wd 'set progress ',":j
end.
)
NB.===========================================================
|
This is a sample plot
The GUI Viewer.
«Mays Equation»=
require 'graph numeric trig plot strings'
view=: 3 : 0 NB. viewer
'nRval nRinc'=: y
may nRval, nRinc
pd 'axes 1 1'
pd 'labels 1'
pd 'viewsize 2'
pd 'color darkblue'
pd 'pensize 1'
'type dot; title The Equation of May (R v X); framebackcolor white' plot R; NX
)
NB.===========================================================
Window Control.
«Mays Equation»=
require 'printf plot strings' MAY=: 0 : 0 pc May;pn "Mays equation"; menupop "File"; menu new "&New" "" "" ""; menu open "&Open" "" "" ""; menusep; menu exit "&Exit" "" "" ""; menupopz; xywh 153 12 41 11;cc editRstart edit; xywh 154 37 41 11;cc editRinc edit; xywh 162 2 27 10;cc static1 static;cn "R Start "; xywh 165 26 23 10;cc static2 static;cn "R Inc."; xywh 27 37 34 11;cc bnPlot button;cn "Plot"; xywh 21 20 50 11;cc progress progress; xywh 24 8 46 10;cc static3 static;cn "Plot Progress"; xywh 73 49 75 30;cc stDesc static; pas 6 6;pcenter; rem form end; )
Execution
«Mays Equation»=
May_run=: 3 : 0 wd MAY NB. initialize form here wd 'set editRstart 3.55' wd 'set editRinc 0.000035' j=: 0 wd 'set progress ',":j wd 'set stDesc *',Desc rplc LF;'' wd 'pshow;' )
Go control.
«Mays Equation»=
May_bnPlot_button=: 3 : 0 fire'' 'Plot completed 'printf here=: '' ) May_close=: 3 : 0 wd'pclose' )
Go
«Mays Equation»=
fire=: 3 : 0
m=: 1>.{.0".editRstart
n=: ".editRinc
view m, n
)
A warning to the user should you select very small values.
«Mays Equation»=
Desc =: 0 : 0 Take care. A small value of Rinc causes a long Plot time. )
Run.
«Mays Equation»=
May_run''
An Example of a simple diagnostic test if required for debugging.
«Mays Equation»=
NB.view 3.55 0.00015
Progress button (no additional control here.)
«Mays Equation»=
May_progress_button=: 3 : 0 )


