### Install Nemo Julia Package Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/index.md Instructions to add the Nemo package to a Julia environment using the built-in Pkg manager. This command should be run at the Julia prompt. ```Julia julia> using Pkg; Pkg.add("Nemo") ``` -------------------------------- ### Work with Power Series in Nemo Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/index.md Demonstrates the creation of power series rings over polynomial rings and performs operations such as exact division. This example showcases Nemo's functionality for handling series expansions. ```Julia julia> using Nemo julia> R, x = QQ["x"] (Univariate polynomial ring in x over QQ, x) julia> S, t = power_series_ring(R, 100, "t") (Univariate power series ring over univariate polynomial ring, t + O(t^101)) julia> u = t + O(t^100) t + O(t^100) julia> @time divexact((u*exp(x*u)), (exp(u)-1)); 0.412813 seconds (667.49 k allocations: 33.966 MiB, 90.26% compilation time) ``` -------------------------------- ### Override FLINT Binary Path for Nemo Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/index.md Explains how to override the default FLINT C library binary installation path for Nemo. This configuration is done by adding an entry to the `~/.julia/artifacts/Overrides.toml` file for Julia versions 1.3 or higher. ```TOML [e134572f-a0d5-539d-bddf-3cad8db41a82] FLINT = "/prefix/for/libflint" ``` -------------------------------- ### Perform Generic Recursive Ring Constructions in Nemo Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/index.md Illustrates the construction of complex ring structures, including finite fields, polynomial rings, and residue rings. It demonstrates operations within these nested structures and measures the performance of a resultant computation. ```Julia julia> using Nemo julia> R, x = finite_field(7, 11, "x") (Finite field of degree 11 and characteristic 7, x) julia> S, y = polynomial_ring(R, "y") (Univariate polynomial ring in y over GF(7, 11), y) julia> T, _ = residue_ring(S, y^3 + 3x*y + 1) (Residue ring of univariate polynomial ring modulo y^3 + 3*x*y + 1, Map: univariate polynomial ring -> residue ring) julia> U, z = polynomial_ring(T, "z") (Univariate polynomial ring in z over residue ring, z) julia> f = (3y^2 + y + x)*z^2 + ((x + 2)*y^2 + x + 1)*z + 4x*y + 3; julia> g = (7y^2 - y + 2x + 7)*z^2 + (3y^2 + 4x + 1)*z + (2x + 1)*y + 1; julia> s = f^12; julia> t = (s + g)^12; julia> @time resultant(s, t) 0.059095 seconds (391.89 k allocations: 54.851 MiB, 5.22% gc time) (x^10 + 4*x^8 + 6*x^7 + 3*x^6 + 4*x^5 + x^4 + 6*x^3 + 5*x^2 + x)*y^2 + (5*x^10 + x^8 + 4*x^7 + 3*x^5 + 5*x^4 + 3*x^3 + x^2 + x + 6)*y + 2*x^10 + 6*x^9 + 5*x^8 + 5*x^7 + x^6 + 6*x^5 + 5*x^4 + 4*x^3 + x + 3 ``` -------------------------------- ### Julia: QQFieldElem Basic Manipulation Examples Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/fraction.md Illustrative Julia examples demonstrating basic operations with `QQFieldElem` (rational numbers), such as absolute value and comparison. ```Julia d = abs(ZZ(11)//3) # Output: 11//3 4 <= ZZ(7)//ZZ(3) # Output: false ``` -------------------------------- ### Compute Recursive Univariate Polynomials in Nemo Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/index.md Demonstrates the creation of nested polynomial rings (ZZ, R, S) and computation with recursive univariate polynomials. It shows how to define variables in different rings and perform operations like exponentiation, including performance timing. ```Julia julia> using Nemo julia> R, x = polynomial_ring(ZZ, "x") (Univariate polynomial ring in x over ZZ, x) julia> S, y = polynomial_ring(R, "y") (Univariate polynomial ring in y over univariate polynomial ring, y) julia> T, z = polynomial_ring(S, "z") (Univariate polynomial ring in z over univariate polynomial ring, z) julia> f = x + y + z + 1 z + y + x + 1 julia> p = f^30; # semicolon suppresses output julia> @time q = p*(p+1); 0.161733 seconds (79.42 k allocations: 2.409 MiB) ``` -------------------------------- ### Nemo Module Configuration Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/padic.md Configuration for the Nemo module documentation, setting the current module and defining the setup for doctests to ensure `using Nemo` is available for examples. ```Julia CurrentModule = Nemo DocTestSetup = quote using Nemo end ``` -------------------------------- ### AbstractAlgebra.jl Algebraic Function Examples Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/developer/topics.md Examples demonstrating the algebraic behavior of `sqrt`, `inv`, and `exp` functions in AbstractAlgebra.jl, which return exact results or raise exceptions if an exact result is not possible within the ring. ```Julia AbstractAlgebra.sqrt(4) == 2 AbstractAlgebra.inv(-1) == -1 AbstractAlgebra.exp(0) == 1 ``` -------------------------------- ### Perform Matrix Operations with Polynomial Entries in Nemo Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/index.md Shows how to define a matrix space over a polynomial ring and perform operations like computing the determinant of a large random matrix. This example highlights Nemo's capabilities for linear algebra over abstract rings. ```Julia julia> using Nemo julia> R, x = polynomial_ring(ZZ, "x") (Univariate polynomial ring in x over ZZ, x) julia> S = matrix_space(R, 40, 40) Matrix space of 40 rows and 40 columns over univariate polynomial ring in x over ZZ julia> M = rand(S, 2:2, -20:20); julia> @time det(M); 0.080976 seconds (132.28 k allocations: 23.341 MiB, 4.11% gc time) ``` -------------------------------- ### Example Usage of Euclidean Division Functions in Julia Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/integer.md Demonstrates how to use various Euclidean division functions from Nemo.jl, including `divrem`, `cdiv`, `fdiv`, `tdivpow2`, and `fmodpow2`, with `ZZRingElem` instances. The examples illustrate how to perform different types of division and retrieve quotients and remainders. ```julia a = ZZ(12) 12 b = ZZ(5) 5 q, r = divrem(a, b) (2, 2) c = cdiv(a, b) 3 d = fdiv(a, b) 2 f = tdivpow2(a, 2) 3 g = fmodpow2(a, 3) 4 ``` -------------------------------- ### Example Usage of Comparison Operators in Julia Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/integer.md Illustrates the use of standard comparison operators (`<`, `!=`, `>`, `<=`) and the `cmpabs` function with `ZZRingElem` instances in Nemo.jl. The examples demonstrate how to perform various relational comparisons and compare absolute magnitudes. ```julia a = ZZ(12) 12 b = ZZ(3) 3 a < b false a != b true a > 4 true 5 <= b false cmpabs(a, b) 1 ``` -------------------------------- ### Example Usage of Comparison Operations for AcbFieldElem Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/acb.md Demonstrates the initialization of `AcbField` and `AcbFieldElem` objects, followed by practical examples of `isequal`, `==`, and `!=` operators to perform various comparisons. ```Julia CC = AcbField(64) x = CC("1 +/- 0.001") y = CC("3") z = CC("4") isequal(x, deepcopy(x)) x == 3 ZZ(3) == z x != 1.23 ``` -------------------------------- ### Example Usage of Bit Shifting Operators in Julia Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/integer.md Provides practical examples of using the left (`<<`) and right (`>>`) bit shifting operators with `ZZRingElem` in Nemo.jl. The examples demonstrate how integer values are transformed by shifting their bits, illustrating the effect of these operations. ```julia a = ZZ(12) 12 a << 3 96 a >> 5 0 ``` -------------------------------- ### Override FLINT C Library Location in Overrides.toml Source: https://github.com/nemocas/nemo.jl/blob/master/README.maintainer.md Configuration for `Overrides.toml` to specify a custom installation path for the FLINT C library. Replace `/usr/local` with the actual installation directory. This entry uses the UUID associated with `FLINT_jll`. ```TOML [e134572f-a0d5-539d-bddf-3cad8db41a82] FLINT = "/usr/local" ``` -------------------------------- ### Examples of Basic P-adic Field Manipulation in Julia Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/padic.md Demonstrates the usage of `prime`, `precision`, `valuation`, and `lift` functions on p-adic field elements. These examples show how to extract the prime of the field, the precision of an element, its p-adic valuation, and how to convert p-adic elements back to integer or rational types. ```Julia julia> R = padic_field(7, precision = 30) Field of 7-adic numbers julia> a = 1 + 2*7 + 4*7^2 + O(R, 7^3) 7^0 + 2*7^1 + 4*7^2 + O(7^3) julia> b = 7^2 + 3*7^3 + O(R, 7^5) 7^2 + 3*7^3 + O(7^5) julia> c = R(2) 2*7^0 + O(7^30) julia> k = precision(a) 3 julia> m = prime(R) 7 julia> n = valuation(b) 2 julia> p = lift(ZZ, a) 211 julia> q = lift(QQ, divexact(a, b)) 337//49 ``` -------------------------------- ### Override Antic C Library Location in Overrides.toml Source: https://github.com/nemocas/nemo.jl/blob/master/README.maintainer.md Configuration for `Overrides.toml` to specify a custom installation path for the Antic C library. Replace `/usr/local` with the actual installation directory. This entry uses the UUID associated with `Antic_jll`. ```TOML [e21ec000-9f72-519e-ba6d-10061e575a27] Antic = "/usr/local" ``` -------------------------------- ### Example Usage of Puiseux Series in Julia Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/puiseux.md Demonstrates the creation of a Puiseux series ring over integers, defining a sample series, and applying sqrt and eta_qexp functions to it. ```Julia S, z = puiseux_series_ring(ZZ, 30, "z") a = 1 + z + 3z^2 + O(z^5) h = sqrt(a^2) k = eta_qexp(z) ``` -------------------------------- ### Example: Scaling ZZMatrix using Bit Shift Operators Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/matrix.md Illustrates how to use the bit shift operators `<<` and `>>` to scale a `ZZMatrix` by an integer, demonstrating multiplication and division by powers of 2. ```julia A = ZZ[2 3 5; 1 4 7; 9 6 3] B = A<<5 C = B>>2 ``` -------------------------------- ### Example: Creating a Real Ball using `ball` Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/arb.md Illustrates the use of the `ball` constructor to create a real ball by providing a midpoint and a radius as `ArbFieldElem` types, demonstrating the resulting interval representation. ```Julia RR = ArbField(64) c = ball(RR(3), RR("0.0001")) ``` -------------------------------- ### Work with Gaussian Integers in Nemo.jl Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/integer.md Examples demonstrating the creation, manipulation, and properties of Gaussian integers in Nemo.jl, including ring initialization, arithmetic operations, unit testing, factorization, and absolute square calculation. ```Julia julia> ZZi = Nemo.GaussianIntegers() Gaussian integer ring julia> a = ZZ(5)*im 5*im julia> b = ZZi(3, 4) 3 + 4*im julia> is_unit(a) false julia> factor(a) im * (2 - im) * (2 + im) julia> a//b 4//5 + 3//5*im julia> abs2(a//b) 1 ``` -------------------------------- ### Examples of Special P-adic Field Functions in Julia Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/padic.md Demonstrates the use of `exp`, `log`, and `teichmuller` functions on p-adic field elements. These examples showcase their application to various p-adic numbers and illustrate the resulting p-adic values. ```Julia julia> R = padic_field(7, precision = 30) Field of 7-adic numbers julia> a = 1 + 7 + 2*7^2 + O(R, 7^3) 7^0 + 7^1 + 2*7^2 + O(7^3) julia> b = 2 + 5*7 + 3*7^2 + O(R, 7^3) 2*7^0 + 5*7^1 + 3*7^2 + O(7^3) julia> c = 3*7 + 2*7^2 + O(R, 7^5) 3*7^1 + 2*7^2 + O(7^5) julia> c = exp(c) 7^0 + 3*7^1 + 3*7^2 + 4*7^3 + 4*7^4 + O(7^5) julia> d = log(a) 7^1 + 5*7^2 + O(7^3) julia> c = exp(R(0)) 7^0 + O(7^30) julia> d = log(R(1)) O(7^30) julia> f = teichmuller(b) 2*7^0 + 4*7^1 + 6*7^2 + O(7^3) ``` -------------------------------- ### Julia: Example of computing a finite field embedding Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/ff_embedding.md This Julia example demonstrates how to create a finite field embedding using both the `embed` function and direct type conversion. It initializes two finite fields (`k2` and `k4`) and shows how an element from `k2` can be embedded into `k4`, illustrating the resulting `FinFieldMorphism`. ```julia julia> k2, x2 = finite_field(19, 2, "x2") (Finite field of degree 2 and characteristic 19, x2) julia> k4, x4 = finite_field(19, 4, "x4") (Finite field of degree 4 and characteristic 19, x4) julia> f = embed(k2, k4) Morphism of finite fields from finite field of degree 2 and characteristic 19 to finite field of degree 4 and characteristic 19 julia> y = f(x2) 6*x4^3 + 5*x4^2 + 9*x4 + 17 julia> z = k4(x2) 6*x4^3 + 5*x4^2 + 9*x4 + 17 ``` -------------------------------- ### Override Arb C Library Location in Overrides.toml Source: https://github.com/nemocas/nemo.jl/blob/master/README.maintainer.md Configuration for `Overrides.toml` to specify a custom installation path for the Arb C library. Replace `/usr/local` with the actual installation directory. This entry uses the UUID associated with `Arb_jll`. ```TOML [d9960996-1013-53c9-9ba4-74a4155039c3] Arb = "/usr/local" ``` -------------------------------- ### Julia Example: Basic Operations on Nemo Integers Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/integer.md Illustrates the creation of a `ZZRingElem` and the application of various basic manipulation functions like `is_unit`, `sign`, `size`, `fits`, `numerator`, and `denominator`. ```Julia a = ZZ(12) is_unit(a) sign(a) s = size(a) fits(Int, a) n = numerator(a) d = denominator(a) ``` -------------------------------- ### Override Calcium C Library Location in Overrides.toml Source: https://github.com/nemocas/nemo.jl/blob/master/README.maintainer.md Configuration for `Overrides.toml` to specify a custom installation path for the Calcium C library. Replace `/usr/local` with the actual installation directory. This entry uses the UUID associated with `Calcium_jll`. ```TOML [fcfa6d1b-d8ce-59d5-8c0a-c0d7f69e4f40] Calcium = "/usr/local" ``` -------------------------------- ### Example: Apply Bit Shifting to a Nemo Matrix Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/matrix.md This example illustrates the use of the "ldexp" function to perform bit shifting on a Nemo real matrix. It shows how to initialize a matrix, apply the shift, and then verify the result using the "overlaps" function, which checks for numerical overlap between two matrices. ```Julia RR = RealField() A = RR[1 2 3; 4 5 6; 7 8 9] B = ldexp(A, 4) overlaps(16*A, B) ``` -------------------------------- ### Example: Modular Reduction of ZZMatrix Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/matrix.md Illustrates how to apply `reduce_mod` to a `ZZMatrix` using both an integer and a `ZZRingElem` as the modulus, demonstrating element-wise modular arithmetic. ```julia A = ZZ[2 3 5; 1 4 7; 9 2 2] reduce_mod(A, ZZ(5)) reduce_mod(A, 2) ``` -------------------------------- ### Julia Example: Calculating Norm and Trace of a Number Field Element Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/numberfield.md This example demonstrates how to define a polynomial ring and a number field, create an element within that field, and then compute its norm and trace using the `norm` and `tr` functions from Nemo.jl. ```Julia R, x = polynomial_ring(QQ, "x") K, a = number_field(x^3 + 3x + 1, "a") c = 3a^2 - a + 1 d = norm(c) f = tr(c) ``` -------------------------------- ### Example: Compute Eigenvalues of Complex Matrices in Nemo.jl Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/matrix.md This example demonstrates the usage of experimental eigenvalue functions in Nemo.jl for complex matrices. It shows how to compute simple eigenvalues for a triangular matrix and then how to find all eigenvalues and their multiplicities for a matrix with repeated eigenvalues. ```Julia CC = ComplexField() A = CC[1 2 3; 0 4 5; 0 0 6] eigenvalues_simple(A) A = CC[2 2 3; 0 2 5; 0 0 2] eigenvalues(A) eigenvalues_with_multiplicities(A) ``` -------------------------------- ### Examples of Basic Real Ball Manipulation Functions (Julia) Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/real.md Provides practical examples demonstrating the usage of various basic manipulation functions on `RealFieldElem` objects. It shows how to check properties like positivity, finiteness, and integer status, and how to extract the radius, midpoint, and accuracy bits from real balls. ```julia RR = RealField() Real field a = RR("1.2 +/- 0.001") [1.20 +/- 1.01e-3] b = RR(3) 3.0000000000000000000 is_positive(a) true isfinite(b) true isinteger(b) true is_negative(a) false c = radius(a) [0.0010000000038417056203 +/- 1.12e-23] d = midpoint(b) 3.0000000000000000000 f = accuracy_bits(a) 9 ``` -------------------------------- ### Nemo Internal divrem Behavior Example Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/developer/topics.md Shows an example of how Nemo.divrem behaves differently from Julia's base divrem when used internally within Nemo. This reflects Nemo's choice to use div, mod, and divrem as a consistent triple for Euclidean division, with mod aligning with FLINT's definition. ```Julia Nemo.divrem(-1, 3) == (-1, 2) ``` -------------------------------- ### Example: Lift Matrix Elements in Julia Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/matrix.md Demonstrates how to use the `lift` function to convert a matrix from a residue ring to an integer matrix in Julia. ```Julia julia> R, = residue_ring(ZZ, 7) (Integers modulo 7, Map: ZZ -> ZZ/(7)) julia> a = R[4 5 6; 7 3 2; 1 4 5] [4 5 6] [0 3 2] [1 4 5] julia> b = lift(a) [-3 -2 -1] [ 0 3 2] [ 1 -3 -2] ``` -------------------------------- ### Example: Converting ArbFieldElem to Float64 Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/arb.md Shows how to convert an `ArbFieldElem` (a real ball) to a standard `Float64` type, demonstrating the conversion of a rational number represented as a real ball. ```Julia RR = ArbField(64) convert(Float64, RR(1//3)) ``` -------------------------------- ### Example: Calculate Infinite Norm of a Real Matrix in Nemo.jl Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/matrix.md This example demonstrates how to initialize a real matrix using "RealField()" and "RR[]" syntax in Nemo.jl and then apply the "bound_inf_norm" function to calculate its infinite norm. The output shows the resulting bounded value. ```Julia RR = RealField() A = RR[1 2 3; 4 5 6; 7 8 9] d = bound_inf_norm(A) ``` -------------------------------- ### Example: Perform LLL Lattice Basis Reduction in Julia Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/matrix.md Demonstrates how to apply LLL lattice basis reduction to an integer matrix using various `lll` functions, including obtaining transformation matrices and working with Gram matrices. ```Julia julia> A = ZZ[2 3 5; 1 4 7; 19 3 7] [ 2 3 5] [ 1 4 7] [19 3 7] julia> L = lll(A, LLLContext(0.95, 0.55, :zbasis, :approx)) [-1 1 2] [-1 -2 2] [ 4 1 1] julia> L, T = lll_with_transform(A) ([-1 1 2; -1 -2 2; 4 1 1], [-1 1 0; -15 10 1; 3 -2 0]) julia> G = lll_gram(gram(A)) [ 6 3 -1] [ 3 9 -4] [-1 -4 18] julia> G, T = lll_gram_with_transform(gram(A)) ([6 3 -1; 3 9 -4; -1 -4 18], [-1 1 0; -15 10 1; 3 -2 0]) julia> r, L = lll_with_removal(A, ZZ(100)) (3, [-1 1 2; -1 -2 2; 4 1 1]) julia> r, L, T = lll_with_removal_transform(A, ZZ(100)) (3, [-1 1 2; -1 -2 2; 4 1 1], [-1 1 0; -15 10 1; 3 -2 0]) ``` -------------------------------- ### Example: Calculating Determinant of ZZMatrix Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/matrix.md Demonstrates how to use `det_divisor` to find a divisor of a `ZZMatrix`'s determinant and then `det_given_divisor` to compute the actual determinant using that divisor. ```julia A = ZZ[2 3 5; 1 4 7; 9 6 3] c = det_divisor(A) d = det_given_divisor(A, c) ``` -------------------------------- ### Example: Constructing Number Fields in Julia Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/numberfield.md Demonstrates how to create various types of number fields (simple, cyclotomic, real subfield) and coerce elements into them using Nemo.jl. ```julia R, x = polynomial_ring(QQ, "x") (Univariate polynomial ring in x over QQ, x) K, a = number_field(x^3 + 3x + 1, "a") (Number field of degree 3 over QQ, a) L, b = cyclotomic_field(5, "b") (Cyclotomic field of order 5, b) M, c = cyclotomic_real_subfield(5, "c") (Maximal real subfield of cyclotomic field of order 5, c) d = K(3) 3 f = L(b) b g = L(ZZ(11)) 11 h = L(ZZ(11)//3) 11//3 k = M(x) c ``` -------------------------------- ### Example: Basic Manipulation of Real Balls Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/arb.md Demonstrates the usage of various basic manipulation functions like `is_positive`, `isfinite`, `isinteger`, `is_negative`, `radius`, `midpoint`, and `accuracy_bits` on `ArbFieldElem` instances, showing their typical outputs. ```Julia RR = ArbField(64) a = RR("1.2 +/- 0.001") b = RR(3) is_positive(a) isfinite(b) isinteger(b) is_negative(a) c = radius(a) d = midpoint(b) f = accuracy_bits(a) ``` -------------------------------- ### Constructing P-adic Fields and Elements in Julia Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/padic.md Examples demonstrating how to create p-adic fields using `padic_field` with a specified prime and precision. It also shows how to coerce various integer and rational numbers into these newly constructed p-adic fields. ```Julia julia> R = padic_field(7, precision = 30) Field of 7-adic numbers julia> S = padic_field(ZZ(65537), precision = 30) Field of 65537-adic numbers julia> a = R() O(7^30) julia> b = S(1) 65537^0 + O(65537^30) julia> c = S(ZZ(123)) 123*65537^0 + O(65537^30) julia> d = R(ZZ(1)//7^2) 7^-2 + O(7^28) ``` -------------------------------- ### Example: Constructing Number Field Elements in Julia Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/numberfield.md Illustrates how to obtain the generator of a number field and construct elements using arithmetic with the generator. ```julia R, x = polynomial_ring(QQ, "x") (Univariate polynomial ring in x over QQ, x) K, a = number_field(x^3 + 3x + 1, "a") (Number field of degree 3 over QQ, a) d = gen(K) a f = a^2 + 2a - 7 a^2 + 2*a - 7 ``` -------------------------------- ### Example: Create and Check Special Matrices in Julia Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/matrix.md Illustrates the creation of Hadamard and Hilbert matrices and checking the Hadamard property using `hadamard`, `is_hadamard`, and `hilbert` functions in Julia. ```Julia julia> hadamard(matrix_space(ZZ, 3, 3)) ERROR: Unable to create Hadamard matrix [...] julia> A = hadamard(matrix_space(ZZ, 4, 4)) [1 1 1 1] [1 -1 1 -1] [1 1 -1 -1] [1 -1 -1 1] julia> is_hadamard(A) true julia> B = hilbert(matrix_space(QQ, 3, 3)) [ 1 1//2 1//3] [1//2 1//3 1//4] [1//3 1//4 1//5] ``` -------------------------------- ### Factorizing an integer using Nemo.jl Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/factor.md This example demonstrates how to use the `factor` function in Nemo.jl to factorize a large integer. It shows how to retrieve the unit, iterate through the prime factors and their exponents, and check for the presence of a specific factor and its corresponding exponent within the factorization. ```Julia julia> fac = factor(ZZ(-6000361807272228723606)) -1 * 2 * 229^3 * 43669^3 * 3 julia> unit(fac) -1 julia> -6000361807272228723606 == unit(fac) * prod([ p^e for (p, e) in fac]) true julia> for (p, e) in fac; println("$p $e"); end 2 1 229 3 43669 3 3 1 julia> 229 in fac true julia> fac[229] 3 ``` -------------------------------- ### Example: Check Predicates for Nemo Complex Matrices Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/matrix.md This example demonstrates how to use predicate functions like "isreal" on Nemo complex matrices. It shows how to initialize a complex matrix and then test if it contains only real numbers, including a case where it's explicitly made non-real by multiplication with an imaginary unit. ```Julia CC = ComplexField() A = CC[1 2 3; 4 5 6; 7 8 9] isreal(A) isreal(onei(CC)*A) ``` -------------------------------- ### Example: Compute Howell Form in Julia Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/matrix.md Demonstrates how to compute the Howell form of a matrix over a residue ring using `howell_form`. ```Julia julia> R, = residue_ring(ZZ, 12); julia> A = R[4 1 0; 0 0 5; 0 0 0 ] [4 1 0] [0 0 5] [0 0 0] julia> B = howell_form(A) [4 1 0] [0 3 0] [0 0 1] ``` -------------------------------- ### Example: Using Comparison Operators with Nemo Real Matrices Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/matrix.md Demonstrates the usage of `overlaps` and `contains` functions with `RealMatrix` types in Nemo, showing how to check for overlap and containment between matrices. ```julia RR = RealField() C = RR[1 2; 3 4] D = RR["1 +/- 0.1" "2 +/- 0.1"; "3 +/- 0.1" "4 +/- 0.1"] overlaps(C, D) contains(D, C) ``` -------------------------------- ### Perform Basic Arithmetic Operations with Nemo.jl Algebraic Numbers Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/algebraic.md This example demonstrates basic arithmetic operations on `QQBarFieldElem` instances in Nemo.jl. It shows conversion from algebraic numbers to `ZZRingElem` and `QQFieldElem`, and complex exponentiation. ```julia ZZRingElem(QQBar(3)) 3 QQFieldElem(QQBar(3) // 2) 3//2 QQBar(-1) ^ (QQBar(1) // 3) Root 0.500000 + 0.866025*im of x^2 - x + 1 ``` -------------------------------- ### Calculating Roots and Trigonometric Functions for Algebraic Numbers in Julia Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/algebraic.md Examples demonstrating how to compute roots (e.g., root(QQBar(2), 5)), trigonometric functions (sinpi, tanpi), and properties of roots of unity (root_of_unity, is_root_of_unity, root_of_unity_as_args) for algebraic numbers. ```julia root(QQBar(2), 5) Root 1.14870 of x^5 - 2 sinpi(QQBar(7) // 13) Root 0.992709 of 4096x^12 - 13312x^10 + 16640x^8 - 9984x^6 + 2912x^4 - 364x^2 + 13 tanpi(atanpi(sqrt(QQBar(2)) + 1)) Root 2.41421 of x^2 - 2x - 1 root_of_unity(QQBar, 5) Root 0.309017 + 0.951057*im of x^4 + x^3 + x^2 + x + 1 root_of_unity(QQBar, 5, 4) Root 0.309017 - 0.951057*im of x^4 + x^3 + x^2 + x + 1 w = (1 - sqrt(QQBar(-3)))//2 Root 0.500000 - 0.866025*im of x^2 - x + 1 is_root_of_unity(w) true is_root_of_unity(w + 1) false root_of_unity_as_args(w) (6, 5) ``` -------------------------------- ### Julia: Example of `evaluate2` for Real Polynomials Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/polynomial.md Demonstrates how to use the `evaluate2` function in Julia with `RealPolyRingElem`. It shows the creation of a real polynomial ring, defining a polynomial, and evaluating it at an interval, returning two values. ```Julia RR = RealField() T, z = polynomial_ring(RR, "z") h = z^2 + 2z + 1 s, t = evaluate2(h, RR("2.0 +/- 0.1")) ``` -------------------------------- ### Julia Example: Using gcdx with ZZModRingElem in Nemo Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/residue.md This Julia code example demonstrates how to create a residue ring with a large integer modulus using residue_ring(ZZ, ...). It then illustrates the application of the gcdx function to two elements within this ring, showing how to obtain the greatest common divisor and the corresponding Bezout coefficients. ```julia R, = residue_ring(ZZ, 123456789012345678949); g, s, t = gcdx(R(123), R(456)) ``` -------------------------------- ### Example: Compute Strong Echelon Form in Julia Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/matrix.md Demonstrates how to compute the strong echelon form of a matrix over a residue ring using `strong_echelon_form`. ```Julia julia> R, = residue_ring(ZZ, 12); julia> A = R[4 1 0; 0 0 5; 0 0 0 ] [4 1 0] [0 0 5] [0 0 0] julia> B = strong_echelon_form(A) [4 1 0] [0 3 0] [0 0 1] ``` -------------------------------- ### Generate Random Integers in Nemo.jl Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/integer.md Examples demonstrating how to generate random integers and random prime integers with specified bit lengths using rand_bits and rand_bits_prime functions in Nemo.jl. ```Julia a = rand_bits(ZZ, 23) b = rand_bits_prime(ZZ, 7) ``` -------------------------------- ### Julia Example: Using onei to Get Imaginary Unit Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/acb.md This Julia example illustrates the usage of the `onei` function. It first creates an `AcbField` with 64-bit precision and then calls `onei` on this field to obtain and display the imaginary unit `i` within that complex field. ```julia CC = AcbField(64) Complex Field with 64 bits of precision and error bounds c = onei(CC) 1.0000000000000000000*im ``` -------------------------------- ### Configure Julia Documenter.jl Meta Block Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/series.md This snippet defines a Documenter.jl meta block. It sets 'Nemo' as the current module for documentation and includes a 'DocTestSetup' block that executes 'using Nemo' before running any doctests. This ensures the 'Nemo' package is available for examples within the documentation. ```Julia @meta\nCurrentModule = Nemo\nDocTestSetup = quote\n using Nemo\nend ``` -------------------------------- ### Julia: Polynomial Factorization Example Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/polynomial.md Demonstrates polynomial factorization functions, including `factor`, `factor_squarefree`, and `factor_distinct_deg`, over a residue ring. It shows how to obtain the full factorization and how `factor_distinct_deg` groups factors by the degree of their irreducible components. ```Julia julia> R, = residue_ring(ZZ, 23) (Integers modulo 23, Map: ZZ -> ZZ/(23)) julia> S, x = polynomial_ring(R, "x") (Univariate polynomial ring in x over ZZ/(23), x) julia> f = x^2 + 2x + 1 x^2 + 2*x + 1 julia> g = x^3 + 3x + 1 x^3 + 3*x + 1 julia> R = factor(f*g) 1 * (x + 1)^2 * (x^3 + 3*x + 1) julia> S = factor_squarefree(f*g) 1 * (x + 1)^2 * (x^3 + 3*x + 1) julia> T = factor_distinct_deg((x + 1)*g*(x^5+x^3+x+1)) Dict{Int64, zzModPolyRingElem} with 3 entries: 4 => x^4 + 7*x^3 + 4*x^2 + 5*x + 13 3 => x^3 + 3*x + 1 1 => x^2 + 17*x + 16 ``` -------------------------------- ### Example Usage of Absolute Value for AcbFieldElem Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/acb.md Illustrates how to compute the absolute value of an `AcbFieldElem` object using the `abs` function in Nemo.jl, showing the setup of a complex field and the result. ```Julia CC = AcbField(64) x = CC("-1 +/- 0.001") a = abs(x) ``` -------------------------------- ### Demonstrate Special Functions on Power Series in Julia Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/series.md This snippet illustrates how to perform various mathematical operations on power series defined over rational numbers (QQ) using the Nemo.jl library in Julia. It includes examples of initializing a power series ring, defining power series, and applying functions like `divexact`, `exp`, `log`, `sqrt`, `sin`, and `atanh` to them. ```Julia T, z = power_series_ring(QQ, 30, "z") (Univariate power series ring over QQ, z + O(z^31)) a = 1 + z + 3z^2 + O(z^5) 1 + z + 3*z^2 + O(z^5) b = z + 2z^2 + 5z^3 + O(z^5) z + 2*z^2 + 5*z^3 + O(z^5) d = divexact(z, exp(z + O(z^40)) - 1) 1 - 1//2*z + 1//12*z^2 - 1//720*z^4 + 1//30240*z^6 - 1//1209600*z^8 + 1//47900160*z^10 - 691//1307674368000*z^12 + 1//74724249600*z^14 - 3617//10670622842880000*z^16 + 43867//5109094217170944000*z^18 - 174611//802857662698291200000*z^20 + 77683//14101100039391805440000*z^22 - 236364091//1693824136731743669452800000*z^24 + 657931//186134520519971831808000000*z^26 - 3392780147//37893265687455865519472640000000*z^28 + O(z^29) f = exp(b) 1 + z + 5//2*z^2 + 43//6*z^3 + 193//24*z^4 + O(z^5) g = log(a) z + 5//2*z^2 - 8//3*z^3 - 7//4*z^4 + O(z^5) h = sqrt(a) 1 + 1//2*z + 11//8*z^2 - 11//16*z^3 - 77//128*z^4 + O(z^5) k = sin(b) z + 2*z^2 + 29//6*z^3 - z^4 + O(z^5) m = atanh(b) z + 2*z^2 + 16//3*z^3 + 2*z^4 + O(z^5) ``` -------------------------------- ### Using Big-O Notation in P-adic Field Construction in Julia Source: https://github.com/nemocas/nemo.jl/blob/master/docs/src/padic.md Examples illustrating the use of big-O notation to define p-adic numbers with specific precision. It demonstrates how to combine integer and rational components with an O(p^n) term to construct p-adic values. ```Julia julia> R = padic_field(7, precision = 30) Field of 7-adic numbers julia> S = padic_field(ZZ(65537), precision = 30) Field of 65537-adic numbers julia> c = 1 + 2*7 + 4*7^2 + O(R, 7^3) 7^0 + 2*7^1 + 4*7^2 + O(7^3) julia> d = 13 + 357*ZZ(65537) + O(S, ZZ(65537)^12) 13*65537^0 + 357*65537^1 + O(65537^12) julia> f = ZZ(1)//7^2 + ZZ(2)//7 + 3 + 4*7 + O(R, 7^2) 7^-2 + 2*7^-1 + 3*7^0 + 4*7^1 + O(7^2) ```