# New blog post on banded matrices and ordinary differential equations using BandedMatrices.jl

**URL:** https://discourse.julialang.org/t/new-blog-post-on-banded-matrices-and-ordinary-differential-equations-using-bandedmatrices-jl/18564
**Category:** Numerics
**Tags:** announcement
**Created:** [December 11, 2018, 4:10pm UTC](https://discourse.julialang.org/t/new-blog-post-on-banded-matrices-and-ordinary-differential-equations-using-bandedmatrices-jl/18564 "2018-12-11T16:10:04Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![dlfivefifty](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlfivefifty/32/1959_2.png) [@dlfivefifty](https://discourse.julialang.org/u/dlfivefifty)
#### Post date: [December 11, 2018, 4:10pm UTC](https://discourse.julialang.org/t/new-blog-post-on-banded-matrices-and-ordinary-differential-equations-using-bandedmatrices-jl/18564/1 "2018-12-11T16:10:04Z")

</div>

I just posted my first blog post, on using BandedMatrices.jl to solve ordinary differential equations via finite differences / spectral methods: [Banded matrices and ordinary differential equations](https://approximatelyfunctioning.blogspot.com/2018/12/banded-matrices-and-ordinary.html)

This is first of a series outlining the results of the NumFocus small development grant to add support for GPUs and other backends to BlockBandedMatrices.jl

---

<div class="post-metadata">

### Author: ![dlfivefifty](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlfivefifty/32/1959_2.png) [@dlfivefifty](https://discourse.julialang.org/u/dlfivefifty)
#### Post date: [December 12, 2018, 2:10pm UTC](https://discourse.julialang.org/t/new-blog-post-on-banded-matrices-and-ordinary-differential-equations-using-bandedmatrices-jl/18564/2 "2018-12-12T14:10:20Z")

</div>

I accidentally posted an old working draft. I’ve uploaded the correct version which has some minor changes.

---

<div class="post-metadata">

### Author: ![isaacsas](https://avatars.discourse-cdn.com/v4/letter/i/f6c823/32.png) [@isaacsas](https://discourse.julialang.org/u/isaacsas)
#### Post date: [December 12, 2018, 3:07pm UTC](https://discourse.julialang.org/t/new-blog-post-on-banded-matrices-and-ordinary-differential-equations-using-bandedmatrices-jl/18564/3 "2018-12-12T15:07:48Z")

</div>

This is a very nice article and introduction to BandedMatrices.jl, thanks! It is disheartening to hear about the OpenBlas issues with banded solvers since installing MKL with Julia still requires some extra work…

A few very minor comments/typos in case you are updating it at some point:

1. It would be nice if you could make the width of your text and code boxes larger. Right now many of the code boxes require horizontal scrolling to read all the text. (At least on Chrome on my Mac.)
2. Right at the start of section 2 you say j=1,2,\dots,n. I assume you meant, k=1,2,\dots,n.
3. When plotting the coefficients your code says: `.+ 1E-40` in a comment but actually uses `1E-100`.
4. Where you `btime` the `lu(L)` and `lu(L̃)` I assume the comment for the latter meant `pivoted LU for sparse matrices`?

---

<div class="post-metadata">

### Author: ![jlapeyre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlapeyre/32/4514_2.png) [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)
#### Post date: [December 12, 2018, 3:16pm UTC](https://discourse.julialang.org/t/new-blog-post-on-banded-matrices-and-ordinary-differential-equations-using-bandedmatrices-jl/18564/4 "2018-12-12T15:16:22Z")

</div>

Me too on the boxes and scrolling.

---

<div class="post-metadata">

### Author: ![dlfivefifty](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlfivefifty/32/1959_2.png) [@dlfivefifty](https://discourse.julialang.org/u/dlfivefifty)
#### Post date: [December 12, 2018, 3:17pm UTC](https://discourse.julialang.org/t/new-blog-post-on-banded-matrices-and-ordinary-differential-equations-using-bandedmatrices-jl/18564/5 "2018-12-12T15:17:09Z")

</div>

> It would be nice if you could make the width of your text and code boxes larger. Right now many of the code boxes require horizontal scrolling to read all the text. (At least on Chrome on my Mac.)

Yes, the formatting still could use improvement. Part of the issue is the Weave.jl generates raw HTML, and only Blogger supports this from what I can tell. Blogger is a bit daunting and I haven’t figured out the “right” way to adjust the default layout. In particular, I don’t know why the column of text is so narrow.

Your corrections are correct, thanks.

---

<div class="post-metadata">

### Author: ![dlfivefifty](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlfivefifty/32/1959_2.png) [@dlfivefifty](https://discourse.julialang.org/u/dlfivefifty)
#### Post date: [December 12, 2018, 4:40pm UTC](https://discourse.julialang.org/t/new-blog-post-on-banded-matrices-and-ordinary-differential-equations-using-bandedmatrices-jl/18564/6 "2018-12-12T16:40:31Z")

</div>

I’ve increased the widths, does this improve things for you?

---

<div class="post-metadata">

### Author: ![antoine-levitt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/antoine-levitt/32/4008_2.png) [@antoine-levitt](https://discourse.julialang.org/u/antoine-levitt)
#### Post date: [December 12, 2018, 5:09pm UTC](https://discourse.julialang.org/t/new-blog-post-on-banded-matrices-and-ordinary-differential-equations-using-bandedmatrices-jl/18564/7 "2018-12-12T17:09:30Z")

</div>

Very interesting! Do you have an idea of the trade-offs (in terms of bandwith size perhaps) between this approach and that of using iterative solvers with FFTs to do the matvecs?

---

<div class="post-metadata">

### Author: ![isaacsas](https://avatars.discourse-cdn.com/v4/letter/i/f6c823/32.png) [@isaacsas](https://discourse.julialang.org/u/isaacsas)
#### Post date: [December 12, 2018, 5:54pm UTC](https://discourse.julialang.org/t/new-blog-post-on-banded-matrices-and-ordinary-differential-equations-using-bandedmatrices-jl/18564/8 "2018-12-12T17:54:30Z")

</div>

New widths look much better to me!

---

<div class="post-metadata">

### Author: ![dlfivefifty](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlfivefifty/32/1959_2.png) [@dlfivefifty](https://discourse.julialang.org/u/dlfivefifty)
#### Post date: [December 12, 2018, 5:56pm UTC](https://discourse.julialang.org/t/new-blog-post-on-banded-matrices-and-ordinary-differential-equations-using-bandedmatrices-jl/18564/9 "2018-12-12T17:56:07Z")

</div>

Under practically all circumstances iterative methods are not competitive for ODEs, and this is certainly the case for singularly perturbed examples where one would need a very good preconditioner to overcome the ill-conditioning. I don’t know of such a preconditioner.

PDEs are a different story as the complexity of applying an operator is better than inverting an operator. I’ll talk about PDEs in the next post.

---

<div class="post-metadata">

### Author: ![matthieu](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@matthieu](https://discourse.julialang.org/u/matthieu)
#### Post date: [December 12, 2018, 6:45pm UTC](https://discourse.julialang.org/t/new-blog-post-on-banded-matrices-and-ordinary-differential-equations-using-bandedmatrices-jl/18564/10 "2018-12-12T18:45:36Z")

</div>

Great work. I like the package and your notes. I never thought about obtaining the fourth derivative matrix as a multiplication of two central derivative matrices — very nice!. Looking forward to the PDE notes.

---

<div class="post-metadata">

### Author: ![jlapeyre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlapeyre/32/4514_2.png) [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)
#### Post date: [December 12, 2018, 8:47pm UTC](https://discourse.julialang.org/t/new-blog-post-on-banded-matrices-and-ordinary-differential-equations-using-bandedmatrices-jl/18564/11 "2018-12-12T20:47:56Z")

</div>

I’m not sure. On my screen, there’s still more than twice as much horizontal empty space as there is scroll box. I guess if your tools don’t make a “responsive” page, there’s not much you can do… I wouldn’t want the text to fill all the space anyway.

---

<div class="post-metadata">

### Author: ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)
#### Post date: [December 12, 2018, 9:09pm UTC](https://discourse.julialang.org/t/new-blog-post-on-banded-matrices-and-ordinary-differential-equations-using-bandedmatrices-jl/18564/12 "2018-12-12T21:09:06Z")

</div>

Nice post and blog !  
I wonder about the opportunity to add fixed size bandwidth (tri/penta/hepta/N-diag) specializations. We implement such N-diag matrices julia types for one of our’s PDE solver and I should compare the performance with this package. We usually use in-place LLT or LDT factorization to solve corresponding symmetric systems.

---

<div class="post-metadata">

### Author: ![dlfivefifty](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlfivefifty/32/1959_2.png) [@dlfivefifty](https://discourse.julialang.org/u/dlfivefifty)
#### Post date: [December 12, 2018, 9:14pm UTC](https://discourse.julialang.org/t/new-blog-post-on-banded-matrices-and-ordinary-differential-equations-using-bandedmatrices-jl/18564/13 "2018-12-12T21:14:22Z")

</div>

This sounds like `StaticArray` v regular array. I don’t think there’s much benefit though in knowing the bandwidths at compile time, as one is usually dealing with large dimensional problems where the actual computation swamps things.

---

<div class="post-metadata">

### Author: ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)
#### Post date: [December 12, 2018, 9:28pm UTC](https://discourse.julialang.org/t/new-blog-post-on-banded-matrices-and-ordinary-differential-equations-using-bandedmatrices-jl/18564/14 "2018-12-12T21:28:42Z")

</div>

Yes, In our cases which maybe not generally relevant, the inner loop operates through the bandwidth. When it is known statically, the loop is unrolled and this can lead to significant speed-up. This is the case for a cholesky factorization for instance. We define our own macros for this purpose but I guess that it maybe implemented efficiently with StaticArrays.

---

<div class="post-metadata">

### Author: ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)
#### Post date: [December 12, 2018, 9:33pm UTC](https://discourse.julialang.org/t/new-blog-post-on-banded-matrices-and-ordinary-differential-equations-using-bandedmatrices-jl/18564/15 "2018-12-12T21:33:54Z")

</div>

I forgot to mention that we deal with larges systems but small bandwidths (3-9).

---

<div class="post-metadata">

### Author: ![dlfivefifty](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlfivefifty/32/1959_2.png) [@dlfivefifty](https://discourse.julialang.org/u/dlfivefifty)
#### Post date: [December 12, 2018, 9:39pm UTC](https://discourse.julialang.org/t/new-blog-post-on-banded-matrices-and-ordinary-differential-equations-using-bandedmatrices-jl/18564/16 "2018-12-12T21:39:25Z")

</div>

If you are sure knowing that at compile time is useful then it’s a good argument. But it would need a new `SBandedMatix` type that knows the bandwidths in the template variables.

---

<div class="post-metadata">

### Author: ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)
#### Post date: [December 12, 2018, 9:41pm UTC](https://discourse.julialang.org/t/new-blog-post-on-banded-matrices-and-ordinary-differential-equations-using-bandedmatrices-jl/18564/17 "2018-12-12T21:41:07Z")

</div>

That is exactly what we have implemented.

---

<div class="post-metadata">

### Author: ![dlfivefifty](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlfivefifty/32/1959_2.png) [@dlfivefifty](https://discourse.julialang.org/u/dlfivefifty)
#### Post date: [December 13, 2018, 12:04am UTC](https://discourse.julialang.org/t/new-blog-post-on-banded-matrices-and-ordinary-differential-equations-using-bandedmatrices-jl/18564/18 "2018-12-13T00:04:51Z")

</div>

Please make a PR if you think it’s of general use

---

<div class="post-metadata">

### Author: ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)
#### Post date: [December 19, 2018, 11:26am UTC](https://discourse.julialang.org/t/new-blog-post-on-banded-matrices-and-ordinary-differential-equations-using-bandedmatrices-jl/18564/19 "2018-12-19T11:26:38Z")

</div>

Hi,

I have tried your package on a 2d problem and it is quite slower than using `sparse`. My matrix line numbers is `Nx * Ny`, same for columns. It has 5 bands at 0, ±1, ±Nx. It seems that you store a big matrix to hold this banded structure and that may be the reason of the slowdown I am experiencing. Do you have any further advice please?

Thank you

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [December 19, 2018, 12:10pm UTC](https://discourse.julialang.org/t/new-blog-post-on-banded-matrices-and-ordinary-differential-equations-using-bandedmatrices-jl/18564/20 "2018-12-19T12:10:37Z")

</div>

I wouldn’t expect a banded matrix structure to do well there since you want something like “dense bandedness”. But @dlfivefifty have you considered this kind of “sparse bandedness”?

[Next page](https://discourse.julialang.org/t/new-blog-post-on-banded-matrices-and-ordinary-differential-equations-using-bandedmatrices-jl/18564.md?page=2)
