Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lisp, OCaml or what for Runge Kutta?

Which language would you propose for solving a system with:

  • first order differential equations
  • complex variables
  • N-dimensions

using 4th order Runge Kutta or the like.

Speed matters a lot but would sacrifice for:

  • Elegant (clean and short) code
  • Flexibility + scalability

I'm mostly between a Lisp and OCaml but any other suggestion is welcomed.

Thanks!

like image 447
Eelvex Avatar asked May 25 '10 19:05

Eelvex


2 Answers

Here's an implementation of RK in Common Lisp:

http://github.com/bld/bld-ode/blob/master/rk.lisp

The nice thing about Common Lisp is that you can start with simple and elegant code and then make the critical bits run fast (e.g. by switching from mostly functional to stateful computation, or by declaring types).

SBCL has an excellent native-code compiler.

like image 53
Leslie P. Polzer Avatar answered Sep 28 '22 01:09

Leslie P. Polzer


RK4 is a very basic method, and there lots of excellent implementations that are already written. Use one of them, and spend your effort on other aspects of the project.

like image 25
Stephen Canon Avatar answered Sep 28 '22 01:09

Stephen Canon