ubuntu2404
## -*- encoding: utf-8 -*-123# This file was *autogenerated* from the file main.sagetex.sage4from sage.all_cmdline import * # import sage library56_sage_const_226 = Integer(226); _sage_const_1 = Integer(1); _sage_const_21 = Integer(21); _sage_const_13 = Integer(13); _sage_const_254 = Integer(254); _sage_const_277 = Integer(277); _sage_const_6 = Integer(6); _sage_const_8 = Integer(8); _sage_const_12 = Integer(12); _sage_const_15 = Integer(15); _sage_const_0 = Integer(0); _sage_const_105 = Integer(105); _sage_const_210 = Integer(210); _sage_const_420 = Integer(420); _sage_const_20 = Integer(20); _sage_const_308 = Integer(308); _sage_const_314 = Integer(314); _sage_const_16 = Integer(16); _sage_const_323 = Integer(323); _sage_const_348 = Integer(348); _sage_const_17 = Integer(17); _sage_const_396 = Integer(396); _sage_const_408 = Integer(408); _sage_const_2 = Integer(2); _sage_const_3 = Integer(3); _sage_const_5 = Integer(5); _sage_const_7 = Integer(7); _sage_const_11 = Integer(11); _sage_const_24 = Integer(24); _sage_const_449 = Integer(449); _sage_const_468 = Integer(468); _sage_const_513 = Integer(513); _sage_const_524 = Integer(524); _sage_const_45 = Integer(45); _sage_const_9 = Integer(9); _sage_const_566 = Integer(566); _sage_const_576 = Integer(576); _sage_const_101 = Integer(101); _sage_const_30 = Integer(30); _sage_const_10 = Integer(10); _sage_const_50 = Integer(50); _sage_const_40 = Integer(40); _sage_const_634 = Integer(634)## This file (main.sagetex.sage) was *autogenerated* from main.tex with sagetex.sty version 2021/10/16 v3.6.7import sagetex8_st_ = sagetex.SageTeXProcessor('main', version='2021/10/16 v3.6', version_check=True)9_st_.current_tex_line = _sage_const_22610_st_.blockbegin()11try:12# Compute cyclotomic polynomials for n = 1 to 2013cyclotomic_data = {}14for n in range(_sage_const_1 , _sage_const_21 ):15phi_n = cyclotomic_polynomial(n)16degree = phi_n.degree()17coeffs = phi_n.coefficients(sparse=False)1819cyclotomic_data[n] = {20'polynomial': phi_n,21'degree': degree,22'coefficients': coeffs,23'euler_phi': euler_phi(n)24}2526# Display cyclotomic polynomials for small n27print("Cyclotomic Polynomials Φ_n(x) for n = 1 to 12:")28for n in range(_sage_const_1 , _sage_const_13 ):29phi_n = cyclotomic_data[n]['polynomial']30degree = cyclotomic_data[n]['degree']31print(f"Φ_{n}(x) = {phi_n}, degree = {degree}")3233# Verify that degree equals Euler's totient function34print("\nVerification: deg(Φ_n) = φ(n)")35for n in range(_sage_const_1 , _sage_const_13 ):36degree = cyclotomic_data[n]['degree']37euler_val = cyclotomic_data[n]['euler_phi']38print(f"n = {n}: deg(Φ_{n}) = {degree}, φ({n}) = {euler_val}, Equal: {degree == euler_val}")39except:40_st_.goboom(_sage_const_254 )41_st_.blockend()42_st_.current_tex_line = _sage_const_27743_st_.blockbegin()44try:45# Verify the fundamental identity for several values of n46print(r"Verification of $x^n - 1 = \prod_{d \mid n} \Phi_d(x)$:")4748for n in [_sage_const_6 , _sage_const_8 , _sage_const_12 , _sage_const_15 ]:49# Left side: x^n - 150left_side = x**n - _sage_const_15152# Right side: product of \Phi_d(x) for all d dividing n53divisors = [d for d in range(_sage_const_1 , n+_sage_const_1 ) if n % d == _sage_const_0 ]54right_side = _sage_const_155for d in divisors:56right_side *= cyclotomic_polynomial(d)5758# Verify equality (no need to expand - SageMath polynomials are already expanded)59equality = (left_side == right_side)6061print(f"n = {n}: divisors = {divisors}")62print(f" x^{n} - 1 = {left_side}")63print(f" Product = {right_side}")64print(f" Equal: {equality}")6566# Analyze coefficient patterns in cyclotomic polynomials67print("\nCoefficient analysis:")68for n in [_sage_const_105 , _sage_const_210 , _sage_const_420 ]: # Cases where coefficients exceed ±169if n <= _sage_const_20 : # Only for computed cases70continue71phi_n = cyclotomic_polynomial(n)72coeffs = phi_n.coefficients(sparse=False)73max_coeff = max(abs(c) for c in coeffs)74print(f"\\Phi_{n}(x): max |coefficient| = {max_coeff}")75except:76_st_.goboom(_sage_const_308 )77_st_.blockend()78_st_.current_tex_line = _sage_const_31479_st_.blockbegin()80try:81# Analysis of roots structure for visualization82print("Roots of Unity Analysis:")83for n in [_sage_const_6 , _sage_const_8 , _sage_const_12 , _sage_const_16 ]:84all_roots = n85primitive_roots = euler_phi(n)86print(f"n = {n}: Total {n}-th roots of unity: {all_roots}")87print(f" Primitive {n}-th roots of unity: {primitive_roots}")88print(f" Cyclotomic polynomial Φ_{n}(x) has degree {primitive_roots}")89except:90_st_.goboom(_sage_const_323 )91_st_.blockend()92_st_.current_tex_line = _sage_const_34893_st_.blockbegin()94try:95# Analyze Galois groups for cyclotomic fields96print("Galois Groups of Cyclotomic Fields Q(ζ_n)/Q:")9798galois_data = {}99for n in range(_sage_const_1 , _sage_const_17 ):100# Units group (Z/nZ)*101units_group = Integers(n).unit_group()102group_order = units_group.order()103group_structure = units_group.invariants()104105# Field degree [Q(ζ_n) : Q] = φ(n)106field_degree = euler_phi(n)107108galois_data[n] = {109'field_degree': field_degree,110'group_order': group_order,111'group_structure': group_structure,112'units_group': units_group113}114115print(f"n = {n:2d}: [Q(ζ_{n}) : Q] = {field_degree:2d}, "116f"|Gal| = {group_order:2d}, structure = {group_structure}")117118# Detailed analysis for specific cases119print("\nDetailed Galois group analysis:")120121interesting_cases = [_sage_const_8 , _sage_const_12 , _sage_const_15 , _sage_const_16 , _sage_const_20 ]122for n in interesting_cases:123if n >= len(galois_data):124continue125126units = Integers(n).unit_group()127elements = [a for a in range(_sage_const_1 , n) if gcd(a, n) == _sage_const_1 ]128129print(f"\nn = {n}: Q(ζ_{n})/Q")130print(f" Units (Z/{n}Z)* = {{{', '.join(map(str, elements))}}}")131print(f" Group structure: {units.invariants()}")132print(f" Cyclic: {units.is_cyclic()}")133134# Generator information for cyclic groups135if units.is_cyclic():136# Find a generator137for a in elements:138order = Integers(n)(a).multiplicative_order()139if order == len(elements):140print(f" Generator: {a} (order {order})")141break142except:143_st_.goboom(_sage_const_396 )144_st_.blockend()145_st_.current_tex_line = _sage_const_408146_st_.blockbegin()147try:148# Analyze ramification patterns149print("Ramification Analysis in Cyclotomic Fields:")150151def analyze_ramification(n):152"""Analyze ramification of primes in Q(ζ_n)"""153print(f"\nQ(ζ_{n})/Q ramification:")154155# Get prime divisors of n156n_factorization = factor(n)157ramified_primes = [p for p, e in n_factorization]158159print(f" n = {n} = {n_factorization}")160print(f" Ramified primes: {ramified_primes}")161162# Analyze each small prime163for p in [_sage_const_2 , _sage_const_3 , _sage_const_5 , _sage_const_7 , _sage_const_11 ]:164if p > n:165break166167if p not in ramified_primes:168# Unramified case - compute splitting behavior169if gcd(p, n) == _sage_const_1 :170f = Integers(n)(p).multiplicative_order()171else:172f = "undefined"173print(f" p = {p}: unramified, inertia degree f = {f}")174else:175# Ramified case - find the exponent of p in the factorization176ramification_index = _sage_const_0177for prime, exp in n_factorization:178if prime == p:179ramification_index = exp180break181totally_ramified = ramification_index == _sage_const_1182print(f" p = {p}: ramified (e = {ramification_index}), "183f"totally ramified: {totally_ramified}")184185# Analyze several cyclotomic fields186for n in [_sage_const_8 , _sage_const_12 , _sage_const_15 , _sage_const_20 , _sage_const_24 ]:187analyze_ramification(n)188except:189_st_.goboom(_sage_const_449 )190_st_.blockend()191_st_.current_tex_line = _sage_const_468192_st_.blockbegin()193try:194import os195if not os.path.exists('figures'):196os.makedirs('figures')197198# Demonstrate quadratic reciprocity computations199print("Quadratic Reciprocity Examples:")200201def legendre_symbol(a, p):202"""Compute Legendre symbol (a/p)"""203return kronecker_symbol(a, p)204205def verify_reciprocity(p, q):206"""Verify quadratic reciprocity for primes p, q"""207left_side = legendre_symbol(p, q) * legendre_symbol(q, p)208right_side = (-_sage_const_1 )**((p-_sage_const_1 )//_sage_const_2 * (q-_sage_const_1 )//_sage_const_2 )209return left_side == right_side210211# Test quadratic reciprocity for several prime pairs212prime_pairs = [(_sage_const_3 , _sage_const_5 ), (_sage_const_3 , _sage_const_7 ), (_sage_const_5 , _sage_const_7 ), (_sage_const_7 , _sage_const_11 ), (_sage_const_11 , _sage_const_13 ), (_sage_const_13 , _sage_const_17 )]213214for p, q in prime_pairs:215leg_p_q = legendre_symbol(p, q)216leg_q_p = legendre_symbol(q, p)217product = leg_p_q * leg_q_p218expected = (-_sage_const_1 )**((p-_sage_const_1 )//_sage_const_2 * (q-_sage_const_1 )//_sage_const_2 )219verified = verify_reciprocity(p, q)220221print(f"p = {p}, q = {q}: ({p}/{q}) = {leg_p_q:2d}, ({q}/{p}) = {leg_q_p:2d}")222print(f" Product = {product:2d}, Expected = {expected:2d}, Verified: {verified}")223224# Analysis summary for the visualization225print("\nQuadratic reciprocity visualization generated showing Legendre symbols.")226print("The reciprocity pattern demonstrates the fundamental law:")227print("For distinct odd primes p, q: (p/q)(q/p) = (-1)^((p-1)/2 * (q-1)/2)")228229# Additional analysis of specific cases230print("\nDetailed reciprocity analysis:")231small_primes = [_sage_const_3 , _sage_const_5 , _sage_const_7 , _sage_const_11 , _sage_const_13 ]232for i, p in enumerate(small_primes):233for j, q in enumerate(small_primes):234if i < j: # Only examine pairs once235symbol_pq = legendre_symbol(p, q)236symbol_qp = legendre_symbol(q, p)237print(f"({p}/{q}) = {symbol_pq:2d}, ({q}/{p}) = {symbol_qp:2d}, Product = {symbol_pq * symbol_qp:2d}")238except:239_st_.goboom(_sage_const_513 )240_st_.blockend()241_st_.current_tex_line = _sage_const_524242_st_.blockbegin()243try:244# Investigate cyclotomic class numbers245print("Class Numbers of Cyclotomic Fields:")246247def compute_cyclotomic_info(n):248"""Compute information about the n-th cyclotomic field"""249# For computational feasibility, we focus on small n250if n > _sage_const_20 :251return None252253field_degree = euler_phi(n)254discriminant_factor_count = len([p for p, e in factor(n)])255256return {257'n': n,258'degree': field_degree,259'conductor': n,260'discriminant_complexity': discriminant_factor_count261}262263# Analyze cyclotomic fields264cyclotomic_info = []265for n in range(_sage_const_1 , _sage_const_21 ):266info = compute_cyclotomic_info(n)267if info:268cyclotomic_info.append(info)269270print("Cyclotomic Field Data:")271print("n degree conductor discriminant_complexity")272print("-" * _sage_const_45 )273for info in cyclotomic_info:274print(f"{info['n']:2d} {info['degree']:3d} {info['conductor']:3d} {info['discriminant_complexity']:3d}")275276# Focus on specific interesting cases277interesting_fields = [_sage_const_7 , _sage_const_8 , _sage_const_9 , _sage_const_12 , _sage_const_15 , _sage_const_16 , _sage_const_20 ]278print(f"\nDetailed analysis for selected cyclotomic fields:")279280for n in interesting_fields:281if n <= _sage_const_20 :282phi_n = euler_phi(n)283units_structure = Integers(n).unit_group().invariants()284print(f"Q(ζ_{n}): degree {phi_n}, Gal ≅ {units_structure}")285except:286_st_.goboom(_sage_const_566 )287_st_.blockend()288_st_.current_tex_line = _sage_const_576289_st_.blockbegin()290try:291# Analyze computational complexity of cyclotomic polynomial operations292print("Computational Complexity Analysis:")293294def time_cyclotomic_computation(n_max):295"""Analyze timing for cyclotomic polynomial computations"""296import time297298timing_data = []299300for n in range(_sage_const_1 , min(n_max + _sage_const_1 , _sage_const_101 )): # Limit for computational feasibility301start_time = time.time()302303# Compute cyclotomic polynomial304phi_n = cyclotomic_polynomial(n)305degree = phi_n.degree()306height = max(abs(c) for c in phi_n.coefficients(sparse=False))307308end_time = time.time()309computation_time = end_time - start_time310311timing_data.append({312'n': int(n),313'degree': int(degree),314'height': int(height),315'time': float(computation_time)316})317318if n <= _sage_const_30 or n % _sage_const_10 == _sage_const_0 :319print(f"n = {n:3d}: degree = {degree:3d}, "320f"height = {height:4d}, time = {computation_time:.4f}s")321322return timing_data323324# Perform timing analysis for moderate values325print("Timing analysis for cyclotomic polynomial computation:")326timing_results = time_cyclotomic_computation(_sage_const_50 )327328# Summary analysis of complexity results329print("\nComplexity Analysis Summary:")330print(f"Analyzed cyclotomic polynomials for n = 1 to {len(timing_results)}")331332n_values = [data['n'] for data in timing_results]333degrees = [data['degree'] for data in timing_results]334heights = [data['height'] for data in timing_results]335times = [data['time'] for data in timing_results]336337print(f"Maximum degree observed: {max(degrees)} (for n = {n_values[degrees.index(max(degrees))]})")338print(f"Maximum coefficient height: {max(heights)} (for n = {n_values[heights.index(max(heights))]})")339print(f"Total computation time: {sum(times):.4f} seconds")340341# Highlight some interesting cases342interesting_n = [_sage_const_12 , _sage_const_15 , _sage_const_20 , _sage_const_24 , _sage_const_30 , _sage_const_40 ]343print("\nComplexity for selected values:")344for n in interesting_n:345if n <= len(timing_results):346idx = n - _sage_const_1347print(f"n = {n:2d}: degree = {degrees[idx]:2d}, height = {heights[idx]:3d}, time = {times[idx]:.4f}s")348except:349_st_.goboom(_sage_const_634 )350_st_.blockend()351_st_.endofdoc()352353354355