Skip to content

Instantly share code, notes, and snippets.

@shirok
Created April 24, 2021 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shirok/e579bbb1fc6ad0fcf48f2c1dc837e9d1 to your computer and use it in GitHub Desktop.
Save shirok/e579bbb1fc6ad0fcf48f2c1dc837e9d1 to your computer and use it in GitHub Desktop.
<html>
<body>
<form action="#">
α: <input type="text" id="α" value="0.008"/>
σ: <input type="text" id="σ" value="0.05"/>
μ: <input type="text" id="μ" value="-0.496"/>
<button type="button" onclick="plot()">redraw</button>
</form>
<canvas id="canvas" width="1000" height="1000"></canvas>
<script><!--
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
const N0 = 2000, Nmax = 100000;
const x0 = 10.0, y0 = 10.0;
function dot(x, y) {
ctx.fillRect((x+20)*canvas.width/40, (20-y)*canvas.height/40, 1, 1);
}
function gm(α, σ, μ) {
function step(x, y) {
var x1 = y + α*y*(1-σ*y*y) + μ*x + 2*(1-μ)*x*x/(1+x*x);
var y1 = -x + μ*x1 + 2*(1-μ)*x1*x1/(1+x1*x1);
return [x1, y1];
}
var x = x0, y = y0, i = 0;
for (; i < N0; i++) {
[x, y] = step(x, y);
}
for (; i < Nmax; i++) {
[x, y] = step(x, y);
dot(x, y);
}
}
function plot() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
gm(parseFloat(document.getElementById('α').value),
parseFloat(document.getElementById('σ').value),
parseFloat(document.getElementById('μ').value));
}
plot();
-->
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment