# How to specify the nonlinear solver algorithm for Shooting and MultipleShooting BVP solvers

**URL:** <https://discourse.julialang.org/t/how-to-specify-the-nonlinear-solver-algorithm-for-shooting-and-multipleshooting-bvp-solvers/130392>\
**Category:** Numerics\
**Created:** [July 2, 2025, 2:29am UTC](https://discourse.julialang.org/t/how-to-specify-the-nonlinear-solver-algorithm-for-shooting-and-multipleshooting-bvp-solvers/130392 "2025-07-02T02:29:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ThermionicsGuy](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@ThermionicsGuy](https://discourse.julialang.org/u/ThermionicsGuy)\
**Post date:** [July 2, 2025, 2:29am UTC](https://discourse.julialang.org/t/how-to-specify-the-nonlinear-solver-algorithm-for-shooting-and-multipleshooting-bvp-solvers/130392/1 "2025-07-02T02:29:17Z")

</div>

SciML’s documentation suggests that the boundary value problem solvers Shooting() and MultipleShooting() should be able to use any of the NonlinearSolve.jl algorithms, but I haven’t been able to find a way to specify the nonlinear solver algorithm that doesn’t result in an error. Any suggestions?

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [July 2, 2025, 3:58am UTC](https://discourse.julialang.org/t/how-to-specify-the-nonlinear-solver-algorithm-for-shooting-and-multipleshooting-bvp-solvers/130392/2 "2025-07-02T03:58:51Z")

</div>

Can you share the code you tried and the full error message?

---

<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:** [July 2, 2025, 8:59am UTC](https://discourse.julialang.org/t/how-to-specify-the-nonlinear-solver-algorithm-for-shooting-and-multipleshooting-bvp-solvers/130392/3 "2025-07-02T08:59:12Z")

</div>

> **[BoundaryValueDiffEqShooting · BoundaryValueDiffEq.jl](https://docs.sciml.ai/BoundaryValueDiffEq/dev/solvers/shooting/)**
>
> Documentation for BoundaryValueDiffEq.jl.

The argument is `nlsolve`, i.e. ` Shooting(nlsolve = TrustRegion())`.

But the bigger thing is, what is the error?

---

<div class="post-metadata">

**Author:** ![ThermionicsGuy](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@ThermionicsGuy](https://discourse.julialang.org/u/ThermionicsGuy)\
**Post date:** [July 2, 2025, 4:44pm UTC](https://discourse.julialang.org/t/how-to-specify-the-nonlinear-solver-algorithm-for-shooting-and-multipleshooting-bvp-solvers/130392/4 "2025-07-02T16:44:53Z")

</div>

Here is a MWE, as usual based on SciML’s SimplePendulum example problem:

```julia
using BoundaryValueDiffEq
using Plots
using OrdinaryDiffEq
using NonlinearSolve #added to original example problem
const g = 9.81
L = 1.0
tspan = (0.0, pi / 2)
function simplependulum!(du, u, p, t)
    θ = u[1]
    dθ = u[2]
    du[1] = dθ
    du[2] = -(g / L) * sin(θ)
end

u₀_2 = [-1.6, -1.7] # the initial guess
function bc3!(residual, sol, p, t)
    residual[1] = sol(pi / 4)[1] + pi / 2 # use the interpolation here, since indexing will be wrong for adaptive methods
    residual[2] = sol(pi / 2)[1] - pi / 2
end
bvp3 = BVProblem(simplependulum!, bc3!, u₀_2, tspan)
sol3 = solve(bvp3, Shooting(Tsit5()); nlsolve = TrustRegion()) #modified from original example problem. Using Tsit5 rather than Vern7 and added nsolve = TrustRegion() per email from CR
plot(sol3)

```

And here is the error message:

```julia
        
ERROR: Unrecognized keyword arguments found.
The only allowed keyword arguments to `solve` are:
(:dense, :saveat, :save_idxs, :tstops, :tspan, :d_discontinuities, :save_everystep, :save_on, :save_start, :save_end, :initialize_save, :adaptive, :abstol, :reltol, :dt, :dtmax, :dtmin, :force_dtmin, :internalnorm, :controller, :gamma, :beta1, :beta2, :qmax, :qmin, :qsteady_min, :qsteady_max, :qoldinit, :failfactor, :calck, :alias_u0, :maxiters, :maxtime, :callback, :isoutofdomain, :unstable_check, :verbose, :merge_callbacks, :progress, :progress_steps, :progress_name, :progress_message, :progress_id, :timeseries_errors, :dense_errors, :weak_timeseries_errors, :weak_dense_errors, :wrap, :calculate_error, :initializealg, :alg, :save_noise, :delta, :seed, :alg_hints, :kwargshandle, :trajectories, :batch_size, :sensealg, :advance_to_tstop, :stop_at_next_tstop, :u0, :p, :default_set, :second_time, :prob_choice, :alias_jump, :alias_noise, :batch, :nlsolve_kwargs, :odesolve_kwargs, :linsolve_kwargs, :ensemblealg, :show_trace, :trace_level, :store_trace, :termination_condition, :alias, :fit_parameters)

See https://diffeq.sciml.ai/stable/basics/common_solver_opts/ for more details.

Unrecognized keyword arguments: [:nlsolve]

Some of the types have been truncated in the stacktrace for improved reading. To emit complete information
in the stack trace, evaluate `TruncatedStacktraces.VERBOSE[] = true` and re-run the code.

Stacktrace:
 [1] #checkkwargs#51
   @ C:\Users\jbmcv\.julia\packages\DiffEqBase\qvEPa\src\solve.jl:1240 [inlined]
 [2] checkkwargs
   @ C:\Users\jbmcv\.julia\packages\DiffEqBase\qvEPa\src\solve.jl:1237 [inlined]
 [3] #solve_call#36
   @ C:\Users\jbmcv\.julia\packages\DiffEqBase\qvEPa\src\solve.jl:646 [inlined]
 [4] solve_call
   @ C:\Users\jbmcv\.julia\packages\DiffEqBase\qvEPa\src\solve.jl:627 [inlined]
 [5] #solve_up#45
   @ C:\Users\jbmcv\.julia\packages\DiffEqBase\qvEPa\src\solve.jl:1205 [inlined]
 [6] solve_up
   @ C:\Users\jbmcv\.julia\packages\DiffEqBase\qvEPa\src\solve.jl:1183 [inlined]
 [7] solve(prob::BVProblem{…}, args::Shooting{…}; sensealg::Nothing, u0::Nothing, p::Nothing, wrap::Val{…}, kwargs::@Kwargs{…})
   @ DiffEqBase C:\Users\jbmcv\.julia\packages\DiffEqBase\qvEPa\src\solve.jl:1096
 [8] top-level scope

```

I had assumed that my code was at fault, but from what Chris wrote it looks like that maybe isn’t the case.

---

<div class="post-metadata">

**Author:** ![ErikQQY](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erikqqy/32/23074_2.png) [@ErikQQY](https://discourse.julialang.org/u/ErikQQY)\
**Post date:** [July 3, 2025, 11:41am UTC](https://discourse.julialang.org/t/how-to-specify-the-nonlinear-solver-algorithm-for-shooting-and-multipleshooting-bvp-solvers/130392/5 "2025-07-03T11:41:46Z")

</div>

> [@ThermionicsGuy](#):
>
> `sol3 = solve(bvp3, Shooting(Tsit5()); nlsolve = TrustRegion())`

@ThermionicsGuy The solver shoud be `Shooting(Tsit5(), nlsolve = TrustRegion())`

see [BoundaryValueDiffEqShooting · BoundaryValueDiffEq.jl](https://docs.sciml.ai/BoundaryValueDiffEq/dev/solvers/shooting/#Detailed-Solvers-Explanation)

---

<div class="post-metadata">

**Author:** ![ThermionicsGuy](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@ThermionicsGuy](https://discourse.julialang.org/u/ThermionicsGuy)\
**Post date:** [July 3, 2025, 4:40pm UTC](https://discourse.julialang.org/t/how-to-specify-the-nonlinear-solver-algorithm-for-shooting-and-multipleshooting-bvp-solvers/130392/6 "2025-07-03T16:40:05Z")

</div>

YES! That works. Thank you very much.
