# Discrete systems in MTK

**URL:** <https://discourse.julialang.org/t/discrete-systems-in-mtk/98602>\
**Category:** Modelling & Simulations\
**Tags:** question, discretization, modelingtoolkit\
**Created:** [May 10, 2023, 9:09am UTC](https://discourse.julialang.org/t/discrete-systems-in-mtk/98602 "2023-05-10T09:09:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![HamzaKh99](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hamzakh99/32/49279_2.png) [@HamzaKh99](https://discourse.julialang.org/u/HamzaKh99)\
**Post date:** [May 10, 2023, 9:09am UTC](https://discourse.julialang.org/t/discrete-systems-in-mtk/98602/1 "2023-05-10T09:09:44Z")

</div>

Hello everyone!  
I’m trying to do a discrete system example, using Difference and Differential functions, when I create the ODEProblem without structural\_simplify() I get the results I want.

`using ModelingToolkit

using DifferentialEquations

using Plots

@parameters t

@variablesy(t)=0 x(t)=0

dt = 0.1

Δ = Difference(t; dt=dt,update=true)

D = Differential(t)

eqs = [

Δ(x) ~ t

D(y) ~ x

]

@named sys = ODESystem(eqs,t)

prob = ODEProblem(sys, , (0,1), )

sol = solve(prob, adaptive=false, dt=dt)

plot(sol)`  
[![image](https://global.discourse-cdn.com/julialang/original/3X/6/6/66de89ca1de00fef835deedf15d63b00e2d118a8.png)](https://user-images.githubusercontent.com/9450625/237062220-142c12a9-b422-4d28-aae5-3195ecadc279.png)

But when I use structural\_simplify() It gives me this error:  
`sys_simp=structural_simplify(sys) ERROR: ExtraVariablesSystemException: The system is unbalanced. There are 3 highest order derivative variables and 2 equations. More variables than equations, here are the potential extra variable(s): y(t) x(t)`  
I think it deletes the difference equation, is there a solution to avoid this problem? it’s important for me to keep structural\_simplify().

---

<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:** [May 10, 2023, 12:00pm UTC](https://discourse.julialang.org/t/discrete-systems-in-mtk/98602/2 "2023-05-10T12:00:08Z")

</div>

can you open this as an issue?
