modular_forms
A creative toolkit for exploring modular forms and elliptic curves through Sonic Pi.
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.2%) to scientific vocabulary
Keywords
Repository
A creative toolkit for exploring modular forms and elliptic curves through Sonic Pi.
Basic Info
- Host: GitHub
- Owner: edelveart
- License: mit
- Language: Ruby
- Default Branch: main
- Homepage: https://rubygems.org/gems/modular_forms
- Size: 731 KB
Statistics
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 3
Topics
Metadata Files
README.md
Modular Forms
A creative toolkit for exploring modular forms and elliptic curves through Sonic Pi.
Project Status
This is a pre-alpha release of modular_forms. At this stage, only a subset of core mathematical definitions and operations is implemented.
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.
Features
- 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.
- 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.
Purpose and Scope
Overview
Given the vastness of the field, this tool intentionally focuses on a limited subset of definitions, without covering all aspects of each.
- List of implemented modules:
Not Optimized for Computational Efficiency
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.
Goal
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.
Installation
You can install the modular_forms gem directly from RubyGems or clone it from GitHub.
bash
gem install modular_forms
If you are use Ruby, then import via
rb
require 'modular_forms'
If you are using Sonic Pi, replace <PATH> with the directory path to the modular_forms.rb file inside the gem installation on your system. You can find the full path by running:
bash
gem which modular_forms
Then require the file like this:
rb
require "<PATH>/modular_forms.rb"
How to use?
Explore Fermat’s Last Theorem in Sonic Pi
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.
For example, we can explore the relationship between the elliptic curve 144.a3 and the newform orbit 144.2.a.a through their L-function,
L(E, s) = L(f, s), in a musical sense.
```rb
require "
Set precision for the Fourier q-expansion
prec = 20
Construct a weight 2 newform as an eta quotient
n = ModularForms.dedekindetapow(12, prec, 12) d1 = ModularForms.dedekindetapow(4, prec, 6) d2 = ModularForms.dedekindetapow(4, prec, 24) etaprod = ModularForms.etaproduct(d1, d2)
newform = ModularForms.etaquotient(n, etaprod, prec)
Define the elliptic curve E over F_p
p = 13 ellc = ModularForms.ellipticcurvefp(p, [0, -1]) # y^2 = x^3 - 1 points = ModularForms.cardinality_fp(ellc) # count points on E mod p
Compute the modular coefficient a_p of L-function(E, s)
ap = ModularForms.ap(p, points)
Sonify the modular relationship
liveloop :modularitymusic do play (chord (:a3 + ap), :m11)[newform.ring.tick], amp: ap, release: 0.125 sleep 0.125 end ```
Merging Machine and Organism - Warp Up
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.
```rb
require "
p = 3 eisensteinmelody = ModularForms.eisensteinseries(8) e8 = eisensteinmelody.take(58) heckeop = ModularForms.heckeoperatorprimenoncusp(e8, p, 8, 20)
ellc = ModularForms.ellipticcurveq([2, 5]) disc = ModularForms.discriminant_q(ellc)
jfunc = ModularForms.jfunction(40) newformac = ModularForms.analyticconductor(15, 2) pol = ModularForms.defpol2deg(41)
x = 7 dirichletchargroup = .each do |i| dirichletchargroup << ModularForms.conreyppminus1(x, i) end
(disc * -1).times do synth :zawa, note: ModularForms.zetacoeffsdeg2(dirichletchargroup, 30) .tick(:zeta) + 72, amp: rrand(0.3, 0.6)
synth :subpulse, note: ModularForms.padicvaluation(eisensteinmelody.next, p) % 7 + 70, release: 0.25 if (spread (disc % 6), 7).tick(:d)
synth :chiplead, note: heckeop.tick(:tp) % 7 + 50, release: newformac, attack: newform_ac
synth :fm, note: ModularForms.gausssumtriv(5, jfunc.tick(:j)) + 51, release: 0.25, attack: 0.012, pan: ModularForms.analyticconductor(jfunc.look % 15, 4) * rrandi(-1, 1) if spread(ModularForms.gamma1_index(p), 11).tick(:g)
sample 90, release: 0.125 if pol.tick == 'x' sample :ambidrone, beatstretch: 0.7 if pol.look == '*' sample :bassdropc, release: 0.125 if pol.look == '6'
sleep ModularForms.padic_norm(p, p) end ```
Implemented Modular Forms, Elliptic Curves, and Related Definitions
Eisenstein Series
ModularForms.eisenstein_series(weight_k, galois_field = nil)ModularForms.eisenstein_series_product(weight_k1, weight_k2, prec)ModularForms.eisenstein_series_pow(weight_k, power, prec)
Eta Functions and Eta Quotients
ModularForms.dedekind_eta_function(m_scale = 1, pentagonal_coefs = false)ModularForms.dedekind_eta_pow(power, prec, m_scale = 1)ModularForms.dedekind_sum(h, k)ModularForms.eta_product(eta1, eta2, prec = nil)-
ModularForms.eta_quotient(num_eta, den_eta, prec)
Theta Functions
ModularForms.jacobi_theta_function(jacobi_index = 3, square_coefs = false)-
ModularForms.jacobi_theta_function_pow(jacobi_index, power, prec)
Ramanujan Tau Function
ModularForms.ramanujan_tau_function
J-Function
ModularForms.j_function(prec)
Hecke Operators
ModularForms.hecke_operator_prime_non_cusp(non_cusp_form_arr, prime, weight_k, prec)ModularForms.hecke_operator_prime_cusp(cusp_form_arr, prime, weight_k, prec)
SL(2,Z) Group
ModularForms.t_gen_matrix(n_power)ModularForms.s_gen_matrix(n_power)ModularForms.u_gen_matrix(mod_n)ModularForms.st_gen_matrix(n_power)ModularForms.product_gen_mats(gen_mat_a, gen_mat_b)ModularForms.gamma0_index(n)ModularForms.gamma1_index(n)
Dirichlet Characters
ModularForms.dirichlet_trivchar(modq, a)ModularForms.conrey_p_pminus1(modp, a)ModularForms.gauss_sum_triv(dirichlet_q, a)ModularForms.gauss_sum_conrey_p_minus1(dirichlet_q, a, parity)
Elliptic Curves over Rationals
ModularForms.elliptic_curve_q(coefs)ModularForms.discriminant_q(curve)ModularForms.j_invariant_q(curve)ModularForms.point_on_curve_q?(curve, point)ModularForms.point_addition_q(curve, p, q)ModularForms.scalar_mul_point_q(curve, n, point)ModularForms.isogeny_2deg_q(curve, point_2tor)ModularForms.isogeny_ndeg_q(curve, point_ntor, order)ModularForms.weil_height(x_point)ModularForms.canonical_height(curve, point, prec = 64)
Elliptic Curves over Finite Fields
ModularForms.elliptic_curve_fp(p, coefs)ModularForms.point_on_curve_modp?(curve, point)ModularForms.discriminant_modp(curve)ModularForms.j_invariant_modp(curve)ModularForms.point_addition_modp(curve, p_point, q_point)ModularForms.scalar_mul_point_modp(curve, n, point)ModularForms.points_fp(curve, point_at_infinity = false)ModularForms.cardinality_fp(curve)ModularForms.quadratic_twist_fp(curve)
Newform Invariants
ModularForms.analytic_conductor(level_n, weight_k)
L-functions
ModularForms.a_p(p, cardinality)
p-adic Fields
ModularForms.padic_valuation(num_b10, p)ModularForms.padic_norm(num_b10, p)ModularForms.padic_expansion(num_b10, p, prec = 11, reverse_trim = false)ModularForms.def_pol_2deg(p = 2, c = 0, num = 1)
Number Fields
ModularForms.zeta_coeffs_deg2(dirichlet_char_group, n)
Testing
Install dependencies first:
bash
bundle install
This project features a comprehensive Minitest suite covering core functionality across modules. While not all edge cases are tested, the main mathematical functions are well validated to ensure correctness and stability.
Run tests with:
bash
rake test
Owner
- Name: Edgar Delgado Vega
- Login: edelveart
- Kind: user
- Location: Lima-Perú
- Repositories: 1
- Profile: https://github.com/edelveart
Hi, I'm Edgar, a person motivated by art and technology. My interests are mathematical music theory and live coding (Sonic Pi).
Citation (CITATION.cff)
cff-version: 1.2.0
message: "If you use this software and its documentation, please cite it as below."
authors:
- family-names: "Delgado Vega"
given-names: "Edgar Armando"
orcid: "https://orcid.org/0000-0002-9672-9087"
title: "Modular Forms: A Creative Toolkit for Exploring Modular Forms and Elliptic Curves through Sonic Pi"
version: 0.0.4
doi:
date-released: 2025-05-22
url: "https://github.com/edelveart/modular_forms"
repository-code: "https://github.com/edelveart/modular_forms"
license: MIT
GitHub Events
Total
- Release event: 1
- Watch event: 1
- Push event: 30
- Public event: 1
- Create event: 4
Last Year
- Release event: 1
- Watch event: 1
- Push event: 30
- Public event: 1
- Create event: 4
Packages
- Total packages: 1
-
Total downloads:
- rubygems 732 total
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 4
- Total maintainers: 1
rubygems.org: modular_forms
Modular Forms is an accessible interface for experimenting with modular forms and elliptic curves through algorithmic composition and live coding using Sonic Pi.
- Homepage: https://github.com/edelveart/modular_forms
- Documentation: http://www.rubydoc.info/gems/modular_forms/
- License: MIT
-
Latest release: 0.0.4
published 9 months ago
Rankings
Maintainers (1)
Dependencies
- minitest ~> 5.0 development
- rake ~> 13.0 development
- rubocop >= 0 development
- ruby-lsp >= 0 development
- ast 2.4.3
- bundler 2.6.8
- json 2.10.2
- language_server-protocol 3.17.0.4
- lint_roller 1.1.0
- logger 1.7.0
- minitest 5.25.5
- parallel 1.27.0
- parser 3.3.8.0
- prism 1.4.0
- racc 1.8.1
- rainbow 3.1.1
- rake 13.2.1
- rbs 3.9.2
- regexp_parser 2.10.0
- rubocop 1.75.2
- rubocop-ast 1.44.1
- ruby-lsp 0.23.14
- ruby-progressbar 1.13.0
- sorbet-runtime 0.5.12026
- unicode-display_width 3.1.4
- unicode-emoji 4.0.4