Closed keefemitman closed 1 year ago
Patch coverage: 66.66
% and no project coverage change.
Comparison is base (
b4c0a51
) 42.29% compared to head (3483e09
) 42.29%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
I think I agree with the actual code change, but not with your comment above.
First, the normalization should be the sum of squares (without a square-root) because it divides something that is explicitly constructed as the sum of squares. So I agree that they should be on the same footing, and your change to the code is correct. But maybe I'm missing something because I believe that WaveformModes.norm
is defined as the $L^2$ norm, not its square-root. Maybe the documentation of WaveformModes.norm
is poorly written?
I'll walk through my reasoning carefully, for myself as much as anything. There are some overlapping meanings for the notation $L^2$, but generally they all include squaring, then summing/integrating, and then taking a square-root. There is an annoying ambiguity with the term "norm" in the context of quaternions (and other composition algebras), where it might be more specifically called the "Cayley norm", and there is no square root. But AFAICT otherwise, a 2-"norm" always involve a square-root. In particular, the underlying concept here is the space of square-integrable functions, for which the $L^2$ norm is universally defined as
$$ \|f\|_2 := \left( \int |f|^2 d\mu \right)^{1/2} $$
We can expand $f$ in SWSHs, and then use orthonormality to find
$$ \begin{align} \|f\|2 &= \left( \int \left| \sum_{\ell,m} f_{\ell,m} \, {}_sY_{\ell,m} \right|^2 d\Omega \right)^{1/2} \ &= \left( \int \left( \sum_{\ell,m} f_{\ell,m} \, {}_sY_{\ell,m} \right)\left( \sum_{\ell',m'} \bar{f}_{\ell',m'} \, {}_s\bar{Y}_{\ell',m'} \right) d\Omega \right)^{1/2} \ &= \left( \sum_{\ell,m,\ell',m'} f_{\ell,m} \bar{f}_{\ell',m'} \int {}_sY_{\ell,m} \, {}_s\bar{Y}_{\ell',m'} d\Omega \right)^{1/2} \ &= \left( \sum_{\ell,m,\ell',m'} f_{\ell,m} \bar{f}_{\ell',m'} \delta_{\ell,\ell'} \delta_{m,m'} \right)^{1/2} \ &= \left( \sum_{\ell,m} f_{\ell,m} \bar{f}_{\ell,m} \right)^{1/2} \ &= \left( \sum_{\ell,m} \left| f\{\ell,m} \right|^2 \right)^{1/2} \end{align} $$
This last quantity is what np.linalg.norm
returns, which is what WaveformModes.norm
calls.
Is this consistent with your understanding of the code and/or documentation?
@moble Yeah my apologies for using sloppy wording. I think the confusion mainly arises because sxs.WaveformModes.norm
is defined as $||f||_{2}
$, i.e., the $L^{2}
$ norm, as you've written out explicitly.
scri.WaveformModes.norm
, however, is defined as $(||f||_{2})^{2}
$, since the default value of take_sqrt
is take_sqrt=False
.
It would be nice if the two were consistent.
Ah, okay. I forgot about that take_sqrt
argument. That was an ugly choice, alright...
I wouldn't be opposed to making a breaking release of scri
to change that, but I'm not sure if anyone uses that in existing code. There are a few uses within scri
that would have to be changed. Thoughts?
For now, anyway, I'll just merge this. Thanks.
Yeah I agree that it's too big of a change (and not important enough of a change) to make to scri
. Thanks for merging!
sxs's norm is defined as the sqrt of the L^2 norm, but in the align2d code we want the actual L^2 norm.