# Nlsolve for find root for a system of ODE for an implicit runge kutta method

**URL:** https://discourse.julialang.org/t/nlsolve-for-find-root-for-a-system-of-ode-for-an-implicit-runge-kutta-method/84349
**Category:** New to Julia
**Tags:** package
**Created:** [July 17, 2022, 8:23am UTC](https://discourse.julialang.org/t/nlsolve-for-find-root-for-a-system-of-ode-for-an-implicit-runge-kutta-method/84349 "2022-07-17T08:23:31Z")
**Posts on this page:** 1
**Showing post:** 31

<div class="post-metadata">

### Author: ![John\_Gibson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/john_gibson/32/5321_2.png) [@John\_Gibson](https://discourse.julialang.org/u/John_Gibson)
#### Post date: [July 19, 2022, 2:40pm UTC](https://discourse.julialang.org/t/nlsolve-for-find-root-for-a-system-of-ode-for-an-implicit-runge-kutta-method/84349/31 "2022-07-19T14:40:06Z")

</div>

> I just don’t understand why we need to provide u to nlsolve, which is just the array of variables for any particular ODE function

I think I misdirected you initially to provide `u` to nlsolve, because I misunderstood what the mathematical problem was. I think I understand correctly now that `k` is a set of implicit Runge-Kutta coefficients that have to be solved for at each time step, from a set of nonlinear equations involving `f` for fixed values of `u` and `t` So `u` and `t` are the parameters in the nonlinear solve and `k` is the unknown.

So the code snippet

```julia
function f!(fx, u)
   fx .= f(u, t, dt, k)
end

c1 = nlsolve(f!, k)

```

should be changed to

```julia
function f!(fk, k)
   fk .= f(u, t, dt, k)
end

solution = nlsolve(f!, k)
ksolution = solution.zero

```

And that code snippet should be inside the time-stepping loop, so that the `u` and `t` parameters can be set to their current values at any given time step.

---

_[View the full topic](https://discourse.julialang.org/t/nlsolve-for-find-root-for-a-system-of-ode-for-an-implicit-runge-kutta-method/84349)._
