# Solving a higher index DAE formulating it as a DAEProblem

**URL:** <https://discourse.julialang.org/t/solving-a-higher-index-dae-formulating-it-as-a-daeproblem/71741>\
**Category:** New to Julia\
**Tags:** diffeq, modelingtoolkit\
**Created:** [November 18, 2021, 7:59pm UTC](https://discourse.julialang.org/t/solving-a-higher-index-dae-formulating-it-as-a-daeproblem/71741 "2021-11-18T19:59:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jisnajohnson27](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jisnajohnson27/32/30186_2.png) [@jisnajohnson27](https://discourse.julialang.org/u/jisnajohnson27)\
**Post date:** [November 18, 2021, 7:59pm UTC](https://discourse.julialang.org/t/solving-a-higher-index-dae-formulating-it-as-a-daeproblem/71741/1 "2021-11-18T19:59:17Z")

</div>

I’m trying to solve a higher index DAE (say in my case index 3) system of equations formulating it directly as a DAEProblem without converting it into an ODEProblem.

Going through the documentation I could find only examples that utilizes index reduction in modelingtoolkit.jl and further solving it as an ODEProblem. I’m looking further into solving it as a DAEProblem.

Is there a possible way to do that ? If so, with what solvers ?

Here is a simple case of equations of pendulum where we encounter a DAE system of index 3. The code below gives me an error message ‘convergence failure’ as I have directly attempted to solve it without index reduction. Can I get any possible help to reduce its index and further solving it as a DAEProblem ?

```julia
using DifferentialEquations, ModelingToolkit  
using LinearAlgebra, DASKR

function f(out, da, a, p, t)    
   (L, m, g) = p
   u, v, x, y, T = a
   du, dv, dx, dy, dT = da
   out[1] = x*T/(m*L) - du
   out[2] = y*T/(m*L) - g - dv
   out[3] = u - dx
   out[4] = v - dy
   out[5] = u^2 + v^2 - L^2
   nothing
end

u0 = zeros(5)
u0[3] = 1.0
du0 = zeros(5)
du0[2] = 9.81

p = [1,1,9.8]
tspan = (0.,100.)
differential_vars = [true, true, true, true, false]

prob = DAEProblem(f, du0, u0, tspan, p, differential_vars = differential_vars)
sol=solve(prob,daskr())  

```

Thanking in advance…

---

<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:** [November 19, 2021, 3:36pm UTC](https://discourse.julialang.org/t/solving-a-higher-index-dae-formulating-it-as-a-daeproblem/71741/3 "2021-11-19T15:36:37Z")

</div>

> [@jisnajohnson27](#):
>
> Going through the documentation I could find only examples that utilizes index reduction in modelingtoolkit.jl and further solving it as an ODEProblem. I’m looking further into solving it as a DAEProblem.

Just call `DAEProblem` from ModelingToolkit on the sys. It can generate an ODEProblem, ODAEProblem, and the DAEProblem forms. You’ll need the MTK structural simplification to do the index reduction.

---

<div class="post-metadata">

**Author:** ![jisnajohnson27](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jisnajohnson27/32/30186_2.png) [@jisnajohnson27](https://discourse.julialang.org/u/jisnajohnson27)\
**Post date:** [November 19, 2021, 5:46pm UTC](https://discourse.julialang.org/t/solving-a-higher-index-dae-formulating-it-as-a-daeproblem/71741/4 "2021-11-19T17:46:26Z")

</div>

Great Thanks. It worked…
