passagemath-schemes 10.8.1a4__cp314-cp314t-macosx_13_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (312) hide show
  1. passagemath_schemes/.dylibs/libflint.22.0.dylib +0 -0
  2. passagemath_schemes/.dylibs/libgmp.10.dylib +0 -0
  3. passagemath_schemes/.dylibs/libgmpxx.4.dylib +0 -0
  4. passagemath_schemes/.dylibs/libmpfr.6.dylib +0 -0
  5. passagemath_schemes/__init__.py +3 -0
  6. passagemath_schemes-10.8.1a4.dist-info/METADATA +203 -0
  7. passagemath_schemes-10.8.1a4.dist-info/METADATA.bak +204 -0
  8. passagemath_schemes-10.8.1a4.dist-info/RECORD +312 -0
  9. passagemath_schemes-10.8.1a4.dist-info/WHEEL +6 -0
  10. passagemath_schemes-10.8.1a4.dist-info/top_level.txt +3 -0
  11. sage/all__sagemath_schemes.py +23 -0
  12. sage/databases/all__sagemath_schemes.py +7 -0
  13. sage/databases/cremona.py +1723 -0
  14. sage/dynamics/all__sagemath_schemes.py +2 -0
  15. sage/dynamics/arithmetic_dynamics/affine_ds.py +1083 -0
  16. sage/dynamics/arithmetic_dynamics/all.py +14 -0
  17. sage/dynamics/arithmetic_dynamics/berkovich_ds.py +1101 -0
  18. sage/dynamics/arithmetic_dynamics/dynamical_semigroup.py +1543 -0
  19. sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py +2426 -0
  20. sage/dynamics/arithmetic_dynamics/endPN_minimal_model.py +1169 -0
  21. sage/dynamics/arithmetic_dynamics/generic_ds.py +663 -0
  22. sage/dynamics/arithmetic_dynamics/product_projective_ds.py +339 -0
  23. sage/dynamics/arithmetic_dynamics/projective_ds.py +9556 -0
  24. sage/dynamics/arithmetic_dynamics/projective_ds_helper.cpython-314t-darwin.so +0 -0
  25. sage/dynamics/arithmetic_dynamics/projective_ds_helper.pyx +301 -0
  26. sage/dynamics/arithmetic_dynamics/wehlerK3.py +2578 -0
  27. sage/lfunctions/all.py +18 -0
  28. sage/lfunctions/dokchitser.py +727 -0
  29. sage/lfunctions/pari.py +971 -0
  30. sage/lfunctions/zero_sums.cpython-314t-darwin.so +0 -0
  31. sage/lfunctions/zero_sums.pyx +1847 -0
  32. sage/modular/abvar/abvar.py +5132 -0
  33. sage/modular/abvar/abvar_ambient_jacobian.py +414 -0
  34. sage/modular/abvar/abvar_newform.py +246 -0
  35. sage/modular/abvar/all.py +8 -0
  36. sage/modular/abvar/constructor.py +187 -0
  37. sage/modular/abvar/cuspidal_subgroup.py +371 -0
  38. sage/modular/abvar/finite_subgroup.py +896 -0
  39. sage/modular/abvar/homology.py +721 -0
  40. sage/modular/abvar/homspace.py +989 -0
  41. sage/modular/abvar/lseries.py +415 -0
  42. sage/modular/abvar/morphism.py +935 -0
  43. sage/modular/abvar/torsion_point.py +274 -0
  44. sage/modular/abvar/torsion_subgroup.py +741 -0
  45. sage/modular/all.py +43 -0
  46. sage/modular/arithgroup/all.py +20 -0
  47. sage/modular/arithgroup/arithgroup_element.cpython-314t-darwin.so +0 -0
  48. sage/modular/arithgroup/arithgroup_element.pyx +474 -0
  49. sage/modular/arithgroup/arithgroup_generic.py +1406 -0
  50. sage/modular/arithgroup/arithgroup_perm.py +2692 -0
  51. sage/modular/arithgroup/congroup.cpython-314t-darwin.so +0 -0
  52. sage/modular/arithgroup/congroup.pyx +334 -0
  53. sage/modular/arithgroup/congroup_gamma.py +361 -0
  54. sage/modular/arithgroup/congroup_gamma0.py +692 -0
  55. sage/modular/arithgroup/congroup_gamma1.py +659 -0
  56. sage/modular/arithgroup/congroup_gammaH.py +1491 -0
  57. sage/modular/arithgroup/congroup_generic.py +630 -0
  58. sage/modular/arithgroup/congroup_sl2z.py +266 -0
  59. sage/modular/arithgroup/farey_symbol.cpython-314t-darwin.so +0 -0
  60. sage/modular/arithgroup/farey_symbol.pyx +1067 -0
  61. sage/modular/arithgroup/tests.py +425 -0
  62. sage/modular/btquotients/all.py +4 -0
  63. sage/modular/btquotients/btquotient.py +3736 -0
  64. sage/modular/btquotients/pautomorphicform.py +2564 -0
  65. sage/modular/buzzard.py +100 -0
  66. sage/modular/congroup.py +29 -0
  67. sage/modular/congroup_element.py +13 -0
  68. sage/modular/cusps.py +1107 -0
  69. sage/modular/cusps_nf.py +1270 -0
  70. sage/modular/dims.py +571 -0
  71. sage/modular/dirichlet.py +3310 -0
  72. sage/modular/drinfeld_modform/all.py +2 -0
  73. sage/modular/drinfeld_modform/element.py +446 -0
  74. sage/modular/drinfeld_modform/ring.py +773 -0
  75. sage/modular/drinfeld_modform/tutorial.py +236 -0
  76. sage/modular/etaproducts.py +1076 -0
  77. sage/modular/hecke/algebra.py +725 -0
  78. sage/modular/hecke/all.py +19 -0
  79. sage/modular/hecke/ambient_module.py +994 -0
  80. sage/modular/hecke/degenmap.py +119 -0
  81. sage/modular/hecke/element.py +302 -0
  82. sage/modular/hecke/hecke_operator.py +736 -0
  83. sage/modular/hecke/homspace.py +185 -0
  84. sage/modular/hecke/module.py +1744 -0
  85. sage/modular/hecke/morphism.py +139 -0
  86. sage/modular/hecke/submodule.py +970 -0
  87. sage/modular/hypergeometric_misc.cpython-314t-darwin.so +0 -0
  88. sage/modular/hypergeometric_misc.pxd +4 -0
  89. sage/modular/hypergeometric_misc.pyx +166 -0
  90. sage/modular/hypergeometric_motive.py +2020 -0
  91. sage/modular/local_comp/all.py +2 -0
  92. sage/modular/local_comp/liftings.py +292 -0
  93. sage/modular/local_comp/local_comp.py +1070 -0
  94. sage/modular/local_comp/smoothchar.py +1825 -0
  95. sage/modular/local_comp/type_space.py +748 -0
  96. sage/modular/modform/all.py +30 -0
  97. sage/modular/modform/ambient.py +817 -0
  98. sage/modular/modform/ambient_R.py +177 -0
  99. sage/modular/modform/ambient_eps.py +306 -0
  100. sage/modular/modform/ambient_g0.py +120 -0
  101. sage/modular/modform/ambient_g1.py +199 -0
  102. sage/modular/modform/constructor.py +545 -0
  103. sage/modular/modform/cuspidal_submodule.py +708 -0
  104. sage/modular/modform/defaults.py +14 -0
  105. sage/modular/modform/eis_series.py +487 -0
  106. sage/modular/modform/eisenstein_submodule.py +663 -0
  107. sage/modular/modform/element.py +4105 -0
  108. sage/modular/modform/half_integral.py +154 -0
  109. sage/modular/modform/hecke_operator_on_qexp.py +247 -0
  110. sage/modular/modform/j_invariant.py +47 -0
  111. sage/modular/modform/l_series_gross_zagier.py +127 -0
  112. sage/modular/modform/l_series_gross_zagier_coeffs.cpython-314t-darwin.so +0 -0
  113. sage/modular/modform/l_series_gross_zagier_coeffs.pyx +177 -0
  114. sage/modular/modform/notes.py +45 -0
  115. sage/modular/modform/numerical.py +514 -0
  116. sage/modular/modform/periods.py +14 -0
  117. sage/modular/modform/ring.py +1257 -0
  118. sage/modular/modform/space.py +1859 -0
  119. sage/modular/modform/submodule.py +118 -0
  120. sage/modular/modform/tests.py +64 -0
  121. sage/modular/modform/theta.py +110 -0
  122. sage/modular/modform/vm_basis.py +380 -0
  123. sage/modular/modform/weight1.py +221 -0
  124. sage/modular/modform_hecketriangle/abstract_ring.py +1932 -0
  125. sage/modular/modform_hecketriangle/abstract_space.py +2527 -0
  126. sage/modular/modform_hecketriangle/all.py +30 -0
  127. sage/modular/modform_hecketriangle/analytic_type.py +590 -0
  128. sage/modular/modform_hecketriangle/constructor.py +416 -0
  129. sage/modular/modform_hecketriangle/element.py +351 -0
  130. sage/modular/modform_hecketriangle/functors.py +752 -0
  131. sage/modular/modform_hecketriangle/graded_ring.py +541 -0
  132. sage/modular/modform_hecketriangle/graded_ring_element.py +2225 -0
  133. sage/modular/modform_hecketriangle/hecke_triangle_group_element.py +3349 -0
  134. sage/modular/modform_hecketriangle/hecke_triangle_groups.py +1426 -0
  135. sage/modular/modform_hecketriangle/readme.py +1214 -0
  136. sage/modular/modform_hecketriangle/series_constructor.py +580 -0
  137. sage/modular/modform_hecketriangle/space.py +1037 -0
  138. sage/modular/modform_hecketriangle/subspace.py +423 -0
  139. sage/modular/modsym/all.py +17 -0
  140. sage/modular/modsym/ambient.py +3844 -0
  141. sage/modular/modsym/boundary.py +1420 -0
  142. sage/modular/modsym/element.py +336 -0
  143. sage/modular/modsym/g1list.py +178 -0
  144. sage/modular/modsym/ghlist.py +182 -0
  145. sage/modular/modsym/hecke_operator.py +73 -0
  146. sage/modular/modsym/manin_symbol.cpython-314t-darwin.so +0 -0
  147. sage/modular/modsym/manin_symbol.pxd +5 -0
  148. sage/modular/modsym/manin_symbol.pyx +497 -0
  149. sage/modular/modsym/manin_symbol_list.py +1291 -0
  150. sage/modular/modsym/modsym.py +400 -0
  151. sage/modular/modsym/modular_symbols.py +384 -0
  152. sage/modular/modsym/p1list_nf.py +1241 -0
  153. sage/modular/modsym/relation_matrix.py +591 -0
  154. sage/modular/modsym/relation_matrix_pyx.cpython-314t-darwin.so +0 -0
  155. sage/modular/modsym/relation_matrix_pyx.pyx +108 -0
  156. sage/modular/modsym/space.py +2468 -0
  157. sage/modular/modsym/subspace.py +455 -0
  158. sage/modular/modsym/tests.py +376 -0
  159. sage/modular/multiple_zeta.py +2635 -0
  160. sage/modular/multiple_zeta_F_algebra.py +789 -0
  161. sage/modular/overconvergent/all.py +6 -0
  162. sage/modular/overconvergent/genus0.py +1879 -0
  163. sage/modular/overconvergent/hecke_series.py +1187 -0
  164. sage/modular/overconvergent/weightspace.py +776 -0
  165. sage/modular/pollack_stevens/all.py +4 -0
  166. sage/modular/pollack_stevens/distributions.py +874 -0
  167. sage/modular/pollack_stevens/fund_domain.py +1572 -0
  168. sage/modular/pollack_stevens/manin_map.py +856 -0
  169. sage/modular/pollack_stevens/modsym.py +1590 -0
  170. sage/modular/pollack_stevens/padic_lseries.py +417 -0
  171. sage/modular/pollack_stevens/sigma0.py +534 -0
  172. sage/modular/pollack_stevens/space.py +1078 -0
  173. sage/modular/quasimodform/all.py +3 -0
  174. sage/modular/quasimodform/element.py +846 -0
  175. sage/modular/quasimodform/ring.py +826 -0
  176. sage/modular/quatalg/all.py +3 -0
  177. sage/modular/quatalg/brandt.py +1642 -0
  178. sage/modular/ssmod/all.py +8 -0
  179. sage/modular/ssmod/ssmod.py +827 -0
  180. sage/rings/all__sagemath_schemes.py +1 -0
  181. sage/rings/polynomial/all__sagemath_schemes.py +1 -0
  182. sage/rings/polynomial/binary_form_reduce.py +585 -0
  183. sage/schemes/all.py +41 -0
  184. sage/schemes/berkovich/all.py +6 -0
  185. sage/schemes/berkovich/berkovich_cp_element.py +2582 -0
  186. sage/schemes/berkovich/berkovich_space.py +700 -0
  187. sage/schemes/curves/affine_curve.py +2924 -0
  188. sage/schemes/curves/all.py +33 -0
  189. sage/schemes/curves/closed_point.py +434 -0
  190. sage/schemes/curves/constructor.py +397 -0
  191. sage/schemes/curves/curve.py +542 -0
  192. sage/schemes/curves/plane_curve_arrangement.py +1283 -0
  193. sage/schemes/curves/point.py +463 -0
  194. sage/schemes/curves/projective_curve.py +3203 -0
  195. sage/schemes/curves/weighted_projective_curve.py +106 -0
  196. sage/schemes/curves/zariski_vankampen.py +1931 -0
  197. sage/schemes/cyclic_covers/all.py +2 -0
  198. sage/schemes/cyclic_covers/charpoly_frobenius.py +320 -0
  199. sage/schemes/cyclic_covers/constructor.py +137 -0
  200. sage/schemes/cyclic_covers/cycliccover_finite_field.py +1309 -0
  201. sage/schemes/cyclic_covers/cycliccover_generic.py +310 -0
  202. sage/schemes/elliptic_curves/BSD.py +991 -0
  203. sage/schemes/elliptic_curves/Qcurves.py +592 -0
  204. sage/schemes/elliptic_curves/addition_formulas_ring.py +94 -0
  205. sage/schemes/elliptic_curves/all.py +49 -0
  206. sage/schemes/elliptic_curves/cardinality.py +609 -0
  207. sage/schemes/elliptic_curves/cm.py +1103 -0
  208. sage/schemes/elliptic_curves/constructor.py +1530 -0
  209. sage/schemes/elliptic_curves/ec_database.py +175 -0
  210. sage/schemes/elliptic_curves/ell_curve_isogeny.py +3971 -0
  211. sage/schemes/elliptic_curves/ell_egros.py +457 -0
  212. sage/schemes/elliptic_curves/ell_field.py +2837 -0
  213. sage/schemes/elliptic_curves/ell_finite_field.py +3249 -0
  214. sage/schemes/elliptic_curves/ell_generic.py +3760 -0
  215. sage/schemes/elliptic_curves/ell_local_data.py +1207 -0
  216. sage/schemes/elliptic_curves/ell_modular_symbols.py +775 -0
  217. sage/schemes/elliptic_curves/ell_number_field.py +4220 -0
  218. sage/schemes/elliptic_curves/ell_padic_field.py +107 -0
  219. sage/schemes/elliptic_curves/ell_point.py +4944 -0
  220. sage/schemes/elliptic_curves/ell_rational_field.py +7184 -0
  221. sage/schemes/elliptic_curves/ell_tate_curve.py +671 -0
  222. sage/schemes/elliptic_curves/ell_torsion.py +436 -0
  223. sage/schemes/elliptic_curves/ell_wp.py +352 -0
  224. sage/schemes/elliptic_curves/formal_group.py +760 -0
  225. sage/schemes/elliptic_curves/gal_reps.py +1459 -0
  226. sage/schemes/elliptic_curves/gal_reps_number_field.py +1663 -0
  227. sage/schemes/elliptic_curves/gp_simon.py +152 -0
  228. sage/schemes/elliptic_curves/heegner.py +7328 -0
  229. sage/schemes/elliptic_curves/height.py +2108 -0
  230. sage/schemes/elliptic_curves/hom.py +1788 -0
  231. sage/schemes/elliptic_curves/hom_composite.py +1084 -0
  232. sage/schemes/elliptic_curves/hom_fractional.py +544 -0
  233. sage/schemes/elliptic_curves/hom_frobenius.py +522 -0
  234. sage/schemes/elliptic_curves/hom_scalar.py +531 -0
  235. sage/schemes/elliptic_curves/hom_sum.py +681 -0
  236. sage/schemes/elliptic_curves/hom_velusqrt.py +1290 -0
  237. sage/schemes/elliptic_curves/homset.py +271 -0
  238. sage/schemes/elliptic_curves/isogeny_class.py +1523 -0
  239. sage/schemes/elliptic_curves/isogeny_small_degree.py +2797 -0
  240. sage/schemes/elliptic_curves/jacobian.py +247 -0
  241. sage/schemes/elliptic_curves/kodaira_symbol.py +344 -0
  242. sage/schemes/elliptic_curves/kraus.py +1014 -0
  243. sage/schemes/elliptic_curves/lseries_ell.py +915 -0
  244. sage/schemes/elliptic_curves/mod5family.py +105 -0
  245. sage/schemes/elliptic_curves/mod_poly.py +197 -0
  246. sage/schemes/elliptic_curves/mod_sym_num.cpython-314t-darwin.so +0 -0
  247. sage/schemes/elliptic_curves/mod_sym_num.pyx +3796 -0
  248. sage/schemes/elliptic_curves/modular_parametrization.py +305 -0
  249. sage/schemes/elliptic_curves/padic_lseries.py +1793 -0
  250. sage/schemes/elliptic_curves/padics.py +1816 -0
  251. sage/schemes/elliptic_curves/period_lattice.py +2234 -0
  252. sage/schemes/elliptic_curves/period_lattice_region.cpython-314t-darwin.so +0 -0
  253. sage/schemes/elliptic_curves/period_lattice_region.pyx +722 -0
  254. sage/schemes/elliptic_curves/saturation.py +716 -0
  255. sage/schemes/elliptic_curves/sha_tate.py +1158 -0
  256. sage/schemes/elliptic_curves/weierstrass_morphism.py +1117 -0
  257. sage/schemes/elliptic_curves/weierstrass_transform.py +200 -0
  258. sage/schemes/hyperelliptic_curves/all.py +6 -0
  259. sage/schemes/hyperelliptic_curves/constructor.py +369 -0
  260. sage/schemes/hyperelliptic_curves/hyperelliptic_finite_field.py +1948 -0
  261. sage/schemes/hyperelliptic_curves/hyperelliptic_g2.py +192 -0
  262. sage/schemes/hyperelliptic_curves/hyperelliptic_generic.py +936 -0
  263. sage/schemes/hyperelliptic_curves/hyperelliptic_padic_field.py +1332 -0
  264. sage/schemes/hyperelliptic_curves/hyperelliptic_rational_field.py +84 -0
  265. sage/schemes/hyperelliptic_curves/invariants.py +410 -0
  266. sage/schemes/hyperelliptic_curves/jacobian_endomorphism_utils.py +312 -0
  267. sage/schemes/hyperelliptic_curves/jacobian_g2.py +32 -0
  268. sage/schemes/hyperelliptic_curves/jacobian_generic.py +437 -0
  269. sage/schemes/hyperelliptic_curves/jacobian_homset.py +186 -0
  270. sage/schemes/hyperelliptic_curves/jacobian_morphism.py +878 -0
  271. sage/schemes/hyperelliptic_curves/kummer_surface.py +99 -0
  272. sage/schemes/hyperelliptic_curves/mestre.py +302 -0
  273. sage/schemes/hyperelliptic_curves/monsky_washnitzer.py +3863 -0
  274. sage/schemes/jacobians/abstract_jacobian.py +277 -0
  275. sage/schemes/jacobians/all.py +2 -0
  276. sage/schemes/overview.py +161 -0
  277. sage/schemes/plane_conics/all.py +22 -0
  278. sage/schemes/plane_conics/con_field.py +1296 -0
  279. sage/schemes/plane_conics/con_finite_field.py +158 -0
  280. sage/schemes/plane_conics/con_number_field.py +456 -0
  281. sage/schemes/plane_conics/con_rational_field.py +406 -0
  282. sage/schemes/plane_conics/con_rational_function_field.py +581 -0
  283. sage/schemes/plane_conics/constructor.py +249 -0
  284. sage/schemes/plane_quartics/all.py +2 -0
  285. sage/schemes/plane_quartics/quartic_constructor.py +71 -0
  286. sage/schemes/plane_quartics/quartic_generic.py +53 -0
  287. sage/schemes/riemann_surfaces/all.py +1 -0
  288. sage/schemes/riemann_surfaces/riemann_surface.py +4177 -0
  289. sage_wheels/share/cremona/cremona_mini.db +0 -0
  290. sage_wheels/share/ellcurves/rank0 +30427 -0
  291. sage_wheels/share/ellcurves/rank1 +31871 -0
  292. sage_wheels/share/ellcurves/rank10 +6 -0
  293. sage_wheels/share/ellcurves/rank11 +6 -0
  294. sage_wheels/share/ellcurves/rank12 +1 -0
  295. sage_wheels/share/ellcurves/rank14 +1 -0
  296. sage_wheels/share/ellcurves/rank15 +1 -0
  297. sage_wheels/share/ellcurves/rank17 +1 -0
  298. sage_wheels/share/ellcurves/rank19 +1 -0
  299. sage_wheels/share/ellcurves/rank2 +2388 -0
  300. sage_wheels/share/ellcurves/rank20 +1 -0
  301. sage_wheels/share/ellcurves/rank21 +1 -0
  302. sage_wheels/share/ellcurves/rank22 +1 -0
  303. sage_wheels/share/ellcurves/rank23 +1 -0
  304. sage_wheels/share/ellcurves/rank24 +1 -0
  305. sage_wheels/share/ellcurves/rank28 +1 -0
  306. sage_wheels/share/ellcurves/rank3 +836 -0
  307. sage_wheels/share/ellcurves/rank4 +10 -0
  308. sage_wheels/share/ellcurves/rank5 +5 -0
  309. sage_wheels/share/ellcurves/rank6 +5 -0
  310. sage_wheels/share/ellcurves/rank7 +5 -0
  311. sage_wheels/share/ellcurves/rank8 +6 -0
  312. sage_wheels/share/ellcurves/rank9 +7 -0
@@ -0,0 +1,2635 @@
1
+ # sage_setup: distribution = sagemath-schemes
2
+ # sage.doctest: needs sage.combinat
3
+ r"""
4
+ Algebra of motivic multiple zeta values
5
+
6
+ This file contains an implementation of the algebra of motivic
7
+ multiple zeta values.
8
+
9
+ The elements of this algebra are not the usual multiple zeta values as
10
+ real numbers defined by concrete iterated integrals, but abstract
11
+ symbols that satisfy all the linear relations between formal iterated
12
+ integrals that come from algebraic geometry (motivic
13
+ relations). Although this set of relations is not explicit, one can
14
+ test the equality as explained in the article [Brown2012]_. One can
15
+ map these motivic multiple zeta values to the associated real
16
+ numbers. Conjecturally, this period map should be injective.
17
+
18
+ The implementation follows closely all the conventions from [Brown2012]_.
19
+
20
+ As a convenient abbreviation, the elements will be called multizetas.
21
+
22
+ EXAMPLES:
23
+
24
+ One can input multizetas using compositions as arguments::
25
+
26
+ sage: Multizeta(3)
27
+ ζ(3)
28
+ sage: Multizeta(2,3,2)
29
+ ζ(2,3,2)
30
+
31
+ as well as linear combinations of them::
32
+
33
+ sage: Multizeta(5)+6*Multizeta(2,3)
34
+ 6*ζ(2,3) + ζ(5)
35
+
36
+ This creates elements of the class :class:`Multizetas`.
37
+
38
+ One can multiply such elements::
39
+
40
+ sage: Multizeta(2)*Multizeta(3)
41
+ 6*ζ(1,4) + 3*ζ(2,3) + ζ(3,2)
42
+
43
+ and their linear combinations::
44
+
45
+ sage: (Multizeta(2)+Multizeta(1,2))*Multizeta(3)
46
+ 9*ζ(1,1,4) + 5*ζ(1,2,3) + 2*ζ(1,3,2) + 6*ζ(1,4) + 2*ζ(2,1,3) + ζ(2,2,2)
47
+ + 3*ζ(2,3) + ζ(3,1,2) + ζ(3,2)
48
+
49
+ The algebra is graded by the weight, which is the sum of the arguments. One
50
+ can extract homogeneous components::
51
+
52
+ sage: z = Multizeta(6)+6*Multizeta(2,3)
53
+ sage: z.homogeneous_component(5)
54
+ 6*ζ(2,3)
55
+
56
+ One can also use the ring of multiple zeta values as a base ring for other
57
+ constructions::
58
+
59
+ sage: Z = Multizeta
60
+ sage: M = matrix(2,2,[Z(2),Z(3),Z(4),Z(5)])
61
+ sage: M.det()
62
+ -10*ζ(1,6) - 5*ζ(2,5) - ζ(3,4) + ζ(4,3) + ζ(5,2)
63
+
64
+ .. rubric:: Auxiliary class for alternative notation
65
+
66
+ One can also use sequences of 0 and 1 as arguments::
67
+
68
+ sage: Multizeta(1,1,0)+3*Multizeta(1,0,0)
69
+ I(110) + 3*I(100)
70
+
71
+ This creates an element of the auxiliary class :class:`Multizetas_iterated`.
72
+ This class is used to represent multiple zeta values as iterated integrals.
73
+
74
+ One can also multiply such elements::
75
+
76
+ sage: Multizeta(1,0)*Multizeta(1,0)
77
+ 4*I(1100) + 2*I(1010)
78
+
79
+ Back-and-forth conversion between the two classes can be done using
80
+ the methods "composition" and "iterated"::
81
+
82
+ sage: (Multizeta(2)*Multizeta(3)).iterated()
83
+ 6*I(11000) + 3*I(10100) + I(10010)
84
+
85
+ sage: (Multizeta(1,0)*Multizeta(1,0)).composition()
86
+ 4*ζ(1,3) + 2*ζ(2,2)
87
+
88
+ Beware that the conversion between these two classes, besides
89
+ exchanging the indexing by words in 0 and 1 and the indexing by
90
+ compositions, also involves the sign `(-1)^w` where `w` is the length
91
+ of the composition and the number of `1` in the associated word in 0
92
+ and 1. For example, one has the equality
93
+
94
+ .. MATH:: \zeta(2,3,4) = (-1)^3 I(1,0,1,0,0,1,0,0,0).
95
+
96
+ .. rubric:: Approximate period map
97
+
98
+ The period map, or rather an approximation, is also available under
99
+ the generic numerical approximation method::
100
+
101
+ sage: z = Multizeta(5)+6*Multizeta(2,3)
102
+ sage: z.n()
103
+ 2.40979014076349
104
+ sage: z.n(prec=100)
105
+ 2.4097901407634924849438423801
106
+
107
+ Behind the scene, all the numerical work is done by the PARI implementation
108
+ of numerical multiple zeta values.
109
+
110
+ .. rubric:: Searching for linear relations
111
+
112
+ All this can be used to find linear dependencies between any set of
113
+ multiple zeta values. Let us illustrate this by an example.
114
+
115
+ Let us first build our sample set::
116
+
117
+ sage: Z = Multizeta
118
+ sage: L = [Z(*c) for c in [(1, 1, 4), (1, 2, 3), (1, 5), (6,)]]
119
+
120
+ Then one can compute the space of relations::
121
+
122
+ sage: M = matrix([Zc.phi_as_vector() for Zc in L])
123
+ sage: K = M.kernel(); K
124
+ Vector space of degree 4 and dimension 2 over Rational Field
125
+ Basis matrix:
126
+ [ 1 0 -2 1/16]
127
+ [ 0 1 6 -13/48]
128
+
129
+ and check that the first relation holds::
130
+
131
+ sage: relation = L[0]-2*L[2]+1/16*L[3]; relation
132
+ ζ(1,1,4) - 2*ζ(1,5) + 1/16*ζ(6)
133
+ sage: relation.phi()
134
+ 0
135
+ sage: relation.is_zero()
136
+ True
137
+
138
+ .. WARNING::
139
+
140
+ Because this code uses an hardcoded multiplicative basis that is
141
+ available up to weight 17 included, some parts will not work
142
+ in larger weights, in particular the test of equality.
143
+
144
+ REFERENCES:
145
+
146
+ .. [Brown2012] Francis C. S. Brown, *On the decomposition of motivic
147
+ multiple zeta values*, Advanced Studies in Pure Mathematics 63,
148
+ 2012. Galois-Teichmuller Theory and Arithmetic Geometry.
149
+
150
+ .. [Brown2019] Francis C. S. Brown, *From the Deligne-Ihara conjecture to
151
+ multiple modular values*, :arxiv:`1904.00179`
152
+
153
+ .. [Deli2012] Pierre Deligne, *Multizêtas, d’après Francis Brown*,
154
+ Séminaire Bourbaki, janvier 2012. http://www.bourbaki.ens.fr/TEXTES/1048.pdf
155
+
156
+ .. [Stie2020] \S. Stieberger, *Periods and Superstring Amplitudes*,
157
+ Periods in Quantum Field Theory and Arithmetic, Springer Proceedings
158
+ in Mathematics and Statistics 314, 2020
159
+ """
160
+ # ****************************************************************************
161
+ # Copyright (C) 2020 Frédéric Chapoton
162
+ #
163
+ # Distributed under the terms of the GNU General Public License (GPL)
164
+ # as published by the Free Software Foundation; either version 2 of
165
+ # the License, or (at your option) any later version.
166
+ #
167
+ # https://www.gnu.org/licenses/
168
+ # ****************************************************************************
169
+ from __future__ import annotations
170
+ import numbers
171
+ from itertools import product
172
+
173
+ from sage.misc.fast_methods import Singleton
174
+ from sage.structure.richcmp import op_EQ, op_NE
175
+ from sage.structure.element import parent
176
+ from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis
177
+ from sage.categories.rings import Rings
178
+ from sage.categories.domains import Domains
179
+ from sage.combinat.composition import Compositions
180
+ from sage.combinat.free_module import CombinatorialFreeModule
181
+ from sage.combinat.integer_vector import IntegerVectors
182
+ from sage.combinat.partition import Partitions
183
+ from sage.combinat.words.finite_word import FiniteWord_class
184
+ from sage.combinat.words.word import Word
185
+ from sage.combinat.words.words import Words
186
+ from sage.combinat.words.shuffle_product import ShuffleProduct_w1w2 as shuffle
187
+ from sage.matrix.constructor import matrix
188
+ from sage.misc.cachefunc import cached_function, cached_method
189
+ from sage.misc.lazy_attribute import lazy_attribute
190
+ from sage.misc.lazy_import import lazy_import
191
+ from sage.misc.misc_c import prod
192
+ from sage.modular.multiple_zeta_F_algebra import F_algebra
193
+ from sage.modules.free_module import VectorSpace
194
+ from sage.rings.integer_ring import ZZ
195
+ from sage.rings.rational_field import QQ
196
+ from sage.sets.positive_integers import PositiveIntegers
197
+ from typing import TYPE_CHECKING
198
+
199
+ if TYPE_CHECKING:
200
+ from collections.abc import Iterator
201
+
202
+ lazy_import('sage.libs.pari', 'pari')
203
+
204
+
205
+ # multiplicative generators for weight <= 17
206
+ # using the following convention
207
+ # (3, 5) <---> (sign) * [1,0,0,1,0,0,0,0]
208
+ # taken from the Maple implementation by F. Brown
209
+ B_data: list[list[tuple]] = [[], [], [(2,)], [(3,)], [], [(5,)], [],
210
+ [(7,)], [(3, 5)], [(9,)],
211
+ [(3, 7)], [(11,), (3, 3, 5)],
212
+ [(5, 7), (5, 3, 2, 2)],
213
+ [(13,), (3, 5, 5), (3, 3, 7)],
214
+ [(5, 9), (3, 11), (3, 3, 3, 5)],
215
+ [(15,), (3, 5, 7), (3, 3, 9), (5, 3, 3, 2, 2)],
216
+ [(11, 5), (13, 3), (5, 5, 3, 3),
217
+ (7, 3, 3, 3), (7, 5, 2, 2)],
218
+ [(17,), (7, 5, 5), (9, 3, 5), (9, 5, 3),
219
+ (11, 3, 3), (5, 3, 3, 3, 3), (5, 5, 3, 2, 2)]]
220
+
221
+ Words10 = Words((1, 0), infinite=False)
222
+
223
+
224
+ def coproduct_iterator(paire) -> Iterator[list]:
225
+ """
226
+ Return an iterator for terms in the coproduct.
227
+
228
+ This is an auxiliary function.
229
+
230
+ INPUT:
231
+
232
+ - ``paire`` -- a pair (list of indices, end of word)
233
+
234
+ OUTPUT: iterator for terms in the motivic coproduct
235
+
236
+ Each term is seen as a list of positions.
237
+
238
+ EXAMPLES::
239
+
240
+ sage: from sage.modular.multiple_zeta import coproduct_iterator
241
+ sage: list(coproduct_iterator(([0],[0,1,0,1])))
242
+ [[0, 1, 2, 3]]
243
+ sage: list(coproduct_iterator(([0],[0,1,0,1,1,0,1])))
244
+ [[0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 6], [0, 1, 5, 6], [0, 4, 5, 6], [0, 6]]
245
+ """
246
+ head, tail = paire
247
+ n = len(tail)
248
+ if n == 1:
249
+ yield head
250
+ return
251
+ start_value = tail[0]
252
+ last_index = head[-1]
253
+ yield from coproduct_iterator((head + [last_index + 1], tail[1:]))
254
+ for step in range(4, n):
255
+ if step == 5:
256
+ continue
257
+ if tail[step] != start_value:
258
+ yield from coproduct_iterator((head + [last_index + step],
259
+ tail[step:]))
260
+
261
+
262
+ def composition_to_iterated(w, reverse=False) -> tuple[int, ...]:
263
+ """
264
+ Convert a composition to a word in 0 and 1.
265
+
266
+ By default, the chosen convention maps (2,3) to (1,0,1,0,0),
267
+ respecting the reading order from left to right.
268
+
269
+ The inverse map is given by :func:`iterated_to_composition`.
270
+
271
+ EXAMPLES::
272
+
273
+ sage: from sage.modular.multiple_zeta import composition_to_iterated
274
+ sage: composition_to_iterated((1,2))
275
+ (1, 1, 0)
276
+ sage: composition_to_iterated((3,1,2))
277
+ (1, 0, 0, 1, 1, 0)
278
+ sage: composition_to_iterated((3,1,2,4))
279
+ (1, 0, 0, 1, 1, 0, 1, 0, 0, 0)
280
+
281
+ TESTS::
282
+
283
+ sage: composition_to_iterated((1,2), True)
284
+ (1, 0, 1)
285
+ """
286
+ word = ()
287
+ loop_over = reversed(w) if reverse else w
288
+ for letter in loop_over:
289
+ word += (1,) + (0,) * (letter - 1)
290
+ return word
291
+
292
+
293
+ def iterated_to_composition(w, reverse=False) -> tuple[int, ...]:
294
+ """
295
+ Convert a word in 0 and 1 to a composition.
296
+
297
+ By default, the chosen convention maps (1,0,1,0,0) to (2,3).
298
+
299
+ The inverse map is given by :func:`composition_to_iterated`.
300
+
301
+ EXAMPLES::
302
+
303
+ sage: from sage.modular.multiple_zeta import iterated_to_composition
304
+ sage: iterated_to_composition([1,0,1,0,0])
305
+ (2, 3)
306
+ sage: iterated_to_composition(Word([1,1,0]))
307
+ (1, 2)
308
+ sage: iterated_to_composition(Word([1,1,0,1,1,0,0]))
309
+ (1, 2, 1, 3)
310
+
311
+ TESTS::
312
+
313
+ sage: iterated_to_composition([1,0,1,0,0], True)
314
+ (3, 2)
315
+ """
316
+ b = []
317
+ count = 1
318
+ for letter in reversed(w):
319
+ if letter == 0:
320
+ count += 1
321
+ else:
322
+ b.append(count)
323
+ count = 1
324
+ return tuple(b) if reverse else tuple(reversed(b))
325
+
326
+
327
+ def dual_composition(c) -> tuple[int, ...]:
328
+ """
329
+ Return the dual composition of ``c``.
330
+
331
+ This is an involution on compositions such that associated
332
+ multizetas are equal.
333
+
334
+ INPUT:
335
+
336
+ - ``c`` -- a composition
337
+
338
+ OUTPUT: a composition
339
+
340
+ EXAMPLES::
341
+
342
+ sage: from sage.modular.multiple_zeta import dual_composition
343
+ sage: dual_composition([3])
344
+ (1, 2)
345
+ sage: dual_composition(dual_composition([3,4,5])) == (3,4,5)
346
+ True
347
+ """
348
+ i = composition_to_iterated(c)
349
+ ri = [1 - x for x in reversed(i)]
350
+ return iterated_to_composition(ri)
351
+
352
+
353
+ def minimize_term(w, cf):
354
+ """
355
+ Return the largest among ``w`` and the dual word of ``w``.
356
+
357
+ INPUT:
358
+
359
+ - ``w`` -- a word in the letters 0 and 1
360
+
361
+ - ``cf`` -- a coefficient
362
+
363
+ OUTPUT:
364
+
365
+ (word, coefficient)
366
+
367
+ The chosen order is lexicographic with 1 < 0.
368
+
369
+ If the dual word is chosen, the sign of the coefficient is changed,
370
+ otherwise the coefficient is returned unchanged.
371
+
372
+ EXAMPLES::
373
+
374
+ sage: from sage.modular.multiple_zeta import minimize_term, Words10
375
+ sage: minimize_term(Words10((1,1,0)), 1)
376
+ (word: 100, -1)
377
+ sage: minimize_term(Words10((1,0,0)), 1)
378
+ (word: 100, 1)
379
+ """
380
+ reverse_w = tuple(1 - t for t in reversed(w))
381
+ for x, y in zip(w, reverse_w):
382
+ if x < y:
383
+ return (w, cf)
384
+ if x > y:
385
+ return (Words10(reverse_w, check=False),
386
+ -cf if len(w) % 2 else cf)
387
+ return (w, cf)
388
+
389
+
390
+ # numerical values
391
+
392
+ class MultizetaValues(Singleton):
393
+ """
394
+ Custom cache for numerical values of multiple zetas.
395
+
396
+ Computations are performed using the PARI/GP :pari:`zetamultall` (for the
397
+ cache) and :pari:`zetamult` (for indices/precision outside of the cache).
398
+
399
+ EXAMPLES::
400
+
401
+ sage: from sage.modular.multiple_zeta import MultizetaValues
402
+ sage: M = MultizetaValues()
403
+
404
+ sage: M((1,2))
405
+ 1.202056903159594285399738161511449990764986292340...
406
+ sage: parent(M((2,3)))
407
+ Real Field with 1024 bits of precision
408
+
409
+ sage: M((2,3), prec=53)
410
+ 0.228810397603354
411
+ sage: parent(M((2,3), prec=53))
412
+ Real Field with 53 bits of precision
413
+
414
+ sage: M((2,3), reverse=False) == M((3,2))
415
+ True
416
+
417
+ sage: M((2,3,4,5))
418
+ 2.9182061974731261426525583710934944310404272413...e-6
419
+ sage: M((2,3,4,5), reverse=False)
420
+ 0.0011829360522243605614404196778185433287651...
421
+
422
+ sage: parent(M((2,3,4,5)))
423
+ Real Field with 1024 bits of precision
424
+ sage: parent(M((2,3,4,5), prec=128))
425
+ Real Field with 128 bits of precision
426
+ """
427
+ def __init__(self) -> None:
428
+ """
429
+ When first called, pre-compute up to weight 8 at precision 1024.
430
+
431
+ TESTS::
432
+
433
+ sage: from sage.modular.multiple_zeta import MultizetaValues
434
+ sage: M = MultizetaValues()
435
+ """
436
+ self.max_weight = 0
437
+ self.prec = 0
438
+ self.reset()
439
+
440
+ def __repr__(self) -> str:
441
+ r"""
442
+ TESTS::
443
+
444
+ sage: from sage.modular.multiple_zeta import MultizetaValues
445
+ sage: MultizetaValues()
446
+ Cached multiple zeta values at precision 1024 up to weight 8
447
+ """
448
+ return f"Cached multiple zeta values at precision {self.prec} up to weight {self.max_weight}"
449
+
450
+ def reset(self, max_weight=8, prec=1024) -> None:
451
+ r"""
452
+ Reset the cache to its default values or to given arguments.
453
+
454
+ TESTS::
455
+
456
+ sage: from sage.modular.multiple_zeta import MultizetaValues
457
+ sage: M = MultizetaValues()
458
+ sage: M
459
+ Cached multiple zeta values at precision 1024 up to weight 8
460
+ sage: M.reset(5, 64)
461
+ sage: M
462
+ Cached multiple zeta values at precision 64 up to weight 5
463
+ sage: M.reset()
464
+ sage: M
465
+ Cached multiple zeta values at precision 1024 up to weight 8
466
+ """
467
+ self.prec = int(prec)
468
+ self.max_weight = int(max_weight)
469
+ self._data = pari.zetamultall(self.max_weight, precision=self.prec)
470
+
471
+ def update(self, max_weight, prec) -> None:
472
+ """
473
+ Compute and store more values if needed.
474
+
475
+ TESTS::
476
+
477
+ sage: from sage.modular.multiple_zeta import MultizetaValues
478
+ sage: M = MultizetaValues()
479
+ sage: M
480
+ Cached multiple zeta values at precision 1024 up to weight 8
481
+ sage: M.update(5, 64)
482
+ sage: M
483
+ Cached multiple zeta values at precision 1024 up to weight 8
484
+ sage: M.update(5, 2048)
485
+ sage: M
486
+ Cached multiple zeta values at precision 2048 up to weight 8
487
+ sage: M.reset()
488
+ """
489
+ if self.prec < prec or self.max_weight < max_weight:
490
+ self.reset(max(self.max_weight, max_weight), max(self.prec, prec))
491
+
492
+ def pari_eval(self, index):
493
+ r"""
494
+ TESTS::
495
+
496
+ sage: from sage.modular.multiple_zeta import MultizetaValues
497
+ sage: M = MultizetaValues()
498
+ sage: [M.pari_eval((n,)) for n in range(2,20)]
499
+ [1.64493406684823, 1.20205690315959, 1.08232323371114, 1.03692775514337, ... 1.00000381729326, 1.00000190821272]
500
+ """
501
+ weight = sum(index)
502
+ index = list(reversed(index))
503
+ if weight <= self.max_weight:
504
+ index = pari.zetamultconvert(index, 2)
505
+ return self._data[index - 1]
506
+ return pari.zetamult(index, precision=self.prec)
507
+
508
+ def __call__(self, index, prec=None, reverse=True):
509
+ r"""
510
+ Numerical multiple zeta value as a Sage real floating point number.
511
+
512
+ TESTS::
513
+
514
+ sage: from sage.modular.multiple_zeta import MultizetaValues
515
+
516
+ sage: V = MultizetaValues()
517
+ sage: V((3,2))
518
+ 0.7115661975505724320969738060864026120925612044383392364...
519
+ sage: V((3,2), reverse=False)
520
+ 0.2288103976033537597687461489416887919325093427198821602...
521
+ sage: V((3,2), prec=128)
522
+ 0.71156619755057243209697380608640261209
523
+ sage: V((3,2), prec=128, reverse=False)
524
+ 0.22881039760335375976874614894168879193
525
+
526
+ sage: V((1,3))
527
+ 0.2705808084277845478790009241352919756936877379796817269...
528
+ sage: V((3,1), reverse=False)
529
+ 0.2705808084277845478790009241352919756936877379796817269...
530
+
531
+ sage: V((3,1))
532
+ Traceback (most recent call last):
533
+ ...
534
+ ValueError: divergent zeta value
535
+ sage: V((1,3), reverse=False)
536
+ Traceback (most recent call last):
537
+ ...
538
+ ValueError: divergent zeta value
539
+ """
540
+ if reverse:
541
+ index = list(reversed(index))
542
+ if index[0] == 1:
543
+ raise ValueError("divergent zeta value")
544
+ if prec is None:
545
+ prec = self.prec
546
+ weight = sum(index)
547
+ if weight <= self.max_weight and prec <= self.prec:
548
+ index = pari.zetamultconvert(index, 2)
549
+ value = self._data[index - 1]
550
+ return value.sage().n(prec=prec)
551
+ return pari.zetamult(index, precision=prec).sage().n(prec=prec)
552
+
553
+
554
+ Values = MultizetaValues()
555
+
556
+
557
+ def extend_multiplicative_basis(B, n) -> Iterator[tuple]:
558
+ """
559
+ Extend a multiplicative basis into a basis.
560
+
561
+ This is an iterator.
562
+
563
+ INPUT:
564
+
565
+ - ``B`` -- function mapping integer to list of tuples of compositions
566
+
567
+ - ``n`` -- integer
568
+
569
+ OUTPUT: each term is a tuple of tuples of compositions
570
+
571
+ EXAMPLES::
572
+
573
+ sage: from sage.modular.multiple_zeta import extend_multiplicative_basis
574
+ sage: from sage.modular.multiple_zeta import B_data
575
+ sage: list(extend_multiplicative_basis(B_data,5))
576
+ [((5,),), ((3,), (2,))]
577
+ sage: list(extend_multiplicative_basis(B_data,6))
578
+ [((3,), (3,)), ((2,), (2,), (2,))]
579
+ sage: list(extend_multiplicative_basis(B_data,7))
580
+ [((7,),), ((5,), (2,)), ((3,), (2,), (2,))]
581
+ """
582
+ for pi in Partitions(n, min_part=2):
583
+ yield from product(*[B[i] for i in pi])
584
+
585
+
586
+ # several classes for the algebra of MZV
587
+
588
+
589
+ def Multizeta(*args):
590
+ r"""
591
+ Common entry point for multiple zeta values.
592
+
593
+ If the argument is a sequence of 0 and 1, an element of
594
+ :class:`Multizetas_iterated` will be returned.
595
+
596
+ Otherwise, an element of :class:`Multizetas` will be returned.
597
+
598
+ The base ring is `\QQ`.
599
+
600
+ EXAMPLES::
601
+
602
+ sage: Z = Multizeta
603
+ sage: Z(1,0,1,0)
604
+ I(1010)
605
+ sage: Z(3,2,2)
606
+ ζ(3,2,2)
607
+
608
+ TESTS::
609
+
610
+ sage: Z(3,2,2).iterated().composition()
611
+ ζ(3,2,2)
612
+ sage: Z(1,0,1,0).composition().iterated()
613
+ I(1010)
614
+ """
615
+ if 0 in args:
616
+ return Multizetas_iterated(QQ)(tuple(args))
617
+ return Multizetas(QQ)(tuple(args))
618
+
619
+
620
+ class Multizetas(CombinatorialFreeModule):
621
+ r"""
622
+ Main class for the algebra of multiple zeta values.
623
+
624
+ The convention is chosen so that `\zeta(1,2)` is convergent.
625
+
626
+ EXAMPLES::
627
+
628
+ sage: M = Multizetas(QQ)
629
+ sage: x = M((2,))
630
+ sage: y = M((4,3))
631
+ sage: x+5*y
632
+ ζ(2) + 5*ζ(4,3)
633
+ sage: x*y
634
+ 6*ζ(1,4,4) + 8*ζ(1,5,3) + 3*ζ(2,3,4) + 4*ζ(2,4,3) + 3*ζ(3,2,4)
635
+ + 2*ζ(3,3,3) + 6*ζ(4,1,4) + 3*ζ(4,2,3) + ζ(4,3,2)
636
+
637
+ TESTS::
638
+
639
+ sage: A = QQ['u']
640
+ sage: u = A.gen()
641
+ sage: M = Multizetas(A)
642
+ sage: (u*M((2,))+M((3,)))*M((2,))
643
+ 4*u*ζ(1,3) + 6*ζ(1,4) + 2*u*ζ(2,2) + 3*ζ(2,3) + ζ(3,2)
644
+
645
+ Check for :issue:`30925`::
646
+
647
+ sage: M = Multizetas(QQ)
648
+ sage: l = [1,2,3]
649
+ sage: z = M(l)
650
+ sage: l[0] = 19
651
+ sage: z
652
+ ζ(1,2,3)
653
+ """
654
+ def __init__(self, R) -> None:
655
+ """
656
+ TESTS::
657
+
658
+ sage: M = Multizetas(QQ)
659
+ sage: TestSuite(M).run() # not tested
660
+ sage: M.category()
661
+ Category of commutative no zero divisors graded algebras
662
+ with basis over Rational Field
663
+ """
664
+ if R not in Rings():
665
+ raise TypeError("argument R must be a ring")
666
+ cat = GradedAlgebrasWithBasis(R).Commutative()
667
+ if R in Domains():
668
+ cat = cat & Domains()
669
+ W = Words(PositiveIntegers(), infinite=False)
670
+ CombinatorialFreeModule.__init__(self, R, W, prefix='Z', category=cat)
671
+
672
+ def _repr_(self) -> str:
673
+ r"""
674
+ Return a string representation of the algebra.
675
+
676
+ EXAMPLES::
677
+
678
+ sage: M = Multizetas(QQ); M
679
+ Algebra of motivic multiple zeta values indexed by compositions over Rational Field
680
+ """
681
+ txt = "Algebra of motivic multiple zeta values indexed by compositions over {}"
682
+ return txt.format(self.base_ring())
683
+
684
+ def _repr_term(self, m) -> str:
685
+ """
686
+ Return a custom string representation for the monomials.
687
+
688
+ EXAMPLES::
689
+
690
+ sage: Multizeta(2,3) # indirect doctest
691
+ ζ(2,3)
692
+ """
693
+ return "ζ(" + ','.join(str(letter) for letter in m) + ")"
694
+
695
+ def _latex_term(self, m) -> str:
696
+ r"""
697
+ Return a custom latex representation for the monomials.
698
+
699
+ EXAMPLES::
700
+
701
+ sage: latex(Multizeta(2,3) - 3/5 * Multizeta(1,1,2)) # indirect doctest
702
+ -\frac{3}{5} \zeta(1,1,2) + \zeta(2,3)
703
+ """
704
+ return "\\zeta(" + ','.join(str(letter) for letter in m) + ")"
705
+
706
+ @cached_method
707
+ def one_basis(self):
708
+ r"""
709
+ Return the index of the unit for the algebra.
710
+
711
+ This is the empty word.
712
+
713
+ EXAMPLES::
714
+
715
+ sage: M = Multizetas(QQ)
716
+ sage: M.one_basis()
717
+ word:
718
+ """
719
+ return self.basis().keys()([], check=False)
720
+
721
+ def some_elements(self) -> tuple:
722
+ r"""
723
+ Return some elements of the algebra.
724
+
725
+ EXAMPLES::
726
+
727
+ sage: M = Multizetas(QQ)
728
+ sage: M.some_elements()
729
+ (ζ(), ζ(2), ζ(3), ζ(4), ζ(1,2))
730
+ """
731
+ return self([]), self([2]), self([3]), self([4]), self((1, 2))
732
+
733
+ def _an_element_(self):
734
+ r"""
735
+ Return an element of the algebra.
736
+
737
+ EXAMPLES::
738
+
739
+ sage: M = Multizetas(QQ)
740
+ sage: M.an_element()
741
+ ζ() + ζ(1,2) + 1/2*ζ(5)
742
+ """
743
+ cf = self.base_ring().an_element()
744
+ return self([]) + self([1, 2]) + cf * self([5])
745
+
746
+ def product_on_basis(self, w1, w2):
747
+ r"""
748
+ Compute the product of two monomials.
749
+
750
+ This is done by converting to iterated integrals and
751
+ using the shuffle product.
752
+
753
+ INPUT:
754
+
755
+ - ``w1``, ``w2`` -- compositions as words
756
+
757
+ EXAMPLES::
758
+
759
+ sage: M = Multizetas(QQ)
760
+ sage: W = M.basis().keys()
761
+ sage: M.product_on_basis(W([2]),W([2]))
762
+ 4*ζ(1,3) + 2*ζ(2,2)
763
+ sage: x = M((2,))
764
+ sage: x*x
765
+ 4*ζ(1,3) + 2*ζ(2,2)
766
+ """
767
+ if not w1:
768
+ return self._monomial(w2)
769
+ if not w2:
770
+ return self._monomial(w1)
771
+ p1 = self.iterated_on_basis(w1)
772
+ p2 = self.iterated_on_basis(w2)
773
+ p1p2 = p1 * p2
774
+ MZV_it = p1p2.parent()
775
+ return MZV_it.composition(p1p2)
776
+
777
+ def half_product(self, w1, w2):
778
+ r"""
779
+ Compute half of the product of two elements.
780
+
781
+ This comes from half of the shuffle product.
782
+
783
+ .. WARNING:: This is not a motivic operation.
784
+
785
+ INPUT:
786
+
787
+ - ``w1``, ``w2`` -- elements
788
+
789
+ EXAMPLES::
790
+
791
+ sage: M = Multizetas(QQ)
792
+ sage: M.half_product(M([2]),M([2]))
793
+ 2*ζ(1,3) + ζ(2,2)
794
+
795
+ TESTS:
796
+
797
+ sage: M.half_product(M.one(), M([2]))
798
+ Traceback (most recent call last):
799
+ ...
800
+ ValueError: not defined on the unit
801
+ """
802
+ empty = self.one_basis()
803
+ if w1.coefficient(empty) or w2.coefficient(empty):
804
+ raise ValueError('not defined on the unit')
805
+ p1 = self.iterated(w1)
806
+ p2 = self.iterated(w2)
807
+ MZV_it = p1.parent()
808
+ p1p2 = MZV_it.half_product(p1, p2)
809
+ return MZV_it.composition(p1p2)
810
+
811
+ @lazy_attribute
812
+ def iterated(self):
813
+ """
814
+ Convert to the algebra of iterated integrals.
815
+
816
+ This is also available as a method of elements.
817
+
818
+ EXAMPLES::
819
+
820
+ sage: M = Multizetas(QQ)
821
+ sage: x = M((3,2))
822
+ sage: M.iterated(3*x)
823
+ 3*I(10010)
824
+ sage: x = M((2,3,2))
825
+ sage: M.iterated(4*x)
826
+ -4*I(1010010)
827
+ """
828
+ cod = Multizetas_iterated(self.base_ring())
829
+ return self.module_morphism(self.iterated_on_basis, codomain=cod)
830
+
831
+ def iterated_on_basis(self, w):
832
+ """
833
+ Convert to the algebra of iterated integrals.
834
+
835
+ Beware that this conversion involves signs in our chosen convention.
836
+
837
+ INPUT:
838
+
839
+ - ``w`` -- a word
840
+
841
+ EXAMPLES::
842
+
843
+ sage: M = Multizetas(QQ)
844
+ sage: x = M.basis().keys()((3,2))
845
+ sage: M.iterated_on_basis(x)
846
+ I(10010)
847
+ sage: x = M.basis().keys()((2,3,2))
848
+ sage: M.iterated_on_basis(x)
849
+ -I(1010010)
850
+ """
851
+ codomain = Multizetas_iterated(self.base_ring())
852
+ image = codomain(composition_to_iterated(w))
853
+ return -image if len(w) % 2 else image
854
+
855
+ def degree_on_basis(self, w):
856
+ """
857
+ Return the degree of the monomial ``w``.
858
+
859
+ This is the sum of terms in ``w``.
860
+
861
+ INPUT:
862
+
863
+ - ``w`` -- a composition
864
+
865
+ EXAMPLES::
866
+
867
+ sage: M = Multizetas(QQ)
868
+ sage: x = (2,3)
869
+ sage: M.degree_on_basis(x) # indirect doctest
870
+ 5
871
+ """
872
+ return ZZ(sum(w))
873
+
874
+ @lazy_attribute
875
+ def phi(self):
876
+ r"""
877
+ Return the morphism ``phi``.
878
+
879
+ This sends multiple zeta values to the auxiliary F-algebra,
880
+ which is a shuffle algebra in odd generators `f_3,f_5,f_7,\dots`
881
+ over the polynomial ring in one variable `f_2`.
882
+
883
+ This is a ring isomorphism, that depends on the choice of a
884
+ multiplicative basis for the ring of motivic multiple zeta
885
+ values. Here we use one specific hardcoded basis.
886
+
887
+ For the precise definition of ``phi`` by induction, see [Brown2012]_.
888
+
889
+ EXAMPLES::
890
+
891
+ sage: M = Multizetas(QQ)
892
+ sage: m = Multizeta(2,2) + 2*Multizeta(1,3); m
893
+ 2*ζ(1,3) + ζ(2,2)
894
+ sage: M.phi(m)
895
+ 1/2*f2^2
896
+
897
+ sage: Z = Multizeta
898
+ sage: B5 = [3*Z(1,4) + 2*Z(2,3) + Z(3,2), 3*Z(1,4) + Z(2,3)]
899
+ sage: [M.phi(b) for b in B5]
900
+ [-1/2*f5 + f2*f3, 1/2*f5]
901
+ """
902
+ M_it = Multizetas_iterated(self.base_ring())
903
+ return M_it.phi * self.iterated
904
+
905
+ def _element_constructor_(self, x):
906
+ r"""
907
+ Convert ``x`` into ``self``.
908
+
909
+ INPUT:
910
+
911
+ - ``x`` -- either a list, tuple, word or a multiple zeta value
912
+
913
+ EXAMPLES::
914
+
915
+ sage: M = Multizetas(QQ)
916
+ sage: M(Word((2,3)))
917
+ ζ(2,3)
918
+ sage: M(Word([2,3]))
919
+ ζ(2,3)
920
+ sage: x = M((2,3)); x
921
+ ζ(2,3)
922
+ sage: M(x) == x
923
+ True
924
+
925
+ sage: M() == M(0) == M.zero()
926
+ True
927
+ sage: M([]) == M(1) == M.one()
928
+ True
929
+
930
+ sage: M('heyho')
931
+ Traceback (most recent call last):
932
+ ...
933
+ TypeError: invalid input for building a multizeta value
934
+ """
935
+ if isinstance(x, (FiniteWord_class, tuple, list)):
936
+ if not all(isinstance(letter, numbers.Integral) for letter in x):
937
+ raise ValueError('invalid input for building a multizeta value')
938
+ if x and x[-1] == 1:
939
+ raise ValueError('divergent zeta value')
940
+ W = self.basis().keys()
941
+ if isinstance(x, list):
942
+ x = tuple(x)
943
+ return self._monomial(W(x, check=False))
944
+ if isinstance(parent(x), Multizetas_iterated):
945
+ return x.composition()
946
+ raise TypeError('invalid input for building a multizeta value')
947
+
948
+ def algebra_generators(self, n) -> list:
949
+ """
950
+ Return a set of multiplicative generators in weight ``n``.
951
+
952
+ This is obtained from hardcoded data, available only up to weight 17.
953
+
954
+ INPUT:
955
+
956
+ - ``n`` -- integer
957
+
958
+ EXAMPLES::
959
+
960
+ sage: M = Multizetas(QQ)
961
+ sage: M.algebra_generators(5)
962
+ [ζ(5)]
963
+ sage: M.algebra_generators(8)
964
+ [ζ(3,5)]
965
+ """
966
+ W = self.basis().keys()
967
+ return [self._monomial(W(b, check=False)) for b in B_data[n]]
968
+
969
+ def basis_data(self, basering, n) -> Iterator:
970
+ """
971
+ Return an iterator for a basis in weight ``n``.
972
+
973
+ This is obtained from hardcoded data, available only up to weight 17.
974
+
975
+ INPUT:
976
+
977
+ - ``n`` -- integer
978
+
979
+ EXAMPLES::
980
+
981
+ sage: M = Multizetas(QQ)
982
+ sage: list(M.basis_data(QQ, 4))
983
+ [4*ζ(1,3) + 2*ζ(2,2)]
984
+ """
985
+ basis_MZV = extend_multiplicative_basis(B_data, n)
986
+ W = self.basis().keys()
987
+ return (prod(self._monomial(W(compo, check=False))
988
+ for compo in term) for term in basis_MZV)
989
+
990
+ def basis_brown(self, n) -> list:
991
+ r"""
992
+ Return a basis of the algebra of multiple zeta values in weight ``n``.
993
+
994
+ It was proved by Francis Brown that this is a basis of motivic
995
+ multiple zeta values.
996
+
997
+ This is made of all `\zeta(n_1, ..., n_r)` with parts in {2,3}.
998
+
999
+ INPUT:
1000
+
1001
+ - ``n`` -- integer
1002
+
1003
+ EXAMPLES::
1004
+
1005
+ sage: M = Multizetas(QQ)
1006
+ sage: M.basis_brown(3)
1007
+ [ζ(3)]
1008
+ sage: M.basis_brown(4)
1009
+ [ζ(2,2)]
1010
+ sage: M.basis_brown(5)
1011
+ [ζ(3,2), ζ(2,3)]
1012
+ sage: M.basis_brown(6)
1013
+ [ζ(3,3), ζ(2,2,2)]
1014
+ """
1015
+ W = self.basis().keys()
1016
+ return [self._monomial(W(tuple(c), check=False))
1017
+ for c in IntegerVectors(n, min_part=2, max_part=3)]
1018
+
1019
+ @cached_method
1020
+ def basis_filtration(self, d, reverse=False):
1021
+ r"""
1022
+ Return a module basis of the homogeneous components of weight ``d`` compatible with
1023
+ the length filtration.
1024
+
1025
+ INPUT:
1026
+
1027
+ - ``d`` -- nonnegative integer; the weight
1028
+
1029
+ - ``reverse`` -- boolean (default: ``False``); change the ordering of compositions
1030
+
1031
+ EXAMPLES::
1032
+
1033
+ sage: M = Multizetas(QQ)
1034
+
1035
+ sage: M.basis_filtration(5)
1036
+ [ζ(5), ζ(1,4)]
1037
+ sage: M.basis_filtration(6)
1038
+ [ζ(6), ζ(1,5)]
1039
+ sage: M.basis_filtration(8)
1040
+ [ζ(8), ζ(1,7), ζ(2,6), ζ(1,1,6)]
1041
+ sage: M.basis_filtration(8, reverse=True)
1042
+ [ζ(8), ζ(6,2), ζ(5,3), ζ(5,1,2)]
1043
+
1044
+ sage: M.basis_filtration(0)
1045
+ [ζ()]
1046
+ sage: M.basis_filtration(1)
1047
+ []
1048
+ """
1049
+ if d < 0:
1050
+ raise ValueError('d must be a nonnegative integer')
1051
+ if d == 0:
1052
+ return [self([])]
1053
+ if d == 1:
1054
+ return []
1055
+
1056
+ W = self.basis().keys()
1057
+ Values.reset(max_weight=d)
1058
+ dim = len(self((d,)).phi_as_vector())
1059
+ V = VectorSpace(QQ, dim)
1060
+ U = V.subspace([])
1061
+ basis: list = []
1062
+ k = 1
1063
+ while len(basis) < dim:
1064
+ for c in Compositions(d, length=k):
1065
+ if reverse:
1066
+ if c[-1] == 1:
1067
+ continue
1068
+ c = tuple(c)
1069
+ else:
1070
+ if c[0] == 1:
1071
+ continue
1072
+ c = c[::-1]
1073
+ mon_c = self._monomial(W(c, check=False))
1074
+ v = mon_c.phi_as_vector()
1075
+ if v in U:
1076
+ continue
1077
+ U = V.subspace(U.basis() + [v])
1078
+ basis.append(mon_c)
1079
+ k += 1
1080
+ return basis
1081
+
1082
+ class Element(CombinatorialFreeModule.Element):
1083
+ def iterated(self):
1084
+ """
1085
+ Convert to the algebra of iterated integrals.
1086
+
1087
+ Beware that this conversion involves signs.
1088
+
1089
+ EXAMPLES::
1090
+
1091
+ sage: M = Multizetas(QQ)
1092
+ sage: x = M((2,3,4))
1093
+ sage: x.iterated()
1094
+ -I(101001000)
1095
+ """
1096
+ return self.parent().iterated(self)
1097
+
1098
+ def single_valued(self):
1099
+ r"""
1100
+ Return the single-valued version of ``self``.
1101
+
1102
+ This is the projection map onto the sub-algebra of
1103
+ single-valued motivic multiple zeta values, as defined by
1104
+ F. Brown in [Bro2013]_.
1105
+
1106
+ This morphism of algebras sends in particular `\zeta(2)` to `0`.
1107
+
1108
+ EXAMPLES::
1109
+
1110
+ sage: M = Multizetas(QQ)
1111
+ sage: x = M((2,))
1112
+ sage: x.single_valued()
1113
+ 0
1114
+ sage: x = M((3,))
1115
+ sage: x.single_valued()
1116
+ 2*ζ(3)
1117
+ sage: x = M((5,))
1118
+ sage: x.single_valued()
1119
+ 2*ζ(5)
1120
+ sage: x = M((2,3))
1121
+ sage: x.single_valued()
1122
+ -11*ζ(5)
1123
+
1124
+ sage: Z = Multizeta
1125
+ sage: Z(3,5).single_valued() == -10*Z(3)*Z(5)
1126
+ True
1127
+ sage: Z(5,3).single_valued() == 14*Z(3)*Z(5)
1128
+ True
1129
+ """
1130
+ return rho_inverse(self.phi().single_valued())
1131
+
1132
+ def simplify(self):
1133
+ """
1134
+ Gather terms using the duality relations.
1135
+
1136
+ This can help to lower the number of monomials.
1137
+
1138
+ EXAMPLES::
1139
+
1140
+ sage: M = Multizetas(QQ)
1141
+ sage: z = 3*M((3,)) + 5*M((1,2))
1142
+ sage: z.simplify()
1143
+ 8*ζ(3)
1144
+ """
1145
+ return self.iterated().simplify().composition()
1146
+
1147
+ def simplify_full(self, basis=None):
1148
+ r"""
1149
+ Rewrite the term in a given basis.
1150
+
1151
+ INPUT:
1152
+
1153
+ - ``basis`` -- either ``None`` (default) or a function such that
1154
+ ``basis(d)`` is a basis of the weight ``d`` multiple zeta values.
1155
+ If ``None``, the Hoffman basis is used.
1156
+
1157
+ EXAMPLES::
1158
+
1159
+ sage: z = Multizeta(5) + Multizeta(1,4) + Multizeta(3,2) - 5 * Multizeta(2,3)
1160
+ sage: z.simplify_full()
1161
+ -22/5*ζ(2,3) + 12/5*ζ(3,2)
1162
+ sage: z.simplify_full(basis=z.parent().basis_filtration)
1163
+ 18*ζ(1,4) - ζ(5)
1164
+
1165
+ sage: z == z.simplify_full() == z.simplify_full(basis=z.parent().basis_filtration)
1166
+ True
1167
+
1168
+ Be careful, that this does not optimize the number of terms::
1169
+
1170
+ sage: Multizeta(7).simplify_full()
1171
+ 352/151*ζ(2,2,3) + 672/151*ζ(2,3,2) + 528/151*ζ(3,2,2)
1172
+
1173
+ TESTS::
1174
+
1175
+ sage: Multizetas(QQ).one().simplify_full()
1176
+ ζ()
1177
+ """
1178
+ if basis is None:
1179
+ basis = self.parent().basis_brown
1180
+ support = {sum(d) for d in self.support()}
1181
+ result = self.parent().zero()
1182
+ for d in sorted(support):
1183
+ h = self.homogeneous_component(d)
1184
+ v = h.phi_as_vector()
1185
+ if v:
1186
+ Bd = basis(d)
1187
+ P = matrix(QQ, [z.phi_as_vector() for z in Bd])
1188
+ result += sum(x * z for x, z in zip(P.solve_left(v), Bd))
1189
+ return result
1190
+
1191
+ def __bool__(self) -> bool:
1192
+ r"""
1193
+ EXAMPLES::
1194
+
1195
+ sage: bool(Multizeta(2))
1196
+ True
1197
+ sage: bool(3*Multizeta(4) - 4*Multizeta(2,2))
1198
+ False
1199
+ """
1200
+ return bool(self.iterated())
1201
+
1202
+ def is_zero(self) -> bool:
1203
+ r"""
1204
+ Return whether this element is zero.
1205
+
1206
+ EXAMPLES::
1207
+
1208
+ sage: M = Multizeta
1209
+
1210
+ sage: (4*M(2,3) + 6*M(3,2) - 5*M(5)).is_zero()
1211
+ True
1212
+ sage: (3*M(4) - 4*M(2,2)).is_zero()
1213
+ True
1214
+ sage: (4*M(2,3) + 6*M(3,2) + 3*M(4) - 5*M(5) - 4*M(2,2)).is_zero()
1215
+ True
1216
+
1217
+ sage: (4*M(2,3) + 6*M(3,2) - 4*M(5)).is_zero()
1218
+ False
1219
+ sage: (M(4) - M(2,2)).is_zero()
1220
+ False
1221
+ sage: (4*M(2,3) + 6*M(3,2) + 3*M(4) - 4*M(5) - 4*M(2,2)).is_zero()
1222
+ False
1223
+ """
1224
+ return not self
1225
+
1226
+ def _richcmp_(self, other, op) -> bool:
1227
+ """
1228
+ Comparison.
1229
+
1230
+ This means equality as motivic multiple zeta value, computed
1231
+ using the morphism ``phi``.
1232
+
1233
+ EXAMPLES::
1234
+
1235
+ sage: M = Multizeta
1236
+ sage: 4*M(1,3) == M(4)
1237
+ True
1238
+ sage: our_pi2 = 6*M(2)
1239
+ sage: Multizeta(2,2,2) == our_pi2**3 / 7.factorial()
1240
+ True
1241
+
1242
+ sage: M(2,2,2) != M(6)
1243
+ True
1244
+
1245
+ sage: M(4) == M(66) + M(33,33)
1246
+ False
1247
+ sage: M(33) + M(22,11) == M(3)
1248
+ False
1249
+ sage: M(5) == 1
1250
+ False
1251
+ sage: M() == 1
1252
+ True
1253
+ sage: (0*M()) == 0
1254
+ True
1255
+ """
1256
+ if op not in [op_EQ, op_NE]:
1257
+ raise TypeError('invalid comparison for multizetas')
1258
+ return self.iterated()._richcmp_(other.iterated(), op)
1259
+
1260
+ def __hash__(self) -> int:
1261
+ """
1262
+ Return the hash of ``self``.
1263
+
1264
+ EXAMPLES::
1265
+
1266
+ sage: M = Multizeta
1267
+ sage: hash(M(1,2)) != hash(M(6))
1268
+ True
1269
+ """
1270
+ return hash(self.iterated().phi())
1271
+
1272
+ def phi(self):
1273
+ """
1274
+ Return the image of ``self`` by the morphism ``phi``.
1275
+
1276
+ This sends multiple zeta values to the auxiliary F-algebra.
1277
+
1278
+ EXAMPLES::
1279
+
1280
+ sage: M = Multizetas(QQ)
1281
+ sage: M((1,2)).phi()
1282
+ f3
1283
+
1284
+ TESTS::
1285
+
1286
+ sage: A = QQ['u']
1287
+ sage: u = A.gen()
1288
+ sage: M = Multizetas(A)
1289
+ sage: tst = u*M((1,2))+M((3,))
1290
+ sage: tst.phi()
1291
+ (u+1)*f3
1292
+ """
1293
+ return self.parent().phi(self)
1294
+
1295
+ def phi_as_vector(self):
1296
+ """
1297
+ Return the image of ``self`` by the morphism ``phi`` as a vector.
1298
+
1299
+ The morphism ``phi`` sends multiple zeta values to the algebra
1300
+ :func:`F_ring`. Then the image is expressed as a vector in
1301
+ a fixed basis of one graded component of this algebra.
1302
+
1303
+ This is only defined for homogeneous elements.
1304
+
1305
+ EXAMPLES::
1306
+
1307
+ sage: M = Multizetas(QQ)
1308
+ sage: M((3,2)).phi_as_vector()
1309
+ (9/2, -2)
1310
+ sage: M(0).phi_as_vector()
1311
+ ()
1312
+
1313
+ TESTS::
1314
+
1315
+ sage: (M((4,))+M((1,2))).phi_as_vector()
1316
+ Traceback (most recent call last):
1317
+ ...
1318
+ ValueError: only defined for homogeneous elements
1319
+ """
1320
+ if not self.is_homogeneous():
1321
+ raise ValueError('only defined for homogeneous elements')
1322
+ return self.parent().phi(self).homogeneous_to_vector()
1323
+
1324
+ def _numerical_approx_pari(self):
1325
+ r"""
1326
+ The numerical values of individual multiple zeta are obtained via
1327
+ the class :class:`MultizetaValues` that performs some caching.
1328
+
1329
+ TESTS::
1330
+
1331
+ sage: M = Multizetas(QQ)
1332
+ sage: a = M((3,2)) - 2*M((7,))
1333
+ sage: a._numerical_approx_pari()
1334
+ -1.30513235721327
1335
+ sage: type(a._numerical_approx_pari())
1336
+ <class 'cypari2.gen.Gen'>
1337
+ """
1338
+ return sum(cf * Values.pari_eval(tuple(w)) for w, cf in self.monomial_coefficients().items())
1339
+
1340
+ def numerical_approx(self, prec=None, digits=None, algorithm=None):
1341
+ """
1342
+ Return a numerical value for this element.
1343
+
1344
+ EXAMPLES::
1345
+
1346
+ sage: M = Multizetas(QQ)
1347
+ sage: M(Word((3,2))).n() # indirect doctest
1348
+ 0.711566197550572
1349
+ sage: parent(M(Word((3,2))).n())
1350
+ Real Field with 53 bits of precision
1351
+
1352
+ sage: (M((3,)) * M((2,))).n(prec=80)
1353
+ 1.9773043502972961181971
1354
+ sage: M((1,2)).n(70)
1355
+ 1.2020569031595942854
1356
+
1357
+ sage: M((3,)).n(digits=10)
1358
+ 1.202056903
1359
+
1360
+ If you plan to use intensively numerical approximation at high precision,
1361
+ you might want to add more values and/or accuracy to the cache::
1362
+
1363
+ sage: from sage.modular.multiple_zeta import MultizetaValues
1364
+ sage: M = MultizetaValues()
1365
+ sage: M.update(max_weight=9, prec=2048)
1366
+ sage: M
1367
+ Cached multiple zeta values at precision 2048 up to weight 9
1368
+ sage: M.reset() # restore precision for the other doctests
1369
+
1370
+ TESTS::
1371
+
1372
+ sage: Multizetas(QQ).zero().n()
1373
+ 0.000000000000000
1374
+ """
1375
+ if prec is None:
1376
+ if digits:
1377
+ from sage.arith.numerical_approx import digits_to_bits
1378
+ prec = digits_to_bits(digits)
1379
+ else:
1380
+ prec = 53
1381
+ if algorithm is not None:
1382
+ raise ValueError("unknown algorithm")
1383
+ if not self.monomial_coefficients():
1384
+ return ZZ(0).n(prec=prec, digits=digits, algorithm=algorithm)
1385
+ if prec < Values.prec:
1386
+ s = sum(cf * Values(tuple(w)) for w, cf in self.monomial_coefficients().items())
1387
+ return s.n(prec=prec)
1388
+ return sum(cf * Values(tuple(w), prec=prec) for w, cf in self.monomial_coefficients().items())
1389
+
1390
+
1391
+ class Multizetas_iterated(CombinatorialFreeModule):
1392
+ r"""
1393
+ Secondary class for the algebra of multiple zeta values.
1394
+
1395
+ This is used to represent multiple zeta values as iterated integrals
1396
+ of the differential forms `\omega_0 = dt/t` and `\omega_1 = dt/(t-1)`.
1397
+
1398
+ EXAMPLES::
1399
+
1400
+ sage: from sage.modular.multiple_zeta import Multizetas_iterated
1401
+ sage: M = Multizetas_iterated(QQ); M
1402
+ Algebra of motivic multiple zeta values as convergent iterated
1403
+ integrals over Rational Field
1404
+ sage: M((1,0))
1405
+ I(10)
1406
+ sage: M((1,0))**2
1407
+ 4*I(1100) + 2*I(1010)
1408
+ sage: M((1,0))*M((1,0,0))
1409
+ 6*I(11000) + 3*I(10100) + I(10010)
1410
+ """
1411
+ def __init__(self, R) -> None:
1412
+ """
1413
+ TESTS::
1414
+
1415
+ sage: from sage.modular.multiple_zeta import Multizetas_iterated
1416
+ sage: M = Multizetas_iterated(QQ)
1417
+ sage: TestSuite(M).run() # not tested
1418
+ sage: M.category()
1419
+ Category of commutative no zero divisors graded algebras
1420
+ with basis over Rational Field
1421
+ """
1422
+ if R not in Rings():
1423
+ raise TypeError("argument R must be a ring")
1424
+ cat = GradedAlgebrasWithBasis(R).Commutative()
1425
+ if R in Domains():
1426
+ cat = cat & Domains()
1427
+ CombinatorialFreeModule.__init__(self, R, Words10, prefix='I',
1428
+ category=cat)
1429
+
1430
+ def _repr_(self) -> str:
1431
+ """
1432
+ Return a string representation for the ring.
1433
+
1434
+ EXAMPLES::
1435
+
1436
+ sage: from sage.modular.multiple_zeta import Multizetas_iterated
1437
+ sage: M = Multizetas_iterated(QQ); M
1438
+ Algebra of motivic multiple zeta values
1439
+ as convergent iterated integrals over Rational Field
1440
+ """
1441
+ return f"Algebra of motivic multiple zeta values as convergent iterated integrals over {self.base_ring()}"
1442
+
1443
+ def _repr_term(self, m) -> str:
1444
+ """
1445
+ Return a custom string representation for the monomials.
1446
+
1447
+ EXAMPLES::
1448
+
1449
+ sage: Multizeta(1,0,1,0) # indirect doctest
1450
+ I(1010)
1451
+ """
1452
+ return "I(" + ''.join(str(letter) for letter in m) + ")"
1453
+
1454
+ @cached_method
1455
+ def one_basis(self):
1456
+ r"""
1457
+ Return the index of the unit for the algebra.
1458
+
1459
+ This is the empty word.
1460
+
1461
+ EXAMPLES::
1462
+
1463
+ sage: from sage.modular.multiple_zeta import Multizetas_iterated
1464
+ sage: M = Multizetas_iterated(QQ)
1465
+ sage: M.one_basis()
1466
+ word:
1467
+ """
1468
+ return self.basis().keys()([], check=False)
1469
+
1470
+ def product_on_basis(self, w1, w2):
1471
+ r"""
1472
+ Compute the product of two monomials.
1473
+
1474
+ This is the shuffle product.
1475
+
1476
+ INPUT:
1477
+
1478
+ - ``w1``, ``w2`` -- words in 0 and 1
1479
+
1480
+ EXAMPLES::
1481
+
1482
+ sage: from sage.modular.multiple_zeta import Multizetas_iterated
1483
+ sage: M = Multizetas_iterated(QQ)
1484
+ sage: x = Word([1,0])
1485
+ sage: M.product_on_basis(x,x)
1486
+ 4*I(1100) + 2*I(1010)
1487
+ sage: y = Word([1,1,0])
1488
+ sage: M.product_on_basis(y,x)
1489
+ I(10110) + 3*I(11010) + 6*I(11100)
1490
+ """
1491
+ return self._sum_of_monomials(shuffle(w1, w2, False))
1492
+
1493
+ def half_product_on_basis(self, w1, w2):
1494
+ r"""
1495
+ Compute half of the product of two monomials.
1496
+
1497
+ This is half of the shuffle product.
1498
+
1499
+ .. WARNING:: This is not a motivic operation.
1500
+
1501
+ INPUT:
1502
+
1503
+ - ``w1``, ``w2`` -- monomials
1504
+
1505
+ EXAMPLES::
1506
+
1507
+ sage: from sage.modular.multiple_zeta import Multizetas_iterated
1508
+ sage: M = Multizetas_iterated(QQ)
1509
+ sage: x = Word([1,0])
1510
+ sage: M.half_product_on_basis(x,x)
1511
+ 2*I(1100) + I(1010)
1512
+ """
1513
+ assert w1
1514
+ W = self.basis().keys()
1515
+ u1 = W([w1[0]], check=False)
1516
+ r1 = w1[1:]
1517
+ B = self.basis()
1518
+ return sum(B[u1 + u] for u in shuffle(r1, w2, False))
1519
+
1520
+ @lazy_attribute
1521
+ def half_product(self):
1522
+ r"""
1523
+ Compute half of the product of two elements.
1524
+
1525
+ This is half of the shuffle product.
1526
+
1527
+ .. WARNING:: This is not a motivic operation.
1528
+
1529
+ INPUT:
1530
+
1531
+ - ``w1``, ``w2`` -- elements
1532
+
1533
+ EXAMPLES::
1534
+
1535
+ sage: from sage.modular.multiple_zeta import Multizetas_iterated
1536
+ sage: M = Multizetas_iterated(QQ)
1537
+ sage: x = M(Word([1,0]))
1538
+ sage: M.half_product(x,x)
1539
+ 2*I(1100) + I(1010)
1540
+ """
1541
+ half = self.half_product_on_basis
1542
+ return self._module_morphism(self._module_morphism(half, position=0,
1543
+ codomain=self),
1544
+ position=1)
1545
+
1546
+ def coproduct_on_basis(self, w):
1547
+ """
1548
+ Return the motivic coproduct of a monomial.
1549
+
1550
+ EXAMPLES::
1551
+
1552
+ sage: from sage.modular.multiple_zeta import Multizetas_iterated
1553
+ sage: M = Multizetas_iterated(QQ)
1554
+ sage: M.coproduct_on_basis([1,0])
1555
+ I() # I(10)
1556
+
1557
+ sage: M.coproduct_on_basis((1,0,1,0))
1558
+ I() # I(1010)
1559
+ """
1560
+ seq = [0] + list(w) + [1]
1561
+ terms = coproduct_iterator(([0], seq))
1562
+ M_all = All_iterated(self.base_ring())
1563
+
1564
+ def split_word(indices):
1565
+ L = self.one()
1566
+ for i in range(len(indices) - 1):
1567
+ w = Word(seq[indices[i]:indices[i + 1] + 1])
1568
+ if len(w) == 2: # this factor is one
1569
+ continue
1570
+ if len(w) <= 4 or len(w) == 6 or w[0] == w[-1]:
1571
+ # vanishing factors
1572
+ return self.zero()
1573
+ value = M_all(w)
1574
+ L *= value.regularise().simplify()
1575
+ return L
1576
+
1577
+ resu = self.tensor_square().zero()
1578
+ for indices in terms:
1579
+ resu += split_word(indices).tensor(
1580
+ M_all(Word(seq[i] for i in indices)).regularise().simplify())
1581
+ return resu
1582
+
1583
+ @lazy_attribute
1584
+ def coproduct(self):
1585
+ """
1586
+ Return the motivic coproduct of an element.
1587
+
1588
+ EXAMPLES::
1589
+
1590
+ sage: from sage.modular.multiple_zeta import Multizetas_iterated
1591
+ sage: M = Multizetas_iterated(QQ)
1592
+ sage: a = 3*Multizeta(1,4) + Multizeta(2,3)
1593
+ sage: M.coproduct(a.iterated())
1594
+ 3*I() # I(11000) + I() # I(10100) + 3*I(11000) # I()
1595
+ + I(10100) # I()
1596
+ """
1597
+ cop = self.coproduct_on_basis
1598
+ return self._module_morphism(cop, codomain=self.tensor_square())
1599
+
1600
+ @lazy_attribute
1601
+ def composition(self):
1602
+ """
1603
+ Convert to the algebra of multiple zeta values of composition style.
1604
+
1605
+ This means the algebra :class:`Multizetas`.
1606
+
1607
+ This is also available as a method of elements.
1608
+
1609
+ EXAMPLES::
1610
+
1611
+ sage: from sage.modular.multiple_zeta import Multizetas_iterated
1612
+ sage: M = Multizetas_iterated(QQ)
1613
+ sage: x = M((1,0))
1614
+ sage: M.composition(2*x)
1615
+ -2*ζ(2)
1616
+ sage: x = M((1,0,1,0,0))
1617
+ sage: M.composition(x)
1618
+ ζ(2,3)
1619
+ """
1620
+ cod = Multizetas(self.base_ring())
1621
+ return self.module_morphism(self.composition_on_basis, codomain=cod)
1622
+
1623
+ def composition_on_basis(self, w, basering=None):
1624
+ """
1625
+ Convert to the algebra of multiple zeta values of composition style.
1626
+
1627
+ INPUT:
1628
+
1629
+ - ``basering`` -- (optional) choice of the coefficient ring
1630
+
1631
+ EXAMPLES::
1632
+
1633
+ sage: from sage.modular.multiple_zeta import Multizetas_iterated
1634
+ sage: M = Multizetas_iterated(QQ)
1635
+ sage: x = Word((1,0,1,0,0))
1636
+ sage: M.composition_on_basis(x)
1637
+ ζ(2,3)
1638
+ sage: x = Word((1,0,1,0,0,1,0))
1639
+ sage: M.composition_on_basis(x)
1640
+ -ζ(2,3,2)
1641
+ """
1642
+ if basering is None:
1643
+ basering = self.base_ring()
1644
+ codomain = Multizetas(basering)
1645
+ return (-1)**w.count(1) * codomain(iterated_to_composition(w))
1646
+
1647
+ def dual_on_basis(self, w):
1648
+ """
1649
+ Return the order of the word and exchange letters 0 and 1.
1650
+
1651
+ This is an involution.
1652
+
1653
+ INPUT:
1654
+
1655
+ - ``w`` -- a word in 0 and 1
1656
+
1657
+ EXAMPLES::
1658
+
1659
+ sage: from sage.modular.multiple_zeta import Multizetas_iterated
1660
+ sage: M = Multizetas_iterated(QQ)
1661
+ sage: x = Word((1,0,1,0,0))
1662
+ sage: M.dual_on_basis(x)
1663
+ -I(11010)
1664
+ """
1665
+ rev = [1 - x for x in reversed(w)]
1666
+ image = self._monomial(self.basis().keys()(rev, check=False))
1667
+ return -image if len(w) % 2 else image
1668
+
1669
+ def degree_on_basis(self, w):
1670
+ """
1671
+ Return the degree of the monomial ``w``.
1672
+
1673
+ This is the length of the word.
1674
+
1675
+ INPUT:
1676
+
1677
+ - ``w`` -- a word in 0 and 1
1678
+
1679
+ EXAMPLES::
1680
+
1681
+ sage: from sage.modular.multiple_zeta import Multizetas_iterated
1682
+ sage: M = Multizetas_iterated(QQ)
1683
+ sage: x = Word((1,0,1,0,0))
1684
+ sage: M.degree_on_basis(x)
1685
+ 5
1686
+ """
1687
+ return ZZ(len(w))
1688
+
1689
+ def D_on_basis(self, k, w):
1690
+ """
1691
+ Return the action of the operator `D_k` on the monomial ``w``.
1692
+
1693
+ This is one main tool in the procedure that allows
1694
+ to map the algebra of multiple zeta values to
1695
+ the F Ring.
1696
+
1697
+ INPUT:
1698
+
1699
+ - ``k`` -- an odd integer, at least 3
1700
+
1701
+ - ``w`` -- a word in 0 and 1
1702
+
1703
+ EXAMPLES::
1704
+
1705
+ sage: from sage.modular.multiple_zeta import Multizetas_iterated
1706
+ sage: M = Multizetas_iterated(QQ)
1707
+ sage: M.D_on_basis(3,(1,1,1,0,0))
1708
+ I(110) # I(10) + 2*I(100) # I(10)
1709
+
1710
+ sage: M.D_on_basis(3,(1,0,1,0,0))
1711
+ 3*I(100) # I(10)
1712
+ sage: M.D_on_basis(5,(1,0,0,0,1,0,0,1,0,0))
1713
+ 10*I(10000) # I(10100)
1714
+ """
1715
+ Im = All_iterated(self.base_ring())
1716
+ MZV_MZV = self.tensor_square()
1717
+ N = len(w)
1718
+ it = [0] + list(w) + [1]
1719
+ coprod = MZV_MZV.zero()
1720
+ for p in range(N + 1 - k):
1721
+ left = Im(it[p: p + k + 2])
1722
+ right = Im(it[:p + 1] + it[p + k + 1:])
1723
+ if left and right:
1724
+ coprod += left.regularise().tensor(right.regularise())
1725
+ return coprod
1726
+
1727
+ def D(self, k):
1728
+ """
1729
+ Return the operator `D_k`.
1730
+
1731
+ INPUT:
1732
+
1733
+ - ``k`` -- an odd integer, at least 3
1734
+
1735
+ EXAMPLES::
1736
+
1737
+ sage: from sage.modular.multiple_zeta import Multizetas_iterated
1738
+ sage: M = Multizetas_iterated(QQ)
1739
+ sage: D3 = M.D(3)
1740
+ sage: elt = M((1,0,1,0,0)) + 2 * M((1,1,0,0,1,0))
1741
+ sage: D3(elt)
1742
+ -6*I(100) # I(110) + 3*I(100) # I(10)
1743
+ """
1744
+ def map_on_basis(elt):
1745
+ return self.D_on_basis(k, elt)
1746
+ cod = Multizetas_iterated(self.base_ring()).tensor_square()
1747
+ return self.module_morphism(map_on_basis, position=0,
1748
+ codomain=cod)
1749
+
1750
+ @cached_method
1751
+ def phi_extended(self, w):
1752
+ r"""
1753
+ Return the image of the monomial ``w`` by the morphism ``phi``.
1754
+
1755
+ INPUT:
1756
+
1757
+ - ``w`` -- a word in 0 and 1
1758
+
1759
+ OUTPUT: an element in the auxiliary F-algebra
1760
+
1761
+ The coefficients are in the base ring.
1762
+
1763
+ EXAMPLES::
1764
+
1765
+ sage: from sage.modular.multiple_zeta import Multizetas_iterated
1766
+ sage: M = Multizetas_iterated(QQ)
1767
+ sage: M.phi_extended((1,0))
1768
+ -f2
1769
+ sage: M.phi_extended((1,0,0))
1770
+ -f3
1771
+ sage: M.phi_extended((1,1,0))
1772
+ f3
1773
+ sage: M.phi_extended((1,0,1,0,0))
1774
+ -11/2*f5 + 3*f2*f3
1775
+
1776
+ More complicated examples::
1777
+
1778
+ sage: from sage.modular.multiple_zeta import composition_to_iterated
1779
+ sage: M.phi_extended(composition_to_iterated((4,3)))
1780
+ -18*f7 + 10*f2*f5 + 2/5*f2^2*f3
1781
+
1782
+ sage: M.phi_extended(composition_to_iterated((3,4)))
1783
+ 17*f7 - 10*f2*f5
1784
+
1785
+ sage: M.phi_extended(composition_to_iterated((4,2)))
1786
+ -2*f3f3 + 10/21*f2^3
1787
+ sage: M.phi_extended(composition_to_iterated((3,5)))
1788
+ -5*f5f3
1789
+ sage: M.phi_extended(composition_to_iterated((3,7)))
1790
+ -6*f5f5 - 14*f7f3
1791
+
1792
+ sage: M.phi_extended(composition_to_iterated((3,3,2)))
1793
+ 9*f3f5 - 9/2*f5f3 - 4*f2*f3f3 - 793/875*f2^4
1794
+
1795
+ TESTS::
1796
+
1797
+ sage: M.phi_extended(tuple())
1798
+ 1
1799
+ """
1800
+ # this is now hardcoded
1801
+ # prec = 1024
1802
+ F = F_algebra(self.base_ring())
1803
+ f = F.gen
1804
+ if not w:
1805
+ return F.one()
1806
+ N = len(w)
1807
+ compo = tuple(iterated_to_composition(w))
1808
+ if compo in B_data[N]:
1809
+ # do not forget the sign
1810
+ return (-1)**len(compo) * phi_on_multiplicative_basis(compo)
1811
+ u = compute_u_on_basis(w)
1812
+ rho_inverse_u = rho_inverse(u)
1813
+ xi = self.composition_on_basis(w, QQ)
1814
+ c_xi = (xi - rho_inverse_u)._numerical_approx_pari()
1815
+ c_xi /= Multizeta(N)._numerical_approx_pari()
1816
+ c_xi = c_xi.bestappr().sage() # in QQ
1817
+ return u + c_xi * f(N)
1818
+
1819
+ @lazy_attribute
1820
+ def phi(self):
1821
+ """
1822
+ Return the morphism ``phi``.
1823
+
1824
+ This sends multiple zeta values to the auxiliary F-algebra.
1825
+
1826
+ EXAMPLES::
1827
+
1828
+ sage: from sage.modular.multiple_zeta import Multizetas_iterated
1829
+ sage: M = Multizetas_iterated(QQ)
1830
+ sage: m = Multizeta(1,0,1,0) + 2*Multizeta(1,1,0,0); m
1831
+ 2*I(1100) + I(1010)
1832
+ sage: M.phi(m)
1833
+ 1/2*f2^2
1834
+
1835
+ sage: Z = Multizeta
1836
+ sage: B5 = [3*Z(1,4) + 2*Z(2,3) + Z(3,2), 3*Z(1,4) + Z(2,3)]
1837
+ sage: [M.phi(b.iterated()) for b in B5]
1838
+ [-1/2*f5 + f2*f3, 1/2*f5]
1839
+
1840
+ sage: B6 = [6*Z(1,5) + 3*Z(2,4) + Z(3,3),
1841
+ ....: 6*Z(1,1,4) + 4*Z(1,2,3) + 2*Z(1,3,2) + 2*Z(2,1,3) + Z(2,2,2)]
1842
+ sage: [M.phi(b.iterated()) for b in B6]
1843
+ [f3f3, 1/6*f2^3]
1844
+ """
1845
+ cod = F_algebra(self.base_ring())
1846
+ return self.module_morphism(self.phi_extended, codomain=cod)
1847
+
1848
+ def _element_constructor_(self, x):
1849
+ r"""
1850
+ Convert ``x`` into ``self``.
1851
+
1852
+ INPUT:
1853
+
1854
+ - ``x`` -- either a list, tuple, word or a multiple zeta value
1855
+
1856
+ EXAMPLES::
1857
+
1858
+ sage: from sage.modular.multiple_zeta import Multizetas_iterated
1859
+ sage: M = Multizetas_iterated(QQ)
1860
+ sage: x = Word((1,0,1,0,0))
1861
+ sage: M(x)
1862
+ I(10100)
1863
+ sage: y = M((1,1,0,0)); y
1864
+ I(1100)
1865
+ sage: y == M(y)
1866
+ True
1867
+ """
1868
+ if isinstance(x, (str, (FiniteWord_class, tuple, list))):
1869
+ if x:
1870
+ assert all(letter in (0, 1) for letter in x), 'bad letter'
1871
+ assert x[0] == 1, 'bad first letter, should be 1'
1872
+ assert x[-1] == 0, 'bad last letter, should be 0'
1873
+ W = self.basis().keys()
1874
+ if isinstance(x, list):
1875
+ x = tuple(x)
1876
+ return self._monomial(W(x, check=False))
1877
+
1878
+ P = x.parent()
1879
+ if isinstance(P, Multizetas_iterated):
1880
+ if P is self:
1881
+ return x
1882
+ if P is not self.base_ring():
1883
+ return self.element_class(self, x.monomial_coefficients())
1884
+ elif isinstance(P, Multizetas):
1885
+ return x.iterated()
1886
+
1887
+ R = self.base_ring()
1888
+ # coercion via base ring
1889
+ x = R(x)
1890
+ if x == 0:
1891
+ return self.element_class(self, {})
1892
+ return self.from_base_ring_from_one_basis(x)
1893
+
1894
+ class Element(CombinatorialFreeModule.Element):
1895
+ def simplify(self):
1896
+ """
1897
+ Gather terms using the duality relations.
1898
+
1899
+ This can help to lower the number of monomials.
1900
+
1901
+ EXAMPLES::
1902
+
1903
+ sage: from sage.modular.multiple_zeta import Multizetas_iterated
1904
+ sage: M = Multizetas_iterated(QQ)
1905
+ sage: z = 4*M((1,0,0)) + 3*M((1,1,0))
1906
+ sage: z.simplify()
1907
+ I(100)
1908
+ """
1909
+ summing = self.parent().sum_of_terms
1910
+ return summing(minimize_term(w, cf)
1911
+ for w, cf in self.monomial_coefficients().items())
1912
+
1913
+ def coproduct(self):
1914
+ """
1915
+ Return the coproduct of ``self``.
1916
+
1917
+ EXAMPLES::
1918
+
1919
+ sage: from sage.modular.multiple_zeta import Multizetas_iterated
1920
+ sage: M = Multizetas_iterated(QQ)
1921
+ sage: a = 3*Multizeta(1,3) + Multizeta(2,3)
1922
+ sage: a.iterated().coproduct()
1923
+ 3*I() # I(1100) + I() # I(10100) + I(10100) # I() + 3*I(100) # I(10)
1924
+ """
1925
+ return self.parent().coproduct(self)
1926
+
1927
+ def composition(self):
1928
+ """
1929
+ Convert to the algebra of multiple zeta values of composition style.
1930
+
1931
+ This means the algebra :class:`Multizetas`.
1932
+
1933
+ EXAMPLES::
1934
+
1935
+ sage: from sage.modular.multiple_zeta import Multizetas_iterated
1936
+ sage: M = Multizetas_iterated(QQ)
1937
+ sage: x = M((1,0,1,0))
1938
+ sage: x.composition()
1939
+ ζ(2,2)
1940
+ sage: x = M((1,0,1,0,0))
1941
+ sage: x.composition()
1942
+ ζ(2,3)
1943
+ sage: x = M((1,0,1,0,0,1,0))
1944
+ sage: x.composition()
1945
+ -ζ(2,3,2)
1946
+ """
1947
+ return self.parent().composition(self)
1948
+
1949
+ def numerical_approx(self, prec=None, digits=None, algorithm=None):
1950
+ """
1951
+ Return a numerical approximation as a sage real.
1952
+
1953
+ EXAMPLES::
1954
+
1955
+ sage: from sage.modular.multiple_zeta import Multizetas_iterated
1956
+ sage: M = Multizetas_iterated(QQ)
1957
+ sage: x = M((1,0,1,0))
1958
+ sage: y = M((1, 0, 0))
1959
+ sage: (3*x+y).n() # indirect doctest
1960
+ 1.23317037269047
1961
+ """
1962
+ return self.composition().numerical_approx(prec=prec, digits=digits, algorithm=algorithm)
1963
+
1964
+ def phi(self):
1965
+ """
1966
+ Return the image of ``self`` by the morphism ``phi``.
1967
+
1968
+ This sends multiple zeta values to the auxiliary F-algebra.
1969
+
1970
+ EXAMPLES::
1971
+
1972
+ sage: from sage.modular.multiple_zeta import Multizetas_iterated
1973
+ sage: M = Multizetas_iterated(QQ)
1974
+ sage: M((1,1,0)).phi()
1975
+ f3
1976
+ """
1977
+ return self.parent().phi(self)
1978
+
1979
+ def __bool__(self) -> bool:
1980
+ r"""
1981
+ TESTS::
1982
+
1983
+ sage: from sage.modular.multiple_zeta import Multizetas_iterated
1984
+ sage: M = Multizetas_iterated(QQ)
1985
+ sage: bool(M(0))
1986
+ False
1987
+ sage: bool(M(1))
1988
+ True
1989
+ sage: bool(M((1,0,0)))
1990
+ True
1991
+ """
1992
+ P = self.parent()
1993
+ deg = P.degree_on_basis
1994
+ phi = P.phi
1995
+ for d in sorted({deg(w) for w in self.support()}):
1996
+ z = self.homogeneous_component(d)
1997
+ if not phi(z).is_zero():
1998
+ return True
1999
+ return False
2000
+
2001
+ def is_zero(self) -> bool:
2002
+ r"""
2003
+ Return whether this element is zero.
2004
+
2005
+ EXAMPLES::
2006
+
2007
+ sage: from sage.modular.multiple_zeta import Multizetas_iterated
2008
+ sage: M = Multizetas_iterated(QQ)
2009
+ sage: M(0).is_zero()
2010
+ True
2011
+ sage: M(1).is_zero()
2012
+ False
2013
+ sage: (M((1,1,0)) - -M((1,0,0))).is_zero()
2014
+ True
2015
+ """
2016
+ return not self
2017
+
2018
+ def _richcmp_(self, other, op) -> bool:
2019
+ """
2020
+ Test for equality.
2021
+
2022
+ This means equality as motivic multiple zeta value, computed
2023
+ using the morphism ``phi``.
2024
+
2025
+ EXAMPLES::
2026
+
2027
+ sage: from sage.modular.multiple_zeta import Multizetas_iterated
2028
+ sage: M = Multizetas_iterated(QQ)
2029
+ sage: M((1,1,0)) == -M((1,0,0))
2030
+ True
2031
+
2032
+ sage: M = Multizetas(QQ)
2033
+ sage: a = 28*M((3,9))+150*M((5,7))+168*M((7,5))
2034
+ sage: b = 5197/691*M((12,))
2035
+ sage: a.iterated() == b.iterated() # not tested, long time (20s)
2036
+ True
2037
+ """
2038
+ if op not in [op_EQ, op_NE]:
2039
+ raise TypeError('invalid comparison for multizetas')
2040
+ return (self - other).is_zero() == (op == op_EQ)
2041
+
2042
+
2043
+ class All_iterated(CombinatorialFreeModule):
2044
+ r"""
2045
+ Auxiliary class for multiple zeta value as generalized iterated integrals.
2046
+
2047
+ This is used to represent multiple zeta values as possibly
2048
+ divergent iterated integrals
2049
+ of the differential forms `\omega_0 = dt/t` and `\omega_1 = dt/(t-1)`.
2050
+
2051
+ This means that the elements are symbols
2052
+ `I(a_0 ; a_1,a_2,...a_n ; a_{n+1})`
2053
+ where all arguments, including the starting and ending points
2054
+ can be 0 or 1.
2055
+
2056
+ This comes with a "regularise" method mapping
2057
+ to :class:`Multizetas_iterated`.
2058
+
2059
+ EXAMPLES::
2060
+
2061
+ sage: from sage.modular.multiple_zeta import All_iterated
2062
+ sage: M = All_iterated(QQ); M
2063
+ Space of motivic multiple zeta values as general iterated integrals
2064
+ over Rational Field
2065
+ sage: M((0,1,0,1))
2066
+ I(0;10;1)
2067
+ sage: x = M((1,1,0,0)); x
2068
+ I(1;10;0)
2069
+ sage: x.regularise()
2070
+ -I(10)
2071
+ """
2072
+ def __init__(self, R) -> None:
2073
+ """
2074
+ TESTS::
2075
+
2076
+ sage: from sage.modular.multiple_zeta import All_iterated
2077
+ sage: M = All_iterated(QQ)
2078
+ sage: TestSuite(M).run() # not tested
2079
+ """
2080
+ if R not in Rings():
2081
+ raise TypeError("argument R must be a ring")
2082
+ CombinatorialFreeModule.__init__(self, R, Words10, prefix='I')
2083
+
2084
+ def _repr_(self) -> str:
2085
+ """
2086
+ Return a string representation of the module.
2087
+
2088
+ EXAMPLES::
2089
+
2090
+ sage: from sage.modular.multiple_zeta import All_iterated
2091
+ sage: M = All_iterated(QQ); M
2092
+ Space of motivic multiple zeta values as general iterated integrals over Rational Field
2093
+ """
2094
+ txt = "Space of motivic multiple zeta values as general iterated integrals over {}"
2095
+ return txt.format(self.base_ring())
2096
+
2097
+ def _repr_term(self, m) -> str:
2098
+ """
2099
+ Return a custom string representation for the monomials.
2100
+
2101
+ EXAMPLES::
2102
+
2103
+ sage: from sage.modular.multiple_zeta import All_iterated
2104
+ sage: M = All_iterated(QQ)
2105
+ sage: x = Word((1,0,1,0,0))
2106
+ sage: M(x) # indirect doctest
2107
+ I(1;010;0)
2108
+ """
2109
+ start = str(m[0])
2110
+ end = str(m[-1])
2111
+ mid = ''.join(str(letter) for letter in m[1:-1])
2112
+ return "I(" + start + ";" + mid + ";" + end + ")"
2113
+
2114
+ def _element_constructor_(self, x):
2115
+ r"""
2116
+ Convert ``x`` into ``self``.
2117
+
2118
+ INPUT:
2119
+
2120
+ - ``x`` -- either a list, tuple, word
2121
+
2122
+ EXAMPLES::
2123
+
2124
+ sage: from sage.modular.multiple_zeta import All_iterated
2125
+ sage: M = All_iterated(QQ)
2126
+ sage: y = M((1,1,0,0)); y
2127
+ I(1;10;0)
2128
+ sage: y == M(y)
2129
+ True
2130
+
2131
+ sage: M((1,0,1,0,1))
2132
+ 0
2133
+ sage: M((1,0,0,0,0))
2134
+ 0
2135
+ """
2136
+ if not isinstance(x, (FiniteWord_class, tuple, list)):
2137
+ raise TypeError('invalid input for building iterated integral')
2138
+ if not x:
2139
+ return self.zero()
2140
+ if any(letter not in (0, 1) for letter in x):
2141
+ raise ValueError('bad letter')
2142
+
2143
+ W = self.basis().keys()
2144
+ w = W(x, check=False)
2145
+ # condition R1 of F. Brown
2146
+ if w[0] == w[-1] or (len(w) >= 4 and
2147
+ all(x == w[1] for x in w[2:-1])):
2148
+ return self.zero()
2149
+ return self._monomial(w)
2150
+
2151
+ def dual_on_basis(self, w):
2152
+ """
2153
+ Reverse the word and exchange the letters 0 and 1.
2154
+
2155
+ This is the operation R4 in [Brown2012]_.
2156
+
2157
+ This should be used only when `a_0 = 0` and `a_{n+1} = 1`.
2158
+
2159
+ EXAMPLES::
2160
+
2161
+ sage: from sage.modular.multiple_zeta import All_iterated
2162
+ sage: M = All_iterated(QQ)
2163
+ sage: x = Word((0,0,1,0,1))
2164
+ sage: M.dual_on_basis(x)
2165
+ I(0;010;1)
2166
+ sage: x = Word((0,1,0,1,1))
2167
+ sage: M.dual_on_basis(x)
2168
+ -I(0;010;1)
2169
+ """
2170
+ W = self.basis().keys()
2171
+ if w[-2] == 0:
2172
+ return self._monomial(w)
2173
+ rev = [1 - x for x in reversed(w)]
2174
+ image = self._monomial(W(rev, check=False))
2175
+ return -image if len(w) % 2 else image
2176
+
2177
+ @lazy_attribute
2178
+ def dual(self):
2179
+ """
2180
+ Reverse words and exchange the letters 0 and 1.
2181
+
2182
+ This is the operation R4 in [Brown2012]_.
2183
+
2184
+ This should be used only when `a_0 = 0` and `a_{n+1} = 1`.
2185
+
2186
+ EXAMPLES::
2187
+
2188
+ sage: from sage.modular.multiple_zeta import All_iterated
2189
+ sage: M = All_iterated(QQ)
2190
+ sage: x = Word((0,0,1,1,1))
2191
+ sage: y = Word((0,0,1,0,1))
2192
+ sage: M.dual(M(x)+5*M(y))
2193
+ 5*I(0;010;1) - I(0;001;1)
2194
+ """
2195
+ return self.module_morphism(self.dual_on_basis, codomain=self)
2196
+
2197
+ def reversal_on_basis(self, w):
2198
+ """
2199
+ Reverse the word if necessary.
2200
+
2201
+ This is the operation R3 in [Brown2012]_.
2202
+
2203
+ This reverses the word only if `a_0 = 0` and `a_{n+1} = 1`.
2204
+
2205
+ EXAMPLES::
2206
+
2207
+ sage: from sage.modular.multiple_zeta import All_iterated
2208
+ sage: M = All_iterated(QQ)
2209
+ sage: x = Word((1,0,1,0,0))
2210
+ sage: M.reversal_on_basis(x)
2211
+ -I(0;010;1)
2212
+ sage: x = Word((0,0,1,1,1))
2213
+ sage: M.reversal_on_basis(x)
2214
+ I(0;011;1)
2215
+ """
2216
+ if w[0] == 0 and w[-1] == 1:
2217
+ return self._monomial(w)
2218
+ W = self.basis().keys()
2219
+ image = self._monomial(W(list(reversed(w)), check=False))
2220
+ return -image if len(w) % 2 else image
2221
+
2222
+ @lazy_attribute
2223
+ def reversal(self):
2224
+ """
2225
+ Reverse words if necessary.
2226
+
2227
+ This is the operation R3 in [Brown2012]_.
2228
+
2229
+ This reverses the word only if `a_0 = 0` and `a_{n+1} = 1`.
2230
+
2231
+ EXAMPLES::
2232
+
2233
+ sage: from sage.modular.multiple_zeta import All_iterated
2234
+ sage: M = All_iterated(QQ)
2235
+ sage: x = Word((1,0,1,0,0))
2236
+ sage: y = Word((0,0,1,1,1))
2237
+ sage: M.reversal(M(x)+2*M(y))
2238
+ 2*I(0;011;1) - I(0;010;1)
2239
+ """
2240
+ return self.module_morphism(self.reversal_on_basis, codomain=self)
2241
+
2242
+ def expand_on_basis(self, w):
2243
+ """
2244
+ Perform an expansion as a linear combination.
2245
+
2246
+ This is the operation R2 in [Brown2012]_.
2247
+
2248
+ This should be used only when `a_0 = 0` and `a_{n+1} = 1`.
2249
+
2250
+ EXAMPLES::
2251
+
2252
+ sage: from sage.modular.multiple_zeta import All_iterated
2253
+ sage: M = All_iterated(QQ)
2254
+ sage: x = Word((0,0,1,0,1))
2255
+ sage: M.expand_on_basis(x)
2256
+ -2*I(0;100;1)
2257
+
2258
+ sage: x = Word((0,0,0,1,0,1,0,0,1))
2259
+ sage: M.expand_on_basis(x)
2260
+ 6*I(0;1010000;1) + 6*I(0;1001000;1) + 3*I(0;1000100;1)
2261
+
2262
+ sage: x = Word((0,1,1,0,1))
2263
+ sage: M.expand_on_basis(x)
2264
+ I(0;110;1)
2265
+ """
2266
+ if w[1] == 1:
2267
+ return self._monomial(w)
2268
+
2269
+ W = self.basis().keys()
2270
+ n_zeros = []
2271
+ k = 0
2272
+ for x in w[1:-1]:
2273
+ if x == 0:
2274
+ k += 1
2275
+ else:
2276
+ n_zeros.append(k)
2277
+ k = 1
2278
+ n_zeros.append(k)
2279
+ k = n_zeros[0]
2280
+ n_zeros = n_zeros[1:]
2281
+ r = len(n_zeros)
2282
+
2283
+ resu = self.zero()
2284
+ for idx in IntegerVectors(k, r):
2285
+ coeff = ZZ.prod(ZZ(nj + ij - 1).binomial(ij)
2286
+ for nj, ij in zip(n_zeros, idx))
2287
+ indice = [0]
2288
+ for nj, ij in zip(n_zeros, idx):
2289
+ indice += [1] + [0] * (nj + ij - 1)
2290
+ resu += coeff * self._monomial(W(tuple(indice + [1]),
2291
+ check=False))
2292
+ return (-1)**k * resu # attention au signe
2293
+
2294
+ @lazy_attribute
2295
+ def expand(self):
2296
+ """
2297
+ Perform an expansion as a linear combination.
2298
+
2299
+ This is the operation R2 in [Brown2012]_.
2300
+
2301
+ This should be used only when `a_0 = 0` and `a_{n+1} = 1`.
2302
+
2303
+ EXAMPLES::
2304
+
2305
+ sage: from sage.modular.multiple_zeta import All_iterated
2306
+ sage: M = All_iterated(QQ)
2307
+ sage: x = Word((0,0,1,0,1))
2308
+ sage: y = Word((0,0,1,1,1))
2309
+ sage: M.expand(M(x)+2*M(y))
2310
+ -2*I(0;110;1) - 2*I(0;101;1) - 2*I(0;100;1)
2311
+ sage: M.expand(M([0,1,1,0,1]))
2312
+ I(0;110;1)
2313
+ sage: M.expand(M([0,1,0,0,1]))
2314
+ I(0;100;1)
2315
+ """
2316
+ return self.module_morphism(self.expand_on_basis, codomain=self)
2317
+
2318
+ class Element(CombinatorialFreeModule.Element):
2319
+ def conversion(self):
2320
+ """
2321
+ Conversion to the :class:`Multizetas_iterated`.
2322
+
2323
+ This assumed that the element has been prepared.
2324
+
2325
+ Not to be used directly.
2326
+
2327
+ EXAMPLES::
2328
+
2329
+ sage: from sage.modular.multiple_zeta import All_iterated
2330
+ sage: M = All_iterated(QQ)
2331
+ sage: x = Word((0,1,0,0,1))
2332
+ sage: y = M(x).conversion(); y
2333
+ I(100)
2334
+ sage: y.parent()
2335
+ Algebra of motivic multiple zeta values as convergent iterated
2336
+ integrals over Rational Field
2337
+ """
2338
+ M = Multizetas_iterated(self.parent().base_ring())
2339
+ return M.sum_of_terms((w[1:-1], cf) for w, cf in self)
2340
+
2341
+ def regularise(self):
2342
+ """
2343
+ Conversion to the :class:`Multizetas_iterated`.
2344
+
2345
+ This is the regularisation procedure, done in several steps.
2346
+
2347
+ EXAMPLES::
2348
+
2349
+ sage: from sage.modular.multiple_zeta import All_iterated
2350
+ sage: M = All_iterated(QQ)
2351
+ sage: x = Word((0,0,1,0,1))
2352
+ sage: M(x).regularise()
2353
+ -2*I(100)
2354
+ sage: x = Word((0,1,1,0,1))
2355
+ sage: M(x).regularise()
2356
+ I(110)
2357
+
2358
+ sage: x = Word((1,0,1,0,0))
2359
+ sage: M(x).regularise()
2360
+ 2*I(100)
2361
+ """
2362
+ P = self.parent()
2363
+ step1 = P.reversal(self) # R3
2364
+ step2 = P.expand(step1) # R2
2365
+ step3 = P.dual(step2) # R4
2366
+ step4 = P.expand(step3) # R2
2367
+ return step4.conversion() # dans Multizetas_iterated
2368
+
2369
+
2370
+ # **************** procedures after F. Brown ************
2371
+
2372
+ def coeff_phi(w):
2373
+ """
2374
+ Return the coefficient of `f_k` in the image by ``phi``.
2375
+
2376
+ INPUT:
2377
+
2378
+ - ``w`` -- a word in 0 and 1 with `k` letters (where `k` is odd)
2379
+
2380
+ OUTPUT: a rational number
2381
+
2382
+ EXAMPLES::
2383
+
2384
+ sage: from sage.modular.multiple_zeta import coeff_phi
2385
+ sage: coeff_phi(Word([1,0,0]))
2386
+ -1
2387
+ sage: coeff_phi(Word([1,1,0]))
2388
+ 1
2389
+ sage: coeff_phi(Word([1,1,0,1,0]))
2390
+ 11/2
2391
+ sage: coeff_phi(Word([1,1,0,0,0,1,0]))
2392
+ 109/16
2393
+ """
2394
+ if all(x == 0 for x in w[1:]):
2395
+ return -1 # beware the sign
2396
+ k = len(w)
2397
+ assert k % 2
2398
+ M = Multizetas_iterated(QQ)
2399
+ z = M.phi_extended(w)
2400
+ W = z.parent().basis().keys()
2401
+ w = W((0, [k]))
2402
+ return z.coefficient(w) # in QQ
2403
+
2404
+
2405
+ def phi_on_multiplicative_basis(compo):
2406
+ """
2407
+ Compute ``phi`` on one single multiple zeta value.
2408
+
2409
+ INPUT:
2410
+
2411
+ - ``compo`` -- a composition (in the hardcoded multiplicative base)
2412
+
2413
+ OUTPUT: an element in :func:`F_ring` with rational coefficients
2414
+
2415
+ EXAMPLES::
2416
+
2417
+ sage: from sage.modular.multiple_zeta import phi_on_multiplicative_basis
2418
+ sage: phi_on_multiplicative_basis((2,))
2419
+ f2
2420
+ sage: phi_on_multiplicative_basis((3,))
2421
+ f3
2422
+ """
2423
+ f = F_algebra(QQ).gen
2424
+
2425
+ if tuple(compo) == (2,):
2426
+ return f(2)
2427
+
2428
+ if len(compo) == 1:
2429
+ n, = compo
2430
+ return f(n)
2431
+
2432
+ return compute_u_on_compo(compo)
2433
+
2434
+
2435
+ def phi_on_basis(L):
2436
+ """
2437
+ Compute the value of phi on the hardcoded basis.
2438
+
2439
+ INPUT:
2440
+
2441
+ - ``L`` -- list of compositions; each composition in the hardcoded basis
2442
+
2443
+ This encodes a product of multiple zeta values.
2444
+
2445
+ OUTPUT: an element in :func:`F_ring`
2446
+
2447
+ EXAMPLES::
2448
+
2449
+ sage: from sage.modular.multiple_zeta import phi_on_basis
2450
+ sage: phi_on_basis([(3,),(3,)])
2451
+ 2*f3f3
2452
+ sage: phi_on_basis([(2,),(2,)])
2453
+ f2^2
2454
+ sage: phi_on_basis([(2,),(3,),(3,)])
2455
+ 2*f2*f3f3
2456
+ """
2457
+ F = F_algebra(QQ)
2458
+ return F.prod(phi_on_multiplicative_basis(compo) for compo in L)
2459
+
2460
+
2461
+ def D_on_compo(k, compo):
2462
+ """
2463
+ Return the value of the operator `D_k` on a multiple zeta value.
2464
+
2465
+ This is now only used as a place to keep many doctests.
2466
+
2467
+ INPUT:
2468
+
2469
+ - ``k`` -- an odd integer
2470
+
2471
+ - ``compo`` -- a composition
2472
+
2473
+ EXAMPLES::
2474
+
2475
+ sage: from sage.modular.multiple_zeta import D_on_compo
2476
+ sage: D_on_compo(3,(2,3))
2477
+ 3*I(100) # I(10)
2478
+
2479
+ sage: D_on_compo(3,(4,3))
2480
+ I(100) # I(1000)
2481
+ sage: D_on_compo(5,(4,3))
2482
+ 10*I(10000) # I(10)
2483
+
2484
+ sage: [D_on_compo(k, [3,5]) for k in (3,5,7)]
2485
+ [0, -5*I(10000) # I(100), 0]
2486
+
2487
+ sage: [D_on_compo(k, [3,7]) for k in (3,5,7,9)]
2488
+ [0, -6*I(10000) # I(10000), -14*I(1000000) # I(100), 0]
2489
+
2490
+ sage: D_on_compo(3,(4,3,3))
2491
+ -I(100) # I(1000100)
2492
+ sage: D_on_compo(5,(4,3,3))
2493
+ -10*I(10000) # I(10100)
2494
+ sage: D_on_compo(7,(4,3,3))
2495
+ 4*I(1001000) # I(100) + 2*I(1000100) # I(100)
2496
+
2497
+ sage: [D_on_compo(k,(1,3,1,3,1,3)) for k in range(3,10,2)]
2498
+ [0, 0, 0, 0]
2499
+ """
2500
+ it = composition_to_iterated(compo)
2501
+ M = Multizetas_iterated(QQ)
2502
+ return (-1)**len(compo) * M.D_on_basis(k, it)
2503
+
2504
+
2505
+ def compute_u_on_compo(compo):
2506
+ r"""
2507
+ Compute the value of the map ``u`` on a multiple zeta value.
2508
+
2509
+ INPUT:
2510
+
2511
+ - ``compo`` -- a composition
2512
+
2513
+ OUTPUT: an element of :func:`F_ring` over `\QQ`
2514
+
2515
+ EXAMPLES::
2516
+
2517
+ sage: from sage.modular.multiple_zeta import compute_u_on_compo
2518
+ sage: compute_u_on_compo((2,4))
2519
+ 2*f3f3
2520
+ sage: compute_u_on_compo((2,3,2))
2521
+ -11/2*f2*f5
2522
+ sage: compute_u_on_compo((3,2,3,2))
2523
+ -75/4*f3f7 + 81/4*f5f5 + 75/8*f7f3 + 11*f2*f3f5 - 9*f2*f5f3
2524
+ """
2525
+ it = composition_to_iterated(compo)
2526
+ return (-1)**len(compo) * compute_u_on_basis(it)
2527
+
2528
+
2529
+ def compute_u_on_basis(w):
2530
+ r"""
2531
+ Compute the value of ``u`` on a multiple zeta value.
2532
+
2533
+ INPUT:
2534
+
2535
+ - ``w`` -- a word in 0,1
2536
+
2537
+ OUTPUT: an element of :func:`F_ring` over `\QQ`
2538
+
2539
+ EXAMPLES::
2540
+
2541
+ sage: from sage.modular.multiple_zeta import compute_u_on_basis
2542
+ sage: compute_u_on_basis((1,0,0,0,1,0))
2543
+ -2*f3f3
2544
+
2545
+ sage: compute_u_on_basis((1,1,1,0,0))
2546
+ f2*f3
2547
+
2548
+ sage: compute_u_on_basis((1,0,0,1,0,0,0,0))
2549
+ -5*f5f3
2550
+
2551
+ sage: compute_u_on_basis((1,0,1,0,0,1,0))
2552
+ 11/2*f2*f5
2553
+
2554
+ sage: compute_u_on_basis((1,0,0,1,0,1,0,0,1,0))
2555
+ -75/4*f3f7 + 81/4*f5f5 + 75/8*f7f3 + 11*f2*f3f5 - 9*f2*f5f3
2556
+ """
2557
+ M = Multizetas_iterated(QQ)
2558
+ F = F_algebra(QQ)
2559
+ N = len(w)
2560
+ xi_dict = {}
2561
+ for k in range(3, N, 2):
2562
+ xi_dict[k] = F.sum(cf * coeff_phi(ww[0]) * M.phi_extended(tuple(ww[1]))
2563
+ for ww, cf in M.D_on_basis(k, w))
2564
+ return F.sum(F.half_product(F.gen(k), xi_dict[k])
2565
+ for k in range(3, N, 2))
2566
+
2567
+
2568
+ @cached_function
2569
+ def rho_matrix_inverse(n):
2570
+ """
2571
+ Return the matrix of the inverse of ``rho``.
2572
+
2573
+ This is the matrix in the chosen bases, namely the hardcoded basis
2574
+ of multiple zeta values and the natural basis of the F ring.
2575
+
2576
+ INPUT:
2577
+
2578
+ - ``n`` -- integer
2579
+
2580
+ EXAMPLES::
2581
+
2582
+ sage: from sage.modular.multiple_zeta import rho_matrix_inverse
2583
+ sage: rho_matrix_inverse(3)
2584
+ [1]
2585
+ sage: rho_matrix_inverse(8)
2586
+ [-1/5 0 0 0]
2587
+ [ 1/5 1 0 0]
2588
+ [ 0 0 1/2 0]
2589
+ [ 0 0 0 1]
2590
+ """
2591
+ base = extend_multiplicative_basis(B_data, n)
2592
+ resu = []
2593
+ for b in base:
2594
+ phi_b = phi_on_basis(b)
2595
+ resu.append(phi_b.homogeneous_to_vector())
2596
+ dN = len(resu)
2597
+ return ~matrix(QQ, dN, dN, resu)
2598
+
2599
+
2600
+ def rho_inverse(elt):
2601
+ """
2602
+ Return the image by the inverse of ``rho``.
2603
+
2604
+ INPUT:
2605
+
2606
+ - ``elt`` -- an homogeneous element of the F ring
2607
+
2608
+ OUTPUT: a linear combination of multiple zeta values
2609
+
2610
+ EXAMPLES::
2611
+
2612
+ sage: from sage.modular.multiple_zeta import rho_inverse
2613
+ sage: from sage.modular.multiple_zeta_F_algebra import F_algebra
2614
+ sage: A = F_algebra(QQ)
2615
+ sage: f = A.gen
2616
+ sage: rho_inverse(f(3))
2617
+ ζ(3)
2618
+ sage: rho_inverse(f(9))
2619
+ ζ(9)
2620
+ sage: rho_inverse(A("53"))
2621
+ -1/5*ζ(3,5)
2622
+ """
2623
+ pa = elt.parent()
2624
+ BR = pa.base_ring().base_ring()
2625
+ M_BR = Multizetas(BR)
2626
+ if elt == pa.zero():
2627
+ return M_BR.zero()
2628
+
2629
+ pw, _ = next(iter(elt))
2630
+ p, w = pw
2631
+ N = 2 * p + sum(int(c) for c in w)
2632
+
2633
+ v = elt.homogeneous_to_vector()
2634
+ w = v * rho_matrix_inverse(N)
2635
+ return sum(cf * b for cf, b in zip(w, M_BR.basis_data(BR, N)))