# DifferentialEquations Parameters

**URL:** <https://discourse.julialang.org/t/differentialequations-parameters/36289>\
**Category:** New to Julia\
**Tags:** question, package, diffeq\
**Created:** [March 21, 2020, 4:55am UTC](https://discourse.julialang.org/t/differentialequations-parameters/36289 "2020-03-21T04:55:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacob-roth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jacob-roth/32/1862_2.png) [@jacob-roth](https://discourse.julialang.org/u/jacob-roth)\
**Post date:** [March 21, 2020, 4:55am UTC](https://discourse.julialang.org/t/differentialequations-parameters/36289/1 "2020-03-21T04:55:03Z")

</div>

When passing parameters `p` to the function `f` of an `ODEProblem` (or any problem type in the DiffEq universe), does `p` always have to be an array? Is there a “best practices” reason for why I shouldn’t use `Dict`s to hold my parameters in my function definition `f`?

As a concrete example, I tried modifying the ODE tutorial

```julia
p = Dict()
p[:c] = 1.01
f(u,p,t) = p[:c]*u
u0 = 1/2
tspan = (0.0,1.0)
prob = ODEProblem(f,u0,tspan)
sol = solve(prob, Tsit5(), reltol=1e-8, abstol=1e-8)

```

but I get `ERROR: MethodError: no method matching getindex(::Nothing, ::Symbol)` related to `p` on the `solve`, so I was curious why parameters have to be “list”-like.

---

<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:** [March 21, 2020, 4:57am UTC](https://discourse.julialang.org/t/differentialequations-parameters/36289/2 "2020-03-21T04:57:36Z")

</div>

> [@jacob-roth](#):
>
> does `p` always have to be an array? Is there a “best practices” reason for why I shouldn’t use `Dict` s to hold my parameters in my function definition `f` ?

It can be any type.

> [@jacob-roth](#):
>
> prob = ODEProblem(f,u0,tspan)

You didn’t pass your parameters.

---

<div class="post-metadata">

**Author:** ![jacob-roth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jacob-roth/32/1862_2.png) [@jacob-roth](https://discourse.julialang.org/u/jacob-roth)\
**Post date:** [March 21, 2020, 5:06am UTC](https://discourse.julialang.org/t/differentialequations-parameters/36289/3 "2020-03-21T05:06:20Z")

</div>

Oh gosh, thank you…

---

<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:** [March 21, 2020, 5:13am UTC](https://discourse.julialang.org/t/differentialequations-parameters/36289/4 "2020-03-21T05:13:21Z")

</div>

No worries. If you use a version of DiffEq released within the last year this error message is better and explicitly says the parameters were not passed in (by using a fancy default)
