modular_forms 0.0.3 → 0.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9b49161da093d436c9afd089b0d2935a43fafb71d1b1eece1af75cc3ef08833
4
- data.tar.gz: 54672d7ef27bc439d12747a919a024e9c9fa58d76a3d4b3ae1fa3f807226be6b
3
+ metadata.gz: 3db834376767beecfe9ac15dba1a8ac97e3e9d845db19729668bbd32d511278d
4
+ data.tar.gz: d12f3d74498c06a7a16f264ab2d659b372e5629d2688470a4f39d2c3ad71883d
5
5
  SHA512:
6
- metadata.gz: d8ad361a6edc83f140ac815bb4b04a6a627100204f523e2192edfaa4cdc8e7b1022cd1c4e6651526582d287818231193d546dd2fb99b859d39401cb5002b3861
7
- data.tar.gz: 2a7223689108395ebc2f389d1e1ae9b6e61a5165e9da9885624b7758500131ca01f983c433dc045928c433608d773b6ea22410d2196b43b2261cb88c40933b27
6
+ metadata.gz: a599f05653f0abea5792617200ffba19726ee0abe421de1e04b13a4beb92e3f1911e61688ee05b55aae7aa8d8114fa63378e188fceb91a568160e20307c77232
7
+ data.tar.gz: bddeae428139325379f8172ebac90d324da39c633470823b40fbebbd0211358c7805dcb4db0c464e1e5156619e59a912d988a28006a9fbc9e08af29cbc4ee856
data/README.md CHANGED
@@ -3,32 +3,31 @@
3
3
  A creative toolkit for exploring modular forms and elliptic curves through [Sonic Pi](https://sonic-pi.net/).
4
4
 
5
5
  <p align="center">
6
- <img src="https://img.shields.io/gem/v/modular_forms" alt="Gem Version">
7
- <img src="https://img.shields.io/gem/dt/modular_forms" alt="Gem Total Downloads">
8
- <img src="https://img.shields.io/github/stars/edelveart/modular_forms" alt="GitHub Repo stars">
9
- <img src="https://img.shields.io/github/license/edelveart/modular_forms" alt="GitHub License">
6
+ <img src="https://img.shields.io/gem/v/modular_forms" alt="Gem Version" />
7
+ <img src="https://img.shields.io/gem/dt/modular_forms" alt="Gem Total Downloads" />
8
+ <img src="https://img.shields.io/github/stars/edelveart/modular_forms" alt="GitHub Repo stars" />
10
9
  </p>
11
10
 
12
- [![Modular Forms - Image](https://raw.githubusercontent.com/edelveart/modular_forms/main/modular_forms.png)](https://rubygems.org/gems/modular_forms)
11
+ <p align="center">
12
+ <img src="https://raw.githubusercontent.com/edelveart/modular_forms/main/modular_forms.png" width="400" alt="Modular Forms Image" />
13
+ </p>
13
14
 
14
- ## ⚙️ Project Status
15
+ ## Project Status
15
16
 
16
- This is a pre-alpha release of `modular_forms`. At this stage, only a subset of core mathematical definitions and operations is implemented.
17
+ This is a **pre-alpha** release of `modular_forms`. At this stage, only a subset of core mathematical definitions and operations is implemented.
17
18
 
18
- Future updates might include a DSL, depending on how the library is used and the interest from the community. A key challenge lies in creating musical mappings that stay true to the underlying mathematics while also sounding intentional, expressive, and naturally fitting within a musical structure.
19
+ Future updates might include a **DSL**, depending on how the library is used and the interest from the community. A key challenge is turning mathematical ideas into music that feels deliberate, expressive, and naturally musical.
19
20
 
20
- ## 🧊 Features
21
+ ## Features
21
22
 
22
23
  - **Accessible to both musicians and coders**: No math expertise required. Create musical patterns, rhythms, timbres, and harmonies by experimenting with mathematical ideas and turning them into sound and effects intuitively.
23
24
  - **Interactive Educational Resource**: Use **Sonic Pi** to discover introductory number theory in a hands-on, immersive way, gaining insights into abstract concepts through math in action.
24
25
 
25
- ## 💡 Purpose and Scope
26
-
27
- ### Overview
26
+ ## Scope
28
27
 
29
28
  Given the vastness of the field, this tool intentionally focuses on a limited subset of definitions, without covering all aspects of each.
30
29
 
31
- - 🧩 List of implemented modules:
30
+ - List of implemented modules:
32
31
  - [Eisenstein Series](#eisenstein-series)
33
32
  - [Eta Functions and Eta Quotients](#eta-functions-and-eta-quotients)
34
33
  - [Theta Functions](#theta-functions)
@@ -42,16 +41,14 @@ Given the vastness of the field, this tool intentionally focuses on a limited su
42
41
  - [Newform Invariants](#newform-invariants)
43
42
  - [L-functions](#l-functions)
44
43
  - [p-adic Fields](#p-adic-fields)
44
+ - [Number Fields](#number-fields)
45
45
 
46
46
  ### Not Optimized for Computational Efficiency
47
47
 
48
- This library is designed for creative exploration rather than maximum computational efficiency. It is **not intended** to replace specialized mathematical software optimized for heavy or large-scale computations. Instead, it draws inspiration from tools like **SageMath**, **Pari/GP**, and the **LMFDB database**.
48
+ > This library is designed for creative exploration rather than maximum computational efficiency. It is **not intended** to replace specialized mathematical software optimized for heavy or large-scale computations. Instead, it draws inspiration from tools like **SageMath**, **Pari/GP**, and the **LMFDB database**.
49
49
 
50
- ### Goal
51
50
 
52
- The goal is simple: to provide an accessible and creative starting point for those who wish to explore, learn, and uncover new ideas, regardless of their mathematical background.
53
-
54
- ## 💎 Installation
51
+ ## Installation
55
52
 
56
53
  You can install the `modular_forms` gem directly from **RubyGems** or clone it from GitHub.
57
54
 
@@ -76,9 +73,9 @@ Then require the file like this:
76
73
  require "<PATH>/modular_forms.rb"
77
74
  ```
78
75
 
79
- ## 🧰 How to use?
76
+ ## How to use?
80
77
 
81
- ### 🎶 Explore Fermat’s Last Theorem in Sonic Pi
78
+ ### Explore Fermat’s Last Theorem in Sonic Pi
82
79
 
83
80
  The Taniyama–Shimura Conjecture (now the Modularity Theorem), proven for semistable cases by Andrew Wiles, connects elliptic curves over the rationals to modular forms. This profound result was crucial in proving **Fermat’s Last Theorem**.
84
81
 
@@ -115,24 +112,36 @@ live_loop :modularity_music do
115
112
  end
116
113
  ```
117
114
 
118
- ### 🎶 Merging Machine and Organism - Warp Up
115
+ ### Merging Machine and Organism - Warp Up
119
116
 
120
117
  Unlike the structured Fermat example, this finite loop explores more abstract territory, using multiple concepts to create a sonic landscape that, while grounded in mathematical principles, goes beyond conventional musical forms.
121
118
 
122
119
  ```rb
123
120
  require "<PATH>/modular_forms.rb"
124
121
 
125
- eisenstein_melody = ModularForms.eisenstein_series(8)
126
122
  p = 3
127
- ellc = ModularForms.elliptic_curve_q([2, 5])
128
- disc = ModularForms.discriminant_q(ellc)
123
+ eisenstein_melody = ModularForms.eisenstein_series(8)
129
124
  e8 = eisenstein_melody.take(58)
130
125
  hecke_op = ModularForms.hecke_operator_prime_non_cusp(e8, p, 8, 20)
126
+
127
+ ellc = ModularForms.elliptic_curve_q([2, 5])
128
+ disc = ModularForms.discriminant_q(ellc)
129
+
131
130
  j_func = ModularForms.j_function(40)
132
131
  newform_ac = ModularForms.analytic_conductor(15, 2)
133
132
  pol = ModularForms.def_pol_2deg(41)
134
133
 
134
+ x = 7
135
+ dirichlet_char_group = []
136
+ (1..x).each do |i|
137
+ dirichlet_char_group << ModularForms.conrey_p_pminus1(x, i)
138
+ end
139
+
135
140
  (disc * -1).times do
141
+ synth :zawa,
142
+ note: ModularForms.zeta_coeffs_deg2(dirichlet_char_group, 30)
143
+ .tick(:zeta) + 72, amp: rrand(0.3, 0.6)
144
+
136
145
  synth :subpulse, note: ModularForms.padic_valuation(eisenstein_melody.next, p) % 7 + 70,
137
146
  release: 0.25 if (spread (disc % 6), 7).tick(:d)
138
147
 
@@ -152,7 +161,7 @@ pol = ModularForms.def_pol_2deg(41)
152
161
  end
153
162
  ```
154
163
 
155
- ## 🧩 Implemented Modular Forms, Elliptic Curves, and Related Definitions
164
+ ## Implemented Modular Forms, Elliptic Curves, and Related Definitions
156
165
 
157
166
  ### Eisenstein Series
158
167
 
@@ -209,41 +218,46 @@ end
209
218
  27. `ModularForms.discriminant_q(curve)`
210
219
  28. `ModularForms.j_invariant_q(curve)`
211
220
  29. `ModularForms.point_on_curve_q?(curve, point)`
212
- 30. `ModularForms.point_addition_q(curve, p, q)`
213
- 31. `ModularForms.scalar_mul_point_q(curve, n, point)`
214
- 32. `ModularForms.isogeny_2deg_q(curve, point_2tor)`
215
- 33. `ModularForms.isogeny_ndeg_q(curve, point_ntor, order)`
216
- 34. `ModularForms.weil_height(x_point)`
217
- 35. `ModularForms.canonical_height(curve, point, prec = 64)`
221
+ 30. `ModularForms.negate_p(point)`
222
+ 31. `ModularForms.point_addition_q(curve, p, q)`
223
+ 32. `ModularForms.scalar_mul_point_q(curve, n, point)`
224
+ 33. `ModularForms.isogeny_2deg_q(curve, point_2tor)`
225
+ 34. `ModularForms.isogeny_ndeg_q(curve, point_ntor, order)`
226
+ 35. `ModularForms.weil_height(x_point)`
227
+ 36. `ModularForms.canonical_height(curve, point, prec = 64)`
218
228
 
219
229
  ### Elliptic Curves over Finite Fields
220
230
 
221
- 36. `ModularForms.elliptic_curve_fp(p, coefs)`
222
- 37. `ModularForms.point_on_curve_modp?(curve, point)`
223
- 38. `ModularForms.discriminant_modp(curve)`
224
- 39. `ModularForms.j_invariant_modp(curve)`
225
- 40. `ModularForms.point_addition_modp(curve, p_point, q_point)`
226
- 41. `ModularForms.scalar_mul_point_modp(curve, n, point)`
227
- 42. `ModularForms.points_fp(curve, point_at_infinity = false)`
228
- 43. `ModularForms.cardinality_fp(curve)`
229
- 44. `ModularForms.quadratic_twist_fp(curve)`
231
+ 37. `ModularForms.elliptic_curve_fp(p, coefs)`
232
+ 38. `ModularForms.point_on_curve_modp?(curve, point)`
233
+ 39. `ModularForms.discriminant_modp(curve)`
234
+ 40. `ModularForms.j_invariant_modp(curve)`
235
+ 41. `ModularForms.point_addition_modp(curve, p_point, q_point)`
236
+ 42. `ModularForms.scalar_mul_point_modp(curve, n, point)`
237
+ 43. `ModularForms.points_fp(curve, point_at_infinity = false)`
238
+ 44. `ModularForms.cardinality_fp(curve)`
239
+ 45. `ModularForms.quadratic_twist_fp(curve)`
230
240
 
231
241
  ### Newform Invariants
232
242
 
233
- 45. `ModularForms.analytic_conductor(level_n, weight_k)`
243
+ 46. `ModularForms.analytic_conductor(level_n, weight_k)`
234
244
 
235
245
  ### L-functions
236
246
 
237
- 46. `ModularForms.a_p(p, cardinality)`
247
+ 47. `ModularForms.a_p(p, cardinality)`
238
248
 
239
249
  ### p-adic Fields
240
250
 
241
- 47. `ModularForms.padic_valuation(num_b10, p)`
242
- 48. `ModularForms.padic_norm(num_b10, p)`
243
- 49. `ModularForms.padic_expansion(num_b10, p, prec = 11, reverse_trim = false)`
244
- 50. `ModularForms.def_pol_2deg(p = 2, c = 0, num = 1)`
251
+ 48. `ModularForms.padic_valuation(num_b10, p)`
252
+ 49. `ModularForms.padic_norm(num_b10, p)`
253
+ 50. `ModularForms.padic_expansion(num_b10, p, prec = 11, reverse_trim = false)`
254
+ 51. `ModularForms.def_pol_2deg(p = 2, c = 0, num = 1)`
255
+
256
+ ### Number Fields
257
+
258
+ 52. `ModularForms.zeta_coeffs_deg2(dirichlet_char_group, n)`
245
259
 
246
- ## 🧪 Testing
260
+ ## Testing
247
261
 
248
262
  Install dependencies first:
249
263
 
@@ -13,7 +13,7 @@ module ModularForms
13
13
  ((n % modp) + modp) % modp
14
14
  end
15
15
 
16
- def self.elliptic_curve_fp(p, coefs)
16
+ def self.elliptic_curve_fp(p, coefs) # rubocop:disable Metrics/MethodLength
17
17
  a, b = coefs
18
18
  raise "#{p} is not a prime number" if NumericHelpers.prime_number?(p) == false
19
19
 
@@ -21,9 +21,13 @@ module ModularForms
21
21
 
22
22
  a_modp = reduction_modp(a, p)
23
23
  b_modp = reduction_modp(b, p)
24
- raise "y^2=x^3 #{a_modp}x #{b_modp} defines a singular curve" if d == 0 # rubocop:disable Style/NumericPredicate
25
24
 
26
- puts "y^2 = x^3 #{a_modp}x #{b_modp} over Finite Field #{p}"
25
+ if d.zero?
26
+ raise "#{EllipticCurvesQ.show_curve_equation(a_modp,
27
+ b_modp)} defines a singular curve over F_#{p}"
28
+ end
29
+
30
+ puts "#{EllipticCurvesQ.show_curve_equation(a_modp, b_modp)} over Finite Field #{p}"
27
31
  { a: a, b: b, p: p }
28
32
  end
29
33
 
@@ -7,16 +7,35 @@ module ModularForms
7
7
  # ModularForms::Core::EllipticCurves
8
8
  #
9
9
  # This module provides methods for generating points on Elliptic Curves (short Weierstrass form) over Q
10
- module EllipticCurvesQ
10
+ module EllipticCurvesQ # rubocop:disable Metrics/ModuleLength
11
11
  def self.discriminant(a, b)
12
12
  -16 * (4 * a**3 + 27 * b**2)
13
13
  end
14
14
 
15
+ def self.show_curve_equation(a, b) # rubocop:disable Metrics/MethodLength,Lint/RedundantCopDisableDirective
16
+ eq = 'y^2 = x^3'
17
+ eq += a != 0 ? " #{a > 0 ? '+' : '-'} #{a.abs}x" : '' # rubocop:disable Style/NestedTernaryOperator,Style/NumericPredicate
18
+ eq += b != 0 ? " #{b > 0 ? '+' : '-'} #{b.abs}" : '' # rubocop:disable Style/NestedTernaryOperator,Style/NumericPredicate
19
+ eq
20
+ end
21
+
22
+ def self.singular?(a, b)
23
+ delta = discriminant(a, b)
24
+ return unless delta.zero?
25
+
26
+ type = begin
27
+ x_s = a.zero? ? 0 : Math.sqrt(-a / 3) rescue 0 # rubocop:disable Style/RescueModifier
28
+ x_s.zero? ? 'cusp' : 'node'
29
+ end
30
+
31
+ # Concatenar la ecuación directamente en el mensaje
32
+ raise "#{show_curve_equation(a, b)} defines a singular curve (#{type})"
33
+ end
34
+
15
35
  def self.elliptic_curve_q(coefs)
16
36
  a, b = coefs
17
- raise "y^2=x^3 #{a}x #{b} defines a singular curve" if discriminant(a, b) == 0 # rubocop:disable Style/NumericPredicate
18
-
19
- puts "y^2 = x^3 #{a}x #{b}"
37
+ singular?(a, b)
38
+ puts show_curve_equation(a, b)
20
39
  { a: a, b: b }
21
40
  end
22
41
 
@@ -126,3 +145,6 @@ module ModularForms
126
145
  end
127
146
  end
128
147
  end
148
+ # # [-1, 2],
149
+ # ModularForms::Core::EllipticCurvesQ.elliptic_curve_q([-27, 54])
150
+ # # ModularForms::Core::EllipticCurvesQ.show_curve_equation([-0, 0])
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ModularForms
4
+ module Core
5
+ # ModularForms::Core::NumberFields
6
+ #
7
+ # This module provides methods and objects related to number fields,
8
+ # such as zeta_coefficients and utility helpers.
9
+ module NumberFields
10
+ def self.fill_arr_with_interval(length, num, interval)
11
+ arr = Array.new(length, 0)
12
+ (interval - 1).step(length - 1, interval) do |i|
13
+ arr[i] = num
14
+ end
15
+ arr
16
+ end
17
+
18
+ def self.zeta_coeffs_deg2(dirichlet_char_group, num_coeffs)
19
+ ded_zeta_to_dir_serie = []
20
+ dirichlet_char_group.each_with_index do |i, j|
21
+ a = 1
22
+ while a <= num_coeffs
23
+ ded_zeta_to_dir_serie << fill_arr_with_interval(num_coeffs, i, j + a)
24
+ a += dirichlet_char_group.length
25
+ end
26
+ end
27
+ ded_zeta_to_dir_serie.transpose.map { |component| component.sum } # rubocop:disable Style/SymbolProc
28
+ end
29
+ end
30
+ end
31
+ end
@@ -13,3 +13,4 @@ require_relative 'core/dirichlet_characters'
13
13
  require_relative 'core/newform_invariants'
14
14
  require_relative 'core/l_functions'
15
15
  require_relative 'core/padic_fields'
16
+ require_relative 'core/number_fields'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ModularForms
4
- VERSION = '0.0.3'
4
+ VERSION = '0.0.5'
5
5
  end
data/lib/modular_forms.rb CHANGED
@@ -212,4 +212,8 @@ module ModularForms # rubocop:disable Metrics/ModuleLength
212
212
  def def_pol_2deg(p = 2, c = 0, num = 1)
213
213
  Core::PAdicFields.def_pol_2deg(p, c, num)
214
214
  end
215
+
216
+ def zeta_coeffs_deg2(dirichlet_char_group, n)
217
+ Core::NumberFields.zeta_coeffs_deg2(dirichlet_char_group, n)
218
+ end
215
219
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modular_forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edgar Armando Delgado Vega
@@ -33,6 +33,7 @@ files:
33
33
  - lib/modular_forms/core/klein_j_invariant.rb
34
34
  - lib/modular_forms/core/l_functions.rb
35
35
  - lib/modular_forms/core/newform_invariants.rb
36
+ - lib/modular_forms/core/number_fields.rb
36
37
  - lib/modular_forms/core/numeric_helpers/numeric_helpers.rb
37
38
  - lib/modular_forms/core/padic_fields.rb
38
39
  - lib/modular_forms/core/padic_pol/data_pol_2deg.rb