# BDF solver crashing Stan 2.18 sampler

**URL:** <https://discourse.mc-stan.org/t/bdf-solver-crashing-stan-2-18-sampler/7617>\
**Category:** Developers\
**Tags:** rstan\
**Created:** [February 7, 2019, 12:48pm UTC](https://discourse.mc-stan.org/t/bdf-solver-crashing-stan-2-18-sampler/7617 "2019-02-07T12:48:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidmanheim](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/davidmanheim/32/282_2.png) [@davidmanheim](https://discourse.mc-stan.org/u/davidmanheim)\
**Post date:** [February 7, 2019, 12:48pm UTC](https://discourse.mc-stan.org/t/bdf-solver-crashing-stan-2-18-sampler/7617/1 "2019-02-07T12:48:43Z")

</div>

I tried re-running an older model in the newest version of stan, and it crashes. After investigating, it seems the stiff solver is no longer working.

Below is a minimal example that can be run (unsuccessfully, because it crashes,) in rstan. Note that if you switch from integrate\_ode\_bdf to integrate\_ode\_rk45, it runs successfully - so the issue may not relate to the integrator, but that’s what makes it happen here.

series = seq(0.1,9.2,1)

data\_ode=list(T = 10,  
y0 = c(1,0),  
t0=0,  
ts=series  
)

scode\_bdf \<- "  
functions {  
real[] sho(real t,  
real[] y,  
real[] theta,  
real[] x\_r,  
int[] x\_i) {  
real dydt[2];  
dydt[1] = y[2];  
dydt[2] = -y[1] - theta[1] \* y[2];  
return dydt;  
}  
}  
data {  
int\<lower=1\> T;  
real y0[2];  
real t0;  
real ts[T];  
}

transformed data {  
real x\_r[0];  
int x\_i[0];  
}  
parameters{  
real theta[1];  
}  
model {  
theta ~ normal(0.15,0.1);  
}  
generated quantities {  
real y\_hat[T,2] = integrate\_ode\_bdf(sho, y0, t0, ts, theta, x\_r, x\_i);  
// add measurement error  
for (t in 1:T) {  
y\_hat[t, 1] += normal\_rng(0, 0.1);  
y\_hat[t, 2] += normal\_rng(0, 0.1);  
}  
}  
"

fit\_bdf \<- stan(model\_code = scode\_bdf, data=data\_ode, iter = 10000, verbose = FALSE)

---

<div class="post-metadata">

**Author:** ![wds15](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/wds15/32/908_2.png) [@wds15](https://discourse.mc-stan.org/u/wds15)\
**Post date:** [February 7, 2019, 12:50pm UTC](https://discourse.mc-stan.org/t/bdf-solver-crashing-stan-2-18-sampler/7617/2 "2019-02-07T12:50:15Z")

</div>

Not nice! Can you please file an issue for this on our Stan-math repository? Thanks a lot!

---

<div class="post-metadata">

**Author:** ![davidmanheim](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/davidmanheim/32/282_2.png) [@davidmanheim](https://discourse.mc-stan.org/u/davidmanheim)\
**Post date:** [February 7, 2019, 1:49pm UTC](https://discourse.mc-stan.org/t/bdf-solver-crashing-stan-2-18-sampler/7617/3 "2019-02-07T13:49:57Z")

</div>

Done;[https://github.com/stan-dev/math/issues/552](https://github.com/stan-dev/math/issues/552)
