That’s because the L factor from cholesky is a lower triangular matrix. If you want to perturb the upper triangular elements as well, you can convert the factor to a Matrix first.

Because ForwardDiff has no special overloads for array valued functions, and LinearAlgebra’s det has the optimization of first checking if the matrix is triangular before computing the LU factorization. Hence, the L factor is going to only go through the triangular branch. As a workaround, you can do

(defn eq
"For non-differentials, this is identical to [[clojure.core/=]].
For [[Differential]] instances, equality acts on tangent components too.
If you want to ignore the tangent components, use [[equiv]]."
([_] true)
([a b]
(= (->terms a)
(->terms b)))
([a b & more]
(reduce eq (eq a b) more)))

seems to agree with you. And BTW: the imaginary part in the PR 's title references the tangents/gradients (I first thought the PR would be about complex numbers)?

The PR is a bit stuck because every time I try to fix the tests I get lost – there are many levels of nested testsets trying to ensure that nothing ever changes, but some must change for this.

Sorry I guess “imaginary” is misleading. The essay about what to do is this issue. When I searched I got the impression that everyone flipped a coin to decide which rule to adopt here when implementing dual numbers. But I didn’t find this particular one. (Edit – because it was written after my issue.)