Iβm calculating the Quantum Fisher Information (QFI) for the kicked top system using the QuantumOptics package in Julia. The code works fine for initial states with j up to 1700, but when I increase j to 1800 or higher, I start getting NaN values in the results. Even the norm of the initial state comes as NaN. Below is the code I am using:

```
#The QFI of the kicked tip system using the QuantumOptics pkg and the Krylov subspace
using QuantumOptics
using LinearAlgebra
using KrylovKit
using Expokit
# Define the system parameters
j = 1800
J = SpinBasis(j)
Jx = 0.5 * sigmax(J)
Jy = 0.5 * sigmay(J)
Jz = 0.5 * sigmaz(J)
# Initial state
initial_state = coherentspinstate(J, Ο/2, Ο/2)
# Ensure the initial state is properly normalized
println("Initial state norm: ", norm(initial_state))
Ξ± = Ο/2 # Precession angle
k = 7 # Kicking strength for chaotic regime
Ξ΅ = 0.001 # Small perturbation
# Construct the Hamiltonians
H_precession = Ξ± * Jz
H_kick = (k / (2*j)) * Jy^2
# Safe normalization function using BigFloat
function safe_norm(state)
nrm = norm(state)
if nrm < BigFloat(1e-10)
return BigFloat(1e-10)
end
return nrm
end
#check if your Hamiltonians contain any NaNs or Infs
function check_matrix_validity(H)
if any(isnan, H) || any(isinf, H)
println("Hamiltonian Matrix contains NaNs or Infs")
return false
else
println("Hamiltonian Matrix is valid")
return true
end
end
# Check the validity of the Hamiltonians
is_valid = check_matrix_validity(sparse((H_kick + H_precession).data)) &&
check_matrix_validity(sparse((H_kick + (Ξ± + Ξ΅) * Jz).data))
if !is_valid
error("Invalid hamiltonian matrix detected, stopping execution.")
end
# Define a function to apply the exponential of a matrix to a state vector
function apply_exp_H(state, H::Operator, t)
H_matrix = sparse(H.data) # Extract the sparse matrix from the Operator
expmv(-1im * t, H_matrix, state.data) # Pass the matrix and vector (state.data) to expmv
end
# Evolve the state using the Krylov subspace method
function krylov_fidel(U_fwd, U_bwd, state, t_max)
F_Ξ΅_values = []
for t in 1:t_max
# Evolve state using U_fwd
state_vec = apply_exp_H(state, U_fwd, 1)
state = Ket(state.basis, state_vec) # Recreate the state object with the new vector
state /= safe_norm(state) # Normalize the state
# Calculate Loschmidt echo
echo_state_vec = apply_exp_H(state, U_bwd, 1)
echo_state = Ket(state.basis, echo_state_vec)
F_Ξ΅ = abs(dagger(initial_state) * echo_state)^2
push!(F_Ξ΅_values, F_Ξ΅)
println("F_Ξ΅ at t=$t: ", F_Ξ΅)
end
return F_Ξ΅_values
end
# Assuming U_Ξ± and U_Ξ±_Ξ΅ are your Hamiltonians or precomputed unitary matrices
t_max = 10
F_Ξ΅_values = krylov_fidel(H_kick + H_precession, H_kick + (Ξ± + Ξ΅) * Jz, initial_state, t_max)
# Compute Loschmidt echo and QFI
QFI_values = [4 * (1 - F_Ξ΅) / (Ξ΅^2) for F_Ξ΅ in F_Ξ΅_values]
println("Loschmidt echo: ", F_Ξ΅_values)
println("QFI: ", QFI_values)
#Plot the QFI values
using PyPlot
plot(1:t_max, QFI_values, linewidth=2)
xlabel("Time (t)")
ylabel("QFI I_Ξ±(t)")
title("QFI using Loschmidt Echo for j = 1800 and k = 7 ")
savefig("QFI_Loschmidt_Fig.png")
println("Plot saved as QFI_Loschmidt_Fig.png.")
```

This issue can be reproduced by running the provided code with j = 1800 or higher. The NaN values appear during the display of the norm of the initial state and computation of the Loschmidt echo and QFI.

- Julia version: 1.7.2
- Packages and versions:
- QuantumOptics: QuantumOptics v1.1.1
- KrylovKit: KrylovKit v0.6.1
- Expokit: Expokit v0.2.0

- The code works fine for j <= 1700