- I would first apply nondimensionalization procedure to all values that go into the numerical integrator to bring their floating-point exponent as close to 0 as possible. This will alleviate some of of issues with doubles’ precision. Then go from there. Erlang’s integers are bigint, so, at the first glance, one may use fixed-point or rational arithmetic for this procedure and stay in pure Erlang. …Or just do floating point arithmetic for that purpose: loss of precision will occur once, rather than repeatedly. …Or just use your CAS to calculate the constants.
- I haven’t worked with floats in Erlang that much, but AFAIK they are regular machine floats under the hood (modulo error handling), so normal procedures should apply.
- These look like two separate questions: one about data structures, and another about NIFs. First question: generally, one should use ETS when data is accessed from multiple processes, otherwise local data structures (map or a list) may be faster. Second question: as usual, one should be extremely careful with NIFs, as they can mess up the BEAM scheduler, among other things. Before rolling your own, perhaps first consider the existing ones, like Elixir’s nx. (Disclaimer: I haven’t used that one)
- See 2.
I would appreciate insights from those experienced with scientific-style workloads on the BEAM VM.
Well, I haven’t done such things in BEAM, only in ol’ CUDA back in the day, so take this answer for what it’s worth.