# Understanding the Use of Derivatives in Optimal Control for Quantum Computing

I'm currently studying quantum computing and I have a question regarding the application of derivatives in the context of optimal control. I would like to provide a simple and generic example and would greatly appreciate any help. I've already tried discussing it with colleagues and professors, but I'm still unsure. I'm not aiming for mathematical rigor, I just want to be able to perform and understand the calculations.

Let's consider the expression $$J = \langle\lambda(t)\rvert \mu(t)H_0 \lvert\psi(t)\rangle$$, where $$\lvert\psi(t)\rangle$$ and $$\lvert\lambda(t)\rangle$$ are states in the Hilbert space, $$H_0$$ is a time-independent Hermitian operator, and $$\mu(t)$$ is an arbitrary function. I would like to know how to express $$\frac{\partial J}{\partial \langle\lambda(t)\rvert}$$, $$\frac{\partial J}{\partial \lvert\psi(t)\rangle}$$ and $$\frac{\partial J}{\partial \lvert\lambda(t)\rangle}$$ solely in terms of $$\lvert\psi(t)\rangle$$, $$\lvert\lambda(t)\rangle$$ (or duals), $$H_0$$, and $$\mu(t)$$. I understand that $$\langle\lambda(t)\rvert$$, $$\lvert\psi(t)\rangle$$ and $$\lvert\lambda(t)\rangle$$ are being treated as "independent variables" in the derivatives, similar to Lagrangian mechanics, but I'm having trouble grasping the entire process.