# Second order 2D differentiation DiffEqOperators.jl

**URL:** https://discourse.julialang.org/t/second-order-2d-differentiation-diffeqoperators-jl/77239
**Category:** Numerics
**Created:** [March 1, 2022, 1:41pm UTC](https://discourse.julialang.org/t/second-order-2d-differentiation-diffeqoperators-jl/77239 "2022-03-01T13:41:26Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![xtalax](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xtalax/32/35293_2.png) [@xtalax](https://discourse.julialang.org/u/xtalax)
#### Post date: [March 7, 2022, 2:17pm UTC](https://discourse.julialang.org/t/second-order-2d-differentiation-diffeqoperators-jl/77239/2 "2022-03-07T14:17:05Z")

</div>

Hi,

What you want to do is:

```julia
dx = 0.01
axis = collect(-1:dx:1);
umesh = [(i, j) for i in axis, j in axis];

sines((x,y)) = sin(pi*x)*sin(pi*y)
u = sines.(umesh)

Qx, Qy = Dirichlet0BC(Float64, size(u))

Dxx = CenteredDifference{1}(2,2,dx,N)
Dyy = CenteredDifference{2}(2,2,dx,N)

A = (Dxx + Dyy)*compose(Qx, Qy)

laplacian_of_u = A*u

```

Doing things in this way improves performance, as `DiffEqOperators` fuses the stencils of the operators, fusing loops and leveraging GPU convolutions from `NNlib`.

For the extension to 3D you do the obvious thing, note that the BC constructors return a variable number of `Q` operators depending on `ndims(u)`, and compose takes any number of arguments.

I’m working on DiffEqOperators and am happy to support if you have further questions, let me know how you get on!

---

_[View the full topic](https://discourse.julialang.org/t/second-order-2d-differentiation-diffeqoperators-jl/77239)._
