gh-38750: Corrects some inner products in root systems
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes #12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes #12345". -->
Goal of this PR:
* Fix Exhibit A in #15325
* Exhibits B and C in the issue are ignored because they are not
strictly speaking errors
Status quo:
* Some inner products for elements of root spaces or ambient spaces
give wrong answers or raise exceptions
Fix:
* Adds a few lines of code to scalar product functions in
ambient_space and root_space
* TESTS were added to scalar product member functions to exhibit
fixing this issue
Notes:
* I am unable to verify that the documentation builds because I
cannot build the documentation (build problems with this version of
Sage)
A more thorough test of this functionality, which checks Exhibit A from
the issue on more cases, is provided by the following code snippet:
```
for ct in [['G', 2], ['F', 4], ['E', 8], ['E', 7]] + [[x, 6] for x in
['A', 'B', 'C', 'D', 'E']]:
rt = RootSystem(ct)
print(ct)
lat = rt.root_lattice()
spc = rt.ambient_space()
ell = lat.rank()
C = rt.cartan_matrix()
for i in range(1,ell+1):
assert lat.simple_root(i) == spc.simple_root(i)
assert lat.simple_coroot(i) == spc.simple_coroot(i)
for j in range(1,ell+1):
aprod = C[j-1,i-1]
assert lat.simple_root(i).scalar(lat.simple_coroot(j)) ==
aprod
assert spc.simple_root(i).scalar(spc.simple_coroot(j)) ==
aprod
assert spc.simple_root(i).scalar(lat.simple_coroot(j)) ==
aprod
assert lat.simple_root(i).scalar(spc.simple_coroot(j)) ==
aprod
```
### :memo: Checklist
<!-- Put an `x` in all the boxes that apply. -->
- [X] The title is concise and informative.
- [X] The description explains in detail what this PR is about.
- [X] I have linked a relevant issue or discussion.
- [X] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.
### :hourglass: Dependencies
<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - #12345: short description why this is a dependency -->
<!-- - #34567: ... -->
URL: https://github.com/sagemath/sage/pull/38750
Reported by: Skip G
Reviewer(s): Skip G, Travis Scrimshaw