littleredcomputer / odex-js

Bulirsch-Stoer integration of systems of ordinary differential equations in JavaScript
BSD 2-Clause "Simplified" License
54 stars 5 forks source link

Code from example page? #2

Closed dantaeyoung closed 6 years ago

dantaeyoung commented 7 years ago

This is wonderful! Could you include the code from your example page (http://blog.littleredcomputer.net/math/odex/js/2016/04/03/lotka-volterra.html)? I'm particularly interested in how you're plotting the phase space.

littleredcomputer commented 6 years ago

Thanks for writing!

The source for all the demos is in my github-pages repo. So from here we can see that the graph is drawn by odexdemo.PredatorPrey, and the sourcefor that is here, which delegates to phaseDraw.

(I used this as an opportunity to dabble with Typescript. I enjoyed it but it is probably overkill just for the demo.)

So for the population, we draw the points (t, x(t)), (t, y(t)); for the phase, we draw the one point (x(t), y(t)).

dantaeyoung commented 6 years ago

Thanks for this! This was super helpful!