I am running the following code in Julia.

code: function lsmc_am_put(S, K, r, σ, t, N, P)

Δt = t / N

R = exp(r * Δt)

T = typeof(S * exp(-σ^2 * Δt / 2 + σ * √Δt * 0.1) / R)

X = Array{T}(undef, N+1, P)

```
for p = 1:P
X[1, p] = x = S
for n = 1:N
x *= R * exp(-σ^2 * Δt / 2 + σ * √Δt * randn())
X[n+1, p] = x
end
end
V = [max(K - x, 0) / R for x in X[N+1, :]]
for n = N-1:-1:1
I = V .!= 0
A = [x^d for d = 0:3, x in X[n+1, :]]
β = A[:, I]' \ V[I]
cV = A' * β
for p = 1:P
ev = max(K - X[n+1, p], 0)
if I[p] && cV[p] < ev
V[p] = ev / R
else
V[p] /= R
end
end
end
return max(mean(V), K - S)
end
```

after this, I import ForwardDiff: Dual and then run

lsmc_am_put(Dual(100,1,0),90,0.5,Dual(0.3,0.1),180/365,1000,10000) but I get the error

error: MethodError: no method matching _mul_partials(::ForwardDiff.Partials{2, Int64}, ::ForwardDiff.Partials{1, Float64}, ::Float64, ::Int64)

Closest candidates are:

_mul_partials(::ForwardDiff.Partials{0, A}, ::ForwardDiff.Partials{N, B}, ::Any, ::Any) where {N, A, B} at ~/.julia/packages/ForwardDiff/QdStj/src/partials.jl:141

_mul_partials(::ForwardDiff.Partials{N, A}, ::ForwardDiff.Partials{0, B}, ::Any, ::Any) where {N, A, B} at ~/.julia/packages/ForwardDiff/QdStj/src/partials.jl:142

_mul_partials(::ForwardDiff.Partials{N}, ::ForwardDiff.Partials{N}, ::Any, ::Any) where N at ~/.julia/packages/ForwardDiff/QdStj/src/partials.jl:118

…

Stacktrace:

[1] **dual_definition_retval(**#unused#::Val{Nothing}, val::Float64, deriv1::Float64, partial1::ForwardDiff.Partials{2, Int64}, deriv2::Int64, partial2::ForwardDiff.Partials{1, Float64}**)**

@ ForwardDiff ~/.julia/packages/ForwardDiff/QdStj/src/dual.jl:203

[2] *****

@ ~/.julia/packages/ForwardDiff/QdStj/src/dual.jl:271 [inlined]

[3] **lsmc_am_put( S::Dual{Nothing, Int64, 2}, K::Int64, r::Float64, σ::Dual{Nothing, Float64, 1}, t::Float64, N::Int64, P::Int64)**

@ Main ./REPL[56]:4

[4] top-level scope

@ REPL[68]

Can someone please help me with this? I am unable to trace what I am getting wrong and how I should fix it.