# Solving N-dimensional Coupled ODE Systems in DifferentialEquations Jl

**URL:** <https://discourse.julialang.org/t/solving-n-dimensional-coupled-ode-systems-in-differentialequations-jl/24629>\
**Category:** New to Julia\
**Created:** [May 26, 2019, 10:38pm UTC](https://discourse.julialang.org/t/solving-n-dimensional-coupled-ode-systems-in-differentialequations-jl/24629 "2019-05-26T22:38:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ben\_Hardisty](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ben_hardisty/32/8614_2.png) [@Ben\_Hardisty](https://discourse.julialang.org/u/Ben_Hardisty)\
**Post date:** [May 26, 2019, 10:38pm UTC](https://discourse.julialang.org/t/solving-n-dimensional-coupled-ode-systems-in-differentialequations-jl/24629/1 "2019-05-26T22:38:41Z")

</div>

So I’ve figured out how to make a simulation of the life-stages of some hypothetical model organism in R. I can use “N” as the number of life-stages, the number of differential equations to be solved, during each simulation. However, I would love to implement something much faster in Julia. In R, it’s somewhat convenient because I only have to put the first equation in explicitly and then R formulates the other differential equations depending upon my choice of N for that run of the simulation. The simulations as they are now take about 1.5 hours to run with moderate time-step, with smaller time-steps (which I’d prefer in my experiments) the sims take about 9 hours to run. Since the equation terms depend upon how many equations there are in total for each simulation, I’m having trouble figuring out how to form up a function in Julia. As in, how do I “tell” Julia, the first equation is solved, then the second, then the N-th.

---

<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 26, 2019, 11:40pm UTC](https://discourse.julialang.org/t/solving-n-dimensional-coupled-ode-systems-in-differentialequations-jl/24629/2 "2019-05-26T23:40:05Z")

</div>

> [@Ben\_Hardisty](#):
>
> Since the equation terms depend upon how many equations there are in total for each simulation, I’m having trouble figuring out how to form up a function in Julia. As in, how do I “tell” Julia, the first equation is solved, then the second, then the N-th.

You can use a loop. Or maybe make use of a tool like [GitHub - SciML/ModelingToolkit.jl: An acausal modeling framework for automatically parallelized scientific machine learning (SciML) in Julia. A computer algebra system for integrated symbolics for physics-informed machine learning and automated transformations of differential equations](https://github.com/JuliaDiffEq/ModelingToolkit.jl)

---

<div class="post-metadata">

**Author:** ![Ben\_Hardisty](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ben_hardisty/32/8614_2.png) [@Ben\_Hardisty](https://discourse.julialang.org/u/Ben_Hardisty)\
**Post date:** [June 11, 2019, 1:01am UTC](https://discourse.julialang.org/t/solving-n-dimensional-coupled-ode-systems-in-differentialequations-jl/24629/3 "2019-06-11T01:01:22Z")

</div>

Thanks for your very fast reply! I was able, in an hour, to sit down and code for some simple versions of my model, where there’s 2,3 or 5 equations. Julia runs fast! I definitely am coming around…
