# Using BoundaryValueDiffEqFIRK: what is the format for solution derivative in bc! function?

**URL:** <https://discourse.julialang.org/t/using-boundaryvaluediffeqfirk-what-is-the-format-for-solution-derivative-in-bc-function/125600>\
**Category:** General Usage\
**Created:** [February 6, 2025, 6:35am UTC](https://discourse.julialang.org/t/using-boundaryvaluediffeqfirk-what-is-the-format-for-solution-derivative-in-bc-function/125600 "2025-02-06T06:35:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![P0p5](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@P0p5](https://discourse.julialang.org/u/P0p5)\
**Post date:** [February 6, 2025, 6:35am UTC](https://discourse.julialang.org/t/using-boundaryvaluediffeqfirk-what-is-the-format-for-solution-derivative-in-bc-function/125600/1 "2025-02-06T06:35:35Z")

</div>

I’m trying to use BVProblem with solver RadauIIa5.  
In the boundary condition function called by the solver,  
I need to refer to the first derivative of the solution.  
I can’t find an acceptable form for this derivative

In a different situation using ODEProblem with solver Vern9, this form is acceptable:  
sol(tx, Val{1}; idxs=1)

But it is rejected by BVProblem with solver RadauIIa5:

```julia
ERROR: MethodError: no method matching (::BoundaryValueDiffEqCore.EvalSol{BoundaryValueDiffEqFIRK.FIRKCacheExpand{…}, Vector{…}, Vector{…}})(::Float64, ::Type{Val{…}}; idxs::Int64)
 .
 .
 .
Closest candidates are:
  (::BoundaryValueDiffEqCore.EvalSol{C})(::Number) where C<:BoundaryValueDiffEqFIRK.FIRKCacheExpand got unsupported keyword argument "idxs"
   @ BoundaryValueDiffEqFIRK ~/.julia/packages/BoundaryValueDiffEqFIRK/ddek7/src/interpolation.jl:134

Stacktrace:
  [1] bcond!(resid::Vector{…}, sol::BoundaryValueDiffEqCore.EvalSol{…}, par::Tuple{…}, r::Vector{…})
    @ Main ~/Applications/Julia/RealisticSeismology-main/src/RealMod/src/shtar.jl:59
  [2] eval_bc_residual!(resid::Vector{…}, ::SciMLBase.StandardBVProblem, bc!::typeof(bcond!), sol::BoundaryValueDiffEqCore.EvalSol{…}, p::Tuple{…}, t::Vector{…})
 .
 .
 .

```

I also tried various other forms with no success.

Please advise.

thanks

---

<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:** [February 6, 2025, 2:02pm UTC](https://discourse.julialang.org/t/using-boundaryvaluediffeqfirk-what-is-the-format-for-solution-derivative-in-bc-function/125600/3 "2025-02-06T14:02:10Z")

</div>

It looks like that dispatch is just missing. Open an issue.

---

<div class="post-metadata">

**Author:** ![P0p5](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@P0p5](https://discourse.julialang.org/u/P0p5)\
**Post date:** [February 8, 2025, 4:48am UTC](https://discourse.julialang.org/t/using-boundaryvaluediffeqfirk-what-is-the-format-for-solution-derivative-in-bc-function/125600/4 "2025-02-08T04:48:13Z")

</div>

Could that dispatch be missing because we’re supposed to use ` [DiffResults.derivative](https://github.com/JuliaDiff/DiffResults.jl/blob/master/docs/src/index.md)`  
because FIRK provides the in-solution vectors as type `ForwardDiff.Dual` (again with apparently no warning about this in the documentation) ?  
(If so, I would have expected this to be no surprise to you, Chris! 😉  
Andy

---

<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:** [February 8, 2025, 7:39am UTC](https://discourse.julialang.org/t/using-boundaryvaluediffeqfirk-what-is-the-format-for-solution-derivative-in-bc-function/125600/5 "2025-02-08T07:39:14Z")

</div>

No, the analytical solution to the derivative should be implemented but it’s not in this case and it’s missing a better error message.

---

<div class="post-metadata">

**Author:** ![P0p5](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@P0p5](https://discourse.julialang.org/u/P0p5)\
**Post date:** [February 8, 2025, 7:41am UTC](https://discourse.julialang.org/t/using-boundaryvaluediffeqfirk-what-is-the-format-for-solution-derivative-in-bc-function/125600/6 "2025-02-08T07:41:52Z")

</div>

Since this issue now may be closely related to difficulty using only the “0th derivative” of the in-solution vector, let me add that to this discourse.  
I get this error…

```julia-auto
The type `Float64` exists, but no method is defined for this combination of argument types when trying to construct it.
`` 
in this situation (without trying to reference Val{1} at this time) …

```

function f!(dy\_dr, y::AbstractVector{\<:AbstractFloat}, param, t)

# Also doesn’t work without “\<:”

# [µ, ν, p] = y # Doesn’t work

```
µ = y[1]
ν = y[2]
p = y[3] # Works so far… 
xx = AnyFunc(p) # This throws the error 

```

````julia-auto
I was trying to apply the solution provided in [nice discourse 41905](https://discourse.julialang.org/t/error-with-forwarddiff-no-method-matching-float64/41905), which had only one equation, while I have three. But now I'm planning to desperately resort to ```DiffResults.value```.  

An aside — I'm surprised that this solver RadauIIa5 with BVPropblem is providing y as a vector of 3 y values and the t value, all not vector's Do I have to do something to allow a vector t chunk, which would seem more appropriate for a fully implicit solver providing ForwardDiff.Dual? Or maybe that will come later in the solution process?  
We hapless clients need to know when we have to code with broadcast to cope with that.  

Thanks
Andy
````

---

<div class="post-metadata">

**Author:** ![P0p5](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@P0p5](https://discourse.julialang.org/u/P0p5)\
**Post date:** [February 8, 2025, 8:09am UTC](https://discourse.julialang.org/t/using-boundaryvaluediffeqfirk-what-is-the-format-for-solution-derivative-in-bc-function/125600/7 "2025-02-08T08:09:33Z")

</div>

I’m sorry, my last post doesn’t show the first line that I know that I pasted, so this time, I’ll start with a blank line:

```julia

ERROR: MethodError: no method matching Float64(::ForwardDiff.Dual{ForwardDiff.Tag{BoundaryValueDiffEqCore.__Fix3{…}, Float64}, Float64, 10})
The type `Float64` exists, but no method is defined for this combination of argument types when trying to construct it.

```

Such an error first appeared when I was starting with only:

```julia
function f!(dy_dr, y, param, t) 

```
