5 ms·
The post describes essentially a spectral method for solving ODEs in the Taylor (monomial) basis. Haskell definitely makes it nice to play around with this, but
by johnbcoughlin 4y ago
The post describes essentially a spectral method for solving ODEs in the Taylor (monomial) basis. Haskell definitely makes it nice to play around with this, but the monomial basis is terribly ill conditioned and not a good choice for this application. The Chebyshev basis is much better. Anyone who finds this neat, I recommend checking out the chebfun family of packages. They use the same idea but with much more rigorous numerics.
- jamessb 4y ago> I recommend checking out the chebfun family of packages. There's also an introductory textbook about ODEs ("Exploring ODEs") that uses chebfun [2] throughout. As well as the original MATLAB implementation, there are now implementations in Julia, Python, and some other languages [3]. [1]: https://people.maths.ox.ac.uk/trefethen/ExplODE/ https://people.maths.ox.ac.uk/trefethen/ExplODE/ [2]: https://www.chebfun.org/ https://www.chebfun.org/ [3]: https://www.chebfun.org/about/projects.html https://www.chebfun.org/about/projects.html
- ChrisRackauckas 4y ago> The Chebyshev basis is much better The Chebyshev basis in time is still not great. This was used in Chebfun before but there's a note that for time to just use standard ODE solvers because it did not good performance. Collocation really only makes sense on BVPs.
- mturmon 4y agoThis comment and GP comment open up a helpful learning experience for a casual/occasional user like me. This distinction between initial value problems (IVP, one endpoint known, hence a “time” differential equation) and BVPs (both endpoints known, not “time”) also appears in this introduction to the Chebfun solvers: https://www.chebfun.org/docs/guide/guide07.html https://www.chebfun.org/docs/guide/guide07.html (last paragraph of sec 7.1) Following the breadcrumbs to the IVP treatment in chapter 10 https://www.chebfun.org/docs/guide/guide10.html https://www.chebfun.org/docs/guide/guide10.html (Sec 10.2) we read: A major change was introduced in Version 5.1 in how initial-value (and final-value) problems are solved. Before, Chebfun used the same global spectral representations as for BVPs. This usually works fine for linear problems, but for nonlinear ones, it is inferior to the method of time-stepping by Runge-Kutta or Adams formulas. In Chebfun Version 5.1, we accordingly switched to solving IVPs numerically by ode113 (by default), converting the resulting output to a Chebfun representation. Thanks again for the helpful comments.
- naillo 4y agoAnyone here (or the OP) know how you'd use chebyshev in a multivariate scenario? The wikipedia article only defines them for the 1d case.
- freemint 4y agoWhat exactly do you mean by multivariate?
- naillo 4y agoMore than one variable :) x/y/z etc
- freemint 4y agoThere are two ways differential equations can involve more than one variable. dx/dt = stuff dy/dt = stuff OR dt/dx = stuff dt/dy = stuff Require very different approaches.
- wheelinsupial 4y agoI think they might be asking about PDEs instead of ODEs in this case when they mentioned x, y, z as being multivariable.
- naillo 4y agoI wasn't actually gonna use them to solve a diff equation though to be honest :) I was just experimenting with denoising diffusion and instead of a u-net to infer the denoising step, I was thinking about using a multivariate polynomial. (Since if you express the output denoising as a linear combination of polynomials finding the denoiser just turns into linear algebra. Might be a big solve etc but inferene is way fast and it's nice to know that you have the global opimum.) I'm sitting at the code right this instant and was using x, y, xy, x^2y, xy^2, etc, but this thread inspired me to try out chebychev as a possible alternative. :)
- 4y ago