You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Found a small issue with ForwardDiff on complex numbers ode #860
The Dual of time in the ode function has NaN values. Meaning, in the ode function (u,p,t) -> ...t is Dual with derivative NaN
Maybe a problem with the promotion of tspan ? affecting the initial dt value ?
Example;
using LinearAlgebra, DifferentialEquations
import ForwardDiff as FD
H0 = randn(2,2)
u0 = [1.0, 0im]
Ht(u,p,t) = (H0*u)*cos(p*t)
prob0 = ODEProblem(Ht, u0, (0.0,1.0))
function loss(p)
prob = remake(prob0; p)
sol = solve(prob)
lo = abs2(tr(first(sol.u)'last(sol.u)))
lo
end
loss(rand())
FD.derivative(loss, rand()) # NaN's
This does not show up in other cases, such as;
if the initial difference is small; e.g., Ht(u,p,t) = (H0*u)*sin(p*t)
other random initial state; u0 = randn(ComplexF64,2)
real initial state u0 = [1.0, 0.0]
use some finite dt in ODEProblem(...; dt=1)
Also nan safe mode for ForwardDiff solve this.
The text was updated successfully, but these errors were encountered:
Found a small issue with ForwardDiff on complex numbers ode #860
The Dual of time in the ode function has NaN values. Meaning, in the ode function
(u,p,t) -> ...
t
is Dual with derivativeNaN
Maybe a problem with the promotion of
tspan
? affecting the initialdt
value ?Example;
This does not show up in other cases, such as;
if the initial difference is small; e.g.,
Ht(u,p,t) = (H0*u)*sin(p*t)
other random initial state;
u0 = randn(ComplexF64,2)
real initial state
u0 = [1.0, 0.0]
use some finite
dt
inODEProblem(...; dt=1)
Also nan safe mode for ForwardDiff solve this.
The text was updated successfully, but these errors were encountered: