# Non-Diagonal SDE with matrix variables

**URL:** https://discourse.julialang.org/t/non-diagonal-sde-with-matrix-variables/82351
**Category:** Modelling & Simulations
**Tags:** diffeq, sde
**Created:** [June 6, 2022, 11:37pm UTC](https://discourse.julialang.org/t/non-diagonal-sde-with-matrix-variables/82351 "2022-06-06T23:37:00Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![thobili](https://avatars.discourse-cdn.com/v4/letter/t/e47774/32.png) [@thobili](https://discourse.julialang.org/u/thobili)
#### Post date: [June 6, 2022, 11:37pm UTC](https://discourse.julialang.org/t/non-diagonal-sde-with-matrix-variables/82351/1 "2022-06-06T23:37:00Z")

</div>

I was trying to apply the method described at

[https://diffeq.sciml.ai/stable/tutorials/sde\_example/#Example-4:-Systems-of-SDEs-with-Non-Diagonal-Noise](https://diffeq.sciml.ai/stable/tutorials/sde_example/#Example-4:-Systems-of-SDEs-with-Non-Diagonal-Noise)

for a matrix valued variable, e.g.

```julia
f(du,u,p,t) = du .= 1.01u
function g(du,u,p,t)
  du[1,1,1] = 1.0
  du[1,2,1] = 1.0
    
  du[2,1,2] = 1.0
  du[2,2,2] = 1.0
    
  du[3,1,3] = 1.0
  du[3,2,3] = 1.0
end
prob = SDEProblem(f,g,ones(3,2),(0.0,1.0),noise_rate_prototype=zeros(3,2,3))

```

with the intention that the last dimension of the noise\_rate\_prototype would define the number of independent Wiener processes, and would be matrix multiplied over to get the right dimensions for my matrix variable.

Unfortunately, this doesn’t work, and I was wondering if this is just not supported, or what the correct syntax for such a system would be.

Many thanks for your help!

---

<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: [June 7, 2022, 11:07am UTC](https://discourse.julialang.org/t/non-diagonal-sde-with-matrix-variables/82351/2 "2022-06-07T11:07:57Z")

</div>

Open an issue. Its definition is `g(u,p,t)*dW`, so `dW` is always a vector. So then `noise_rate_prototype` always needs to be a matrix. That means `f` has to be vector defined in any case of non-diagonal noise. I think we can generalize it, but that’s how the linear algebra works out today.
