modular_forms 0.0.4 → 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 +4 -4
- data/README.md +42 -45
- data/lib/modular_forms/core/elliptic_curves_fp.rb +7 -3
- data/lib/modular_forms/core/elliptic_curves_q.rb +26 -4
- data/lib/modular_forms/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3db834376767beecfe9ac15dba1a8ac97e3e9d845db19729668bbd32d511278d
|
|
4
|
+
data.tar.gz: d12f3d74498c06a7a16f264ab2d659b372e5629d2688470a4f39d2c3ad71883d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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
|
-
##
|
|
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
|
|
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
|
-
##
|
|
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
|
-
##
|
|
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
|
-
-
|
|
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)
|
|
@@ -46,13 +45,10 @@ Given the vastness of the field, this tool intentionally focuses on a limited su
|
|
|
46
45
|
|
|
47
46
|
### Not Optimized for Computational Efficiency
|
|
48
47
|
|
|
49
|
-
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**.
|
|
50
|
-
|
|
51
|
-
### Goal
|
|
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**.
|
|
52
49
|
|
|
53
|
-
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.
|
|
54
50
|
|
|
55
|
-
##
|
|
51
|
+
## Installation
|
|
56
52
|
|
|
57
53
|
You can install the `modular_forms` gem directly from **RubyGems** or clone it from GitHub.
|
|
58
54
|
|
|
@@ -77,9 +73,9 @@ Then require the file like this:
|
|
|
77
73
|
require "<PATH>/modular_forms.rb"
|
|
78
74
|
```
|
|
79
75
|
|
|
80
|
-
##
|
|
76
|
+
## How to use?
|
|
81
77
|
|
|
82
|
-
###
|
|
78
|
+
### Explore Fermat’s Last Theorem in Sonic Pi
|
|
83
79
|
|
|
84
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**.
|
|
85
81
|
|
|
@@ -116,7 +112,7 @@ live_loop :modularity_music do
|
|
|
116
112
|
end
|
|
117
113
|
```
|
|
118
114
|
|
|
119
|
-
###
|
|
115
|
+
### Merging Machine and Organism - Warp Up
|
|
120
116
|
|
|
121
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.
|
|
122
118
|
|
|
@@ -165,7 +161,7 @@ end
|
|
|
165
161
|
end
|
|
166
162
|
```
|
|
167
163
|
|
|
168
|
-
##
|
|
164
|
+
## Implemented Modular Forms, Elliptic Curves, and Related Definitions
|
|
169
165
|
|
|
170
166
|
### Eisenstein Series
|
|
171
167
|
|
|
@@ -222,45 +218,46 @@ end
|
|
|
222
218
|
27. `ModularForms.discriminant_q(curve)`
|
|
223
219
|
28. `ModularForms.j_invariant_q(curve)`
|
|
224
220
|
29. `ModularForms.point_on_curve_q?(curve, point)`
|
|
225
|
-
30. `ModularForms.
|
|
226
|
-
31. `ModularForms.
|
|
227
|
-
32. `ModularForms.
|
|
228
|
-
33. `ModularForms.
|
|
229
|
-
34. `ModularForms.
|
|
230
|
-
35. `ModularForms.
|
|
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)`
|
|
231
228
|
|
|
232
229
|
### Elliptic Curves over Finite Fields
|
|
233
230
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
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)`
|
|
243
240
|
|
|
244
241
|
### Newform Invariants
|
|
245
242
|
|
|
246
|
-
|
|
243
|
+
46. `ModularForms.analytic_conductor(level_n, weight_k)`
|
|
247
244
|
|
|
248
245
|
### L-functions
|
|
249
246
|
|
|
250
|
-
|
|
247
|
+
47. `ModularForms.a_p(p, cardinality)`
|
|
251
248
|
|
|
252
249
|
### p-adic Fields
|
|
253
250
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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)`
|
|
258
255
|
|
|
259
256
|
### Number Fields
|
|
260
257
|
|
|
261
|
-
|
|
258
|
+
52. `ModularForms.zeta_coeffs_deg2(dirichlet_char_group, n)`
|
|
262
259
|
|
|
263
|
-
##
|
|
260
|
+
## Testing
|
|
264
261
|
|
|
265
262
|
Install dependencies first:
|
|
266
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
|
-
|
|
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
|
-
|
|
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])
|