Skip to content

Conversation

@edinvay
Copy link
Contributor

@edinvay edinvay commented Jan 20, 2026

Changed the complex L2 inner product to the real L2 inner product.
It makes it consistent with optimization problems appearing in quantum chemistry.

We need to check:
H2_magnetic_properties_LDA (Failed)

We should operate with different inner products in energy expressions (mrcpp::dot) and in optimization tools (real part of mrcpp::dot). They are conceptually different. For example, the gradient of Lagrangian is an optimization tool, and so it uses the latter one (with the real part).

@edinvay edinvay requested a review from gitpeterwind January 20, 2026 09:02
@gitpeterwind
Copy link
Member

gitpeterwind commented Jan 20, 2026

Can you explain why the imaginary part must be truncated in optimization tools?

@edinvay
Copy link
Contributor Author

edinvay commented Jan 20, 2026

Can you explain why the imaginary part must be truncated in optimization tools?

In order to differentiate functionals and get the corresponding gradients one needs an inner product. It is implied in many text books, though it is rarely pronounced explicitly.
In the Szabo-Ostlund book they calculate the gradient exactly in Re(L2 inner product): they write "expression + complex conjugate" in the derivation of Hartree-Fock equations, for instance. In other words, they differentiate with respect to L2-norm and find the gradient in Re(L2 inner product). It turns out, that both L2 inner product and Re(L2 inner product) induce the same L2-norm. However, while Re(L2 inner product) can be used in the optimization theory, L2 inner product does NOT lead to any meaningful optimization. It is a consequence of the famous Liouville's Theorem in complex analysis: a complex differentiable function CANNOT have extrema.

To put it bluntly, optimization theory is well defined only for real Hilbert spaces (orbitals can still have complex values, there is no contradiction here) with real functionals, of course.

@gitpeterwind
Copy link
Member

Thanks, I understand the idea now. We should try it in a real case (I think the present H2_magnetic_properties_LDA test is not doing any KAIN optimization)

@edinvay edinvay marked this pull request as ready for review January 21, 2026 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants