### Run Tutorial Example Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/interfaces/sage/interfaces/maxima.html Executes a basic arithmetic example from the Maxima tutorial. ```sage sage: from sage.interfaces.maxima import maxima sage: maxima('1/100 + 1/101') 201/10100 ``` ```python >>> from sage.all import * >>> from sage.interfaces.maxima import maxima >>> maxima('1/100 + 1/101') 201/10100 ``` -------------------------------- ### Get Mathematica Installation Hints Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/interfaces/sage/interfaces/mathematica.html Use this function to get more information on how to install and configure Mathematica for use with Sage. This is useful for troubleshooting setup issues. ```python from sage.all import * print(mathematica._install_hints()) ``` -------------------------------- ### Get Example Well-Generated Finite Complex Reflection Group Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/categories/sage/categories/finite_complex_reflection_groups.html Retrieves an example of a finite well-generated complex reflection group from the category. This may require GAP3 to be installed. ```python W = C.example(); W # optional - gap3 ``` ```python from sage.all import * W = C.example(); W # optional - gap3 ``` -------------------------------- ### Method example() Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/repl/sage/repl/rich_output/output_video.html Constructs a sample video output container for testing purposes. ```APIDOC ## Method example() ### Description Construct a sample video output container. This static method is meant for doctests. ### Response - **Output** (instance) - An instance of the class on which this method is called. ``` -------------------------------- ### Initialize QSystem Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/algebras/sage/algebras/q_system.html Example of initializing a QSystem object. ```python >>> Q = QSystem(QQ, ['D',Integer(4),Integer(3)], twisted=True) >>> Q.cartan_type() ['G', 2, 1]^* relabelled by {0: 0, 1: 2, 2: 1} ``` -------------------------------- ### Get an example element from InfiniteEnumeratedSets Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/categories/sage/categories/examples/infinite_enumerated_sets.html Use this to obtain a representative element from the InfiniteEnumeratedSets category. This is often used as a starting point for further operations. ```sage InfiniteEnumeratedSets().example().an_element() ``` ```python from sage.all import * InfiniteEnumeratedSets().example().an_element() ``` -------------------------------- ### Initialize Sphinx project Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/thematic_tutorials/sws2rst.html Run the interactive setup tool to configure documentation generation. ```bash $ sphinx-quickstart ``` -------------------------------- ### Get Defining Polynomial of Splitting Algebra Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/algebras/sage/algebras/splitting_algebra.html Retrieves the defining polynomial of a SplittingAlgebra. This example shows the setup using LaurentPolynomialRing and polygen. ```python from sage.all import * from sage.algebras.splitting_algebra import SplittingAlgebra L = LaurentPolynomialRing(ZZ, names=('u', 'v', 'w',)); (u, v, w,) = L._first_ngens(3) x = polygen(L) S = SplittingAlgebra(x**Integer(3) - u*x**Integer(2) + v*x - w, ('X', 'Y')) S.defining_polynomial() ``` -------------------------------- ### Get Order of Binary Dihedral Group (Python) Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/groups/sage/groups/matrix_gps/binary_dihedral.html This Python example demonstrates how to obtain the order of a Binary Dihedral Group using SageMath's library. Ensure SageMath is installed and imported. ```python from sage.all import * G = groups.matrix.BinaryDihedral(Integer(3)) G.order() ``` -------------------------------- ### Create Partitions Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/combinat/sage/combinat/partition.html Examples of creating partitions using different constructors and inputs. ```Sage sage: Partition([3,2,1]) [3, 2, 1] sage: Partition(exp=[2,1,1]) [3, 2, 1, 1] sage: Partition(core=[2,1], quotient=[[2,1],[3],[1,1,1]]) [11, 5, 5, 3, 2, 2, 2] sage: Partition(frobenius_coordinates=([3,2],[4,0])) [4, 4, 1, 1, 1] sage: Partitions().from_zero_one([1, 1, 1, 1, 0, 1, 0]) [5, 4] sage: [2,1] in Partitions() True sage: [2,1,0] in Partitions() True sage: Partition([1,2,3]) Traceback (most recent call last): ... ValueError: [1, 2, 3] is not an element of Partitions ``` ```Python >>> from sage.all import * >>> Partition([Integer(3),Integer(2),Integer(1)]) [3, 2, 1] >>> Partition(exp=[Integer(2),Integer(1),Integer(1)]) [3, 2, 1, 1] >>> Partition(core=[Integer(2),Integer(1)], quotient=[[Integer(2),Integer(1)],[Integer(3)],[Integer(1),Integer(1),Integer(1)]]) [11, 5, 5, 3, 2, 2, 2] >>> Partition(frobenius_coordinates=([Integer(3),Integer(2)],[Integer(4),Integer(0)])) [4, 4, 1, 1, 1] >>> Partitions().from_zero_one([Integer(1), Integer(1), Integer(1), Integer(1), Integer(0), Integer(1), Integer(0)]) [5, 4] >>> [Integer(2),Integer(1)] in Partitions() True >>> [Integer(2),Integer(1),Integer(0)] in Partitions() True >>> Partition([Integer(1),Integer(2),Integer(3)]) Traceback (most recent call last): ... ValueError: [1, 2, 3] is not an element of Partitions ``` -------------------------------- ### Get Example of Finite HTrivial Semigroup Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/categories/sage/categories/semigroups.html This code attempts to get an example of a finite H-trivial semigroup. Note that this is currently not implemented. ```python from sage.all import * Semigroups().HTrivial().Finite().example() ``` -------------------------------- ### Initialize Module and Basis Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/tensor_free_modules/sage/tensor/modules/free_module_alt_form.html Setup for the module and basis used in subsequent examples. ```python >>> M = FiniteRankFreeModule(ZZ, Integer(3), name='M', start_index=Integer(1)) >>> e = M.basis('e') ``` -------------------------------- ### Initialize Sphinx documentation Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/thematic_tutorials/_sources/sws2rst.rst.txt Open a Sage shell session and run the Sphinx quickstart utility to configure the documentation project. ```console $ sage --sh ``` ```console $ sphinx-quickstart ``` -------------------------------- ### Get Quotient Module W in Sage (Initial Example) Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/modules/sage/modules/fg_pid/fgp_module.html This example shows how to get the submodule W when a module Q is constructed as a quotient V/W. It's a foundational example for understanding quotient modules. ```sage sage: V = span([[1/2,1,1], [3/2,2,1], [0,0,1]], ZZ) sage: W = V.span([2*V.0 + 4*V.1, 9*V.0 + 12*V.1, 4*V.2]) sage: Q = V/W sage: Q.V() Free module of degree 3 and rank 3 over Integer Ring Echelon basis matrix: [1/2 0 0] [ 0 1 0] [ 0 0 1] ``` -------------------------------- ### Initialize and List Partition Diagrams Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/algebras/sage/combinat/diagram_algebras.html Demonstrates creating a partition diagram object of a specific order and listing its elements. ```SageMath >>> pd = da.PartitionDiagrams(Integer(3)/Integer(2)); pd Partition diagrams of order 3/2 >>> pd.list() [ {{-2, -1, 1, 2}}, {{-2, 1, 2}, {-1}}, {{-2, 2}, {-1, 1}}, {{-2, -1, 2}, {1}}, {{-2, 2}, {-1}, {1}}] ``` -------------------------------- ### Get an example of a complex reflection group Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/categories/sage/categories/complex_reflection_groups.html Call the example() method on ComplexReflectionGroups to get a sample complex reflection group. This requires the sage.combinat module. ```python from sage.categories.complex_reflection_groups import ComplexReflectionGroups ComplexReflectionGroups().example() ``` ```python from sage.all import * from sage.categories.complex_reflection_groups import ComplexReflectionGroups ComplexReflectionGroups().example() # needs sage.combinat ``` -------------------------------- ### Instantiate PrimeNumbers Example (Wrapper) Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/categories/sage/categories/examples/sets_cat.html Instantiates the PrimeNumbers example using the wrapper implementation. This is a setup step for further examples. ```sage P = Sets().example("wrapper") ``` ```python P = Sets().example("wrapper") ``` -------------------------------- ### SageCustomizations.run_init() Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/repl/genindex-R.html Handles the initialization process for Sage customizations. ```APIDOC ## SageCustomizations.run_init() ### Description Handles the initialization process for Sage customizations. ### Method (Not specified, likely internal) ### Endpoint (Not applicable, this is a method call) ### Parameters (Parameters not specified in the provided text) ### Request Example (Not applicable) ### Response (Response details not specified in the provided text) ``` -------------------------------- ### Initialize and serialize PartitionAlgebra_pk Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/algebras/sage/combinat/partition_algebra.html Demonstrates creating an instance of PartitionAlgebra_pk and verifying its picklability. ```Sage sage: from sage.combinat.partition_algebra import * sage: p = PartitionAlgebra_pk(QQ, 3, 1) sage: p == loads(dumps(p)) True ``` ```Python >>> from sage.all import * >>> from sage.combinat.partition_algebra import * >>> p = PartitionAlgebra_pk(QQ, Integer(3), Integer(1)) >>> p == loads(dumps(p)) True ``` -------------------------------- ### Instantiate PrimeNumbers Example (Inherits) Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/categories/sage/categories/examples/sets_cat.html Instantiates the PrimeNumbers example using the inherits implementation. This is a setup step for further examples. ```sage P = Sets().example("inherits") ``` ```python P = Sets().example("inherits") ``` -------------------------------- ### Instantiate PrimeNumbers Example (Facade) Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/categories/sage/categories/examples/sets_cat.html Instantiates the PrimeNumbers example using the facade implementation. This is a setup step for further examples. ```sage P = Sets().example("facade") ``` ```python P = Sets().example("facade") ``` -------------------------------- ### Generate Quicktime Video Example Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/repl/sage/repl/rich_output/output_video.html Create an example instance of the Quicktime video output class. ```sage sage: from sage.repl.rich_output.output_catalog import OutputVideoQuicktime sage: OutputVideoQuicktime.example() ``` ```python >>> from sage.all import * >>> from sage.repl.rich_output.output_catalog import OutputVideoQuicktime >>> OutputVideoQuicktime.example() ``` -------------------------------- ### Initialize and Run RESetMPExample Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/parallel/sage/parallel/map_reduce.html Instantiate RESetMPExample and run its computation. This example computes the generating series of permutations. ```python from sage.parallel.map_reduce import RESetMPExample EX = RESetMPExample() EX.run() ``` ```python from sage.all import * from sage.parallel.map_reduce import RESetMPExample EX = RESetMPExample() EX.run() ``` -------------------------------- ### Get example of a quotient semigroup Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/categories/sage/categories/semigroups.html Returns a standard example of a quotient semigroup. ```Sage sage: Semigroups().Quotients().example() An example of a (sub)quotient semigroup: a quotient of the left zero semigroup ``` ```Python >>> from sage.all import * >>> Semigroups().Quotients().example() An example of a (sub)quotient semigroup: a quotient of the left zero semigroup ``` -------------------------------- ### Load Setup File Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/tutorial/interactive_shell.html Loads a setup log file into the current session. ```Sage sage: load("setup") ``` -------------------------------- ### GET example Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/categories/sage/categories/finite_dimensional_lie_algebras_with_basis.html Returns an example of a finite dimensional Lie algebra with basis. ```APIDOC ## GET example ### Description Return an example of a finite dimensional Lie algebra with basis. ### Method GET ### Endpoint example(n=3) ### Parameters #### Query Parameters - **n** (Integer) - Optional - The dimension of the example Lie algebra (default is 3). ### Response - **example** (LieAlgebra) - An example instance of a finite dimensional Lie algebra with basis. ``` -------------------------------- ### Example of all_solutions with dlx_solver Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/combinat/sage/combinat/matrices/dancing_links.html Provides an example of initializing the dlx_solver and then calling the `all_solutions()` method to retrieve all solutions. The solutions are then sorted for consistent output. Requires importing necessary Sage functions. ```python from sage.combinat.matrices.dancing_links import dlx_solver rows = [[0,1,2], [3,4,5], [0,1], [2,3,4,5], [0], [1,2,3,4,5]] d = dlx_solver(rows) S = d.all_solutions() sorted(sorted(s) for s in S) ``` -------------------------------- ### Get Example Group Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/categories/sage/categories/finite_permutation_groups.html Retrieves a standard example of a finite permutation group. ```Sage sage: G = FinitePermutationGroups().example(); G Dihedral group of order 6 as a permutation group ``` ```Python >>> from sage.all import * >>> G = FinitePermutationGroups().example(); G Dihedral group of order 6 as a permutation group ``` -------------------------------- ### Get Start Index Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/manifolds/sage/manifolds/manifold.html Retrieves the starting index for the manifold's index range. ```APIDOC ## Get Start Index ### Description Returns the first value of the index range used on the manifold. ### Method `M.start_index()` ### Parameters None ### Endpoint `start_index()` ### Response - **start_index** (integer) - The integer \(i_0\) such that all indices of indexed objects on the manifold range from \(i_0\) to \(i_0 + n - 1\), where \(n\) is the manifold’s dimension. ### Examples ```python # Example 1: Default start_index M = Manifold(3, 'M', structure='topological') print(M.start_index()) # Expected Output: 0 # Example 2: Custom start_index M = Manifold(3, 'M', structure='topological', start_index=1) print(M.start_index()) # Expected Output: 1 ``` ``` -------------------------------- ### Constructing OutputImagePng examples Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/repl/sage/repl/rich_output/output_graphics.html Demonstrates creating a sample PNG output container and verifying its content. ```Sage sage: from sage.repl.rich_output.output_catalog import OutputImagePng sage: OutputImagePng.example() OutputImagePng container sage: OutputImagePng.example().png buffer containing 608 bytes sage: OutputImagePng.example().png.get().startswith(b'\x89PNG') True ``` ```Python >>> from sage.all import * >>> from sage.repl.rich_output.output_catalog import OutputImagePng >>> OutputImagePng.example() OutputImagePng container >>> OutputImagePng.example().png buffer containing 608 bytes >>> OutputImagePng.example().png.get().startswith(b'\x89PNG') True ``` -------------------------------- ### Threaded worker execution example Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/parallel/sage/parallel/map_reduce.html Example of starting a worker thread and stealing tasks. ```Python >>> thief0 = Thread(target = w0._thief, name='Thief') >>> thief0.start() >>> w1.steal() 42 >>> w0._todo deque([]) ``` -------------------------------- ### Accessing Poset Examples Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/combinat/sage/combinat/posets/poset_examples.html Demonstrates basic instantiation of common posets and lattices. ```Sage sage: posets.BooleanLattice(3) Finite lattice containing 8 elements sage: posets.ChainPoset(3) Finite lattice containing 3 elements sage: posets.RandomPoset(17,.15) Finite poset containing 17 elements ``` ```Python >>> from sage.all import * >>> posets.BooleanLattice(Integer(3)) Finite lattice containing 8 elements >>> posets.ChainPoset(Integer(3)) Finite lattice containing 3 elements >>> posets.RandomPoset(Integer(17),RealNumber('.15')) Finite poset containing 17 elements ``` -------------------------------- ### SageDocTestRunner.report_start Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/doctest/sage/doctest/forker.html Reports the start of a doctest example. This method is called when an example begins execution. ```APIDOC ## POST /sage/doctest/forker/report_start ### Description Reports the start of a doctest example. This method is called when an example begins execution. ### Method POST ### Endpoint /sage/doctest/forker/report_start ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **out** (function) - Required - A function for printing output. - **test** (doctest.DocTest) - Required - A doctest.DocTest instance. - **example** (doctest.Example) - Required - A doctest.Example instance in test. ### Request Example ```json { "out": "sys.stdout.write", "test": "doctests[0]", "example": "ex" } ``` ### Response #### Success Response (200) Prints a report to the provided output function. #### Response Example ``` Trying (line ...): doctest_var = 42; doctest_var^2 Expecting: 1764 ``` ``` -------------------------------- ### Initialize a realization example Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/categories/sage/categories/realizations.html Create an example of a parent with realizations using the Sets().WithRealizations() category. ```Sage sage: A = Sets().WithRealizations().example(); A # needs sage.modules ``` ```Python >>> from sage.all import * >>> A = Sets().WithRealizations().example(); A # needs sage.modules ``` -------------------------------- ### Get Example of FiniteWeylGroups in Sage Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/categories/sage/categories/weyl_groups.html Retrieves an example element from the FiniteWeylGroups category in Sage. ```sage FiniteWeylGroups().example() ``` -------------------------------- ### Configure start index for components Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/tensor_free_modules/sage/tensor/modules/comp.html Demonstrates initializing components with a custom starting index. ```Sage sage: c1 = CompFullyAntiSym(QQ, V.basis(), 2, start_index=1) sage: c1[1,2], c1[1,3], c1[2,3] = 3, 1/2, -1 sage: c1[:] [ 0 3 1/2] [ -3 0 -1] [-1/2 1 0] ``` ```Python >>> from sage.all import * >>> c1 = CompFullyAntiSym(QQ, V.basis(), Integer(2), start_index=Integer(1)) >>> c1[Integer(1),Integer(2)], c1[Integer(1),Integer(3)], c1[Integer(2),Integer(3)] = Integer(3), Integer(1)/Integer(2), -Integer(1) >>> c1[:] [ 0 3 1/2] [ -3 0 -1] [-1/2 1 0] ``` -------------------------------- ### GradedModulesWithBasis Example Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/categories/sage/categories/examples/graded_modules_with_basis.html Demonstrates how to get an example of a graded module with basis and access its basis. ```APIDOC ## GET /sage/categories/examples/graded_modules_with_basis.py ### Description Retrieves an example of a graded module with basis. ### Method GET ### Endpoint /sage/categories/examples/graded_modules_with_basis.py ### Parameters None ### Request Example None ### Response #### Success Response (200) - **basis** (Lazy family) - The basis of the graded module. #### Response Example ```python from sage.all import * E = ExteriorAlgebra(QQ, names=('x', 'y',)); (x, y,) = E._first_ngens(2) print(E.basis()) ``` ``` Lazy family (Term map from Subsets of {0,1} to The exterior algebra of rank 2 over Rational Field(i))_{i in Subsets of {0,1}} ``` ``` -------------------------------- ### Rich Output Example Methods Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/repl/genindex-E.html Demonstrates the usage of the `example()` method for various rich output types in SageMath. ```APIDOC ## OutputAsciiArt.example ### Description Provides an example for ASCII art output. ### Method Class Method ### Endpoint N/A (Class Method) ### Request Example ```json { "example": "ASCII Art Example" } ``` ### Response #### Success Response (200) - **output** (string) - The ASCII art representation. #### Response Example ```json { "output": "+---+\\n| |\\n+---+" } ``` ## OutputBase.example ### Description Base method for providing examples for rich output. ### Method Class Method ### Endpoint N/A (Class Method) ### Request Example ```json { "example": "Base Example" } ``` ### Response #### Success Response (200) - **output** (string) - A generic example output. #### Response Example ```json { "output": "Base Example Output" } ``` ## OutputLatex.example ### Description Provides an example for LaTeX output. ### Method Class Method ### Endpoint N/A (Class Method) ### Request Example ```json { "example": "\\documentclass{article}\\n\\begin{document}Hello\\end{document}" } ``` ### Response #### Success Response (200) - **output** (string) - The LaTeX code. #### Response Example ```json { "output": "\\documentclass{article}\\n\\begin{document}Hello\\end{document}" } ``` ## OutputPlainText.example ### Description Provides an example for plain text output. ### Method Class Method ### Endpoint N/A (Class Method) ### Request Example ```json { "example": "This is plain text." } ``` ### Response #### Success Response (200) - **output** (string) - The plain text content. #### Response Example ```json { "output": "This is plain text." } ``` ## OutputUnicodeArt.example ### Description Provides an example for Unicode art output. ### Method Class Method ### Endpoint N/A (Class Method) ### Request Example ```json { "example": "Unicode Art Example" } ``` ### Response #### Success Response (200) - **output** (string) - The Unicode art representation. #### Response Example ```json { "output": "\u2500\u2500\u2500\n\u2502 \u2502\n\u2500\u2500\u2500" } ``` ## OutputImageDvi.example ### Description Provides an example for DVI image output. ### Method Class Method ### Endpoint N/A (Class Method) ### Request Example ```json { "example": "DVI Image Example" } ``` ### Response #### Success Response (200) - **output** (string) - The DVI image data. #### Response Example ```json { "output": "DVI Image Data..." } ``` ## OutputImageGif.example ### Description Provides an example for GIF image output. ### Method Class Method ### Endpoint N/A (Class Method) ### Request Example ```json { "example": "GIF Image Example" } ``` ### Response #### Success Response (200) - **output** (string) - The GIF image data. #### Response Example ```json { "output": "GIF Image Data..." } ``` ## OutputImageJpg.example ### Description Provides an example for JPG image output. ### Method Class Method ### Endpoint N/A (Class Method) ### Request Example ```json { "example": "JPG Image Example" } ``` ### Response #### Success Response (200) - **output** (string) - The JPG image data. #### Response Example ```json { "output": "JPG Image Data..." } ``` ## OutputImagePdf.example ### Description Provides an example for PDF image output. ### Method Class Method ### Endpoint N/A (Class Method) ### Request Example ```json { "example": "PDF Image Example" } ``` ### Response #### Success Response (200) - **output** (string) - The PDF image data. #### Response Example ```json { "output": "PDF Image Data..." } ``` ## OutputImagePng.example ### Description Provides an example for PNG image output. ### Method Class Method ### Endpoint N/A (Class Method) ### Request Example ```json { "example": "PNG Image Example" } ``` ### Response #### Success Response (200) - **output** (string) - The PNG image data. #### Response Example ```json { "output": "PNG Image Data..." } ``` ## OutputImageSvg.example ### Description Provides an example for SVG image output. ### Method Class Method ### Endpoint N/A (Class Method) ### Request Example ```json { "example": "SVG Image Example" } ``` ### Response #### Success Response (200) - **output** (string) - The SVG image data. #### Response Example ```json { "output": "SVG Image Data..." } ``` ## OutputSceneCanvas3d.example ### Description Provides an example for 3D Canvas scene output. ### Method Class Method ### Endpoint N/A (Class Method) ### Request Example ```json { "example": "3D Canvas Scene Example" } ``` ### Response #### Success Response (200) - **output** (string) - The 3D Canvas scene data. #### Response Example ```json { "output": "3D Canvas Scene Data..." } ``` ## OutputSceneJmol.example ### Description Provides an example for Jmol scene output. ### Method Class Method ### Endpoint N/A (Class Method) ### Request Example ```json { "example": "Jmol Scene Example" } ``` ### Response #### Success Response (200) - **output** (string) - The Jmol scene data. #### Response Example ```json { "output": "Jmol Scene Data..." } ``` ## OutputSceneWavefront.example ### Description Provides an example for Wavefront scene output. ### Method Class Method ### Endpoint N/A (Class Method) ### Request Example ```json { "example": "Wavefront Scene Example" } ``` ### Response #### Success Response (200) - **output** (string) - The Wavefront scene data. #### Response Example ```json { "output": "Wavefront Scene Data..." } ``` ## OutputVideoBase.example ### Description Provides a base example for video output. ### Method Class Method ### Endpoint N/A (Class Method) ### Request Example ```json { "example": "Video Example" } ``` ### Response #### Success Response (200) - **output** (string) - The video data. #### Response Example ```json { "output": "Video Data..." } ``` ``` -------------------------------- ### Get Finite Dimensional Cellular Algebras Category (Python) Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/categories/sage/categories/finite_dimensional_algebras_with_basis.html This Python code, using SageMath's interface, achieves the same as the Sage-specific example: retrieving the category of finite dimensional cellular algebras with basis over the rational field. Ensure SageMath is installed and imported correctly. ```python from sage.all import * Algebras(QQ).FiniteDimensional().WithBasis().Cellular() ``` -------------------------------- ### Creating a Facade Set Example Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/categories/sage/categories/sets_cat.html Demonstrates creating a facade set in SageMath, specifically a set of integers. ```sage sage: Set([4,6,9]) # random {4, 6, 9} sage: Sets().Facade().example() An example of facade set: the monoid of positive integers ``` ```python >>> from sage.all import * >>> Set([Integer(4),Integer(6),Integer(9)]) # random {4, 6, 9} >>> Sets().Facade().example() An example of facade set: the monoid of positive integers ``` -------------------------------- ### Sage Example: Creating and Displaying an Algebra Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/thematic_tutorials/tutorial-implementing-algebraic-structures.html Demonstrates how to create an example algebra 'A' using 'Sets().WithRealizations().example()' and display its representation. The 'A??' command is used for introspection but is noted as not implemented. ```sage sage: A = Sets().WithRealizations().example(); A The subset algebra of {1, 2, 3} over Rational Field sage: A?? # not implemented ``` -------------------------------- ### Get polynomial degree from SplittingData (Python) Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/number_fields/sage/rings/number_field/splitting_field.html This Python example demonstrates how to get the degree of a polynomial from a SplittingData object. It mirrors the Sage example and is useful for verifying polynomial degrees in a Python context. ```python from sage.all import * from sage.rings.number_field.splitting_field import SplittingData SplittingData(pari("x^123 + x + 1"), Integer(2)).poldegree() ``` -------------------------------- ### Initialize and serialize PartitionAlgebra_tk Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/algebras/sage/combinat/partition_algebra.html Demonstrates creating an instance of PartitionAlgebra_tk and verifying its picklability. ```Sage sage: from sage.combinat.partition_algebra import * sage: p = PartitionAlgebra_tk(QQ, 3, 1) sage: p == loads(dumps(p)) True ``` ```Python >>> from sage.all import * >>> from sage.combinat.partition_algebra import * >>> p = PartitionAlgebra_tk(QQ, Integer(3), Integer(1)) >>> p == loads(dumps(p)) True ``` -------------------------------- ### Retrieve Manifold Start Index Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/manifolds/sage/manifolds/manifold.html Get the starting index value for indexed objects on the manifold. ```Sage sage: M = Manifold(3, 'M', structure='topological') sage: M.start_index() 0 sage: M = Manifold(3, 'M', structure='topological', start_index=1) sage: M.start_index() 1 ``` ```Python >>> from sage.all import * >>> M = Manifold(Integer(3), 'M', structure='topological') >>> M.start_index() 0 >>> M = Manifold(Integer(3), 'M', structure='topological', start_index=Integer(1)) >>> M.start_index() 1 ``` -------------------------------- ### Get bit example in Sage Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/logic/sage/logic/logic.html Example usage of get_bit function within a Sage environment. ```python sage: from sage.logic.logic import get_bit sage: get_bit(int(2), int(1)) 'True' sage: get_bit(int(8), int(0)) 'False' ``` -------------------------------- ### FacadeSets.example() Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/categories/sage/categories/facade_sets.html Provides an example usage of FacadeSets. ```APIDOC ## FacadeSets.example() ### Description Demonstrates an example of how to use the FacadeSets class. ### Method GET (or similar, depending on context) ### Endpoint (Not applicable for internal methods) ### Response #### Success Response (200) - **example_output** (string) - A string containing the example output or usage. ``` -------------------------------- ### Initialize and serialize PartitionAlgebra_sk Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/algebras/sage/combinat/partition_algebra.html Demonstrates creating an instance of PartitionAlgebra_sk and verifying its picklability. ```Sage sage: from sage.combinat.partition_algebra import * sage: p = PartitionAlgebra_sk(QQ, 3, 1) sage: p == loads(dumps(p)) True ``` ```Python >>> from sage.all import * >>> from sage.combinat.partition_algebra import * >>> p = PartitionAlgebra_sk(QQ, Integer(3), Integer(1)) >>> p == loads(dumps(p)) True ``` -------------------------------- ### Get Support of FilteredVectorSpace in Python (Example 1) Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/modules/sage/modules/filtered_vector_space.html Shows how to get the support (degrees with non-trivial generators) of a filtered vector space using Sage's Python API. This example does not include infinity. ```python >>> from sage.all import * >>> G \= FilteredVectorSpace({Integer(0): \[(Integer(1),Integer(1),Integer(0))\] , Integer(3): \[(Integer(0),Integer(1),Integer(0))\]}); G QQ^2 >= QQ^1 >= QQ^1 >= QQ^1 >= 0 in QQ^3 >>> G.support() (0, 3) ``` -------------------------------- ### Initialize and serialize PartitionAlgebra_prk Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/algebras/sage/combinat/partition_algebra.html Demonstrates creating an instance of PartitionAlgebra_prk and verifying its picklability. ```Sage sage: from sage.combinat.partition_algebra import * sage: p = PartitionAlgebra_prk(QQ, 3, 1) sage: p == loads(dumps(p)) True ``` ```Python >>> from sage.all import * >>> from sage.combinat.partition_algebra import * >>> p = PartitionAlgebra_prk(QQ, Integer(3), Integer(1)) >>> p == loads(dumps(p)) True ``` -------------------------------- ### Python Example: Get Example Group Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/categories/sage/categories/groups.html Python code to fetch an example group from SageMath's Groups category. The 'sage.modules' module is a prerequisite. ```python >>> from sage.all import * >>> Groups().example() # needs sage.modules General Linear Group of degree 4 over Rational Field ``` -------------------------------- ### Initialize and Inspect Posets Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/categories/sage/categories/posets.html Demonstrates how to access the category of posets and create an example poset. ```Sage sage: Posets().super_categories() [Category of sets] sage: P = Posets().example(); P An example of a poset: sets ordered by inclusion ``` ```Python >>> from sage.all import * >>> Posets() Category of posets >>> Posets().super_categories() [Category of sets] >>> P = Posets().example(); P An example of a poset: sets ordered by inclusion ``` -------------------------------- ### Get Example Object from Category Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/categories/sage/categories/category.html Demonstrates how to obtain a representative object from a category using the `example()` method. ```sage Semigroups().example() ``` ```sage Monoids().Subquotients().example() ``` ```python from sage.all import * Semigroups().example() ``` ```python Monoids().Subquotients().example() ``` -------------------------------- ### SageInputBuilder Setup and Usage Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/misc/sage/misc/sage_input.html Demonstrates the setup of SageInputBuilder and its use in creating parent objects with generators, showcasing different preparsing and generator usage scenarios. ```APIDOC ## SageInputBuilder Setup and Usage Examples ### Description This section provides examples of using the `SageInputBuilder` to create parent objects with specified generators and demonstrates how the `preparse` and `use_gens` options affect the output. ### Method `test_setup(use_gens=True, preparse=True)` ### Endpoint N/A (Python function) ### Parameters - **use_gens** (bool) - Optional - Whether to use generators. - **preparse** (bool) - Optional - Whether to enable preparsing. ### Request Example ```python from sage.all import * from sage.misc.sage_input import SageInputBuilder def test_setup(use_gens=True, preparse=True): sib = SageInputBuilder(preparse=preparse) gen_names=('foo', 'bar') parent = "some parent" normal_sie = sib.name('make_a_parent')(names=gen_names) if use_gens: gens_sie = sib.name('make_a_parent')() else: gens_sie = None name = 'the_thing' result = sib.parent_with_gens(parent, normal_sie, gen_names, name, gens_syntax=gens_sie) return sib, result ``` ### Response #### Success Response (Output of `sib.result()`) - **Output varies based on input parameters and operations performed.** ### Response Example ```python # Example 1: Default setup sib, par_sie = test_setup() sib.result(par_sie) # Output: make_a_parent(names=('foo', 'bar')) # Example 2: Default setup with multiplication sib, par_sie = test_setup() sib.result(sib(3) * sib.gen("some parent", 0)) # Output: the_thing. = make_a_parent() # 3*foo # Example 3: With preparse=False sib, par_sie = test_setup(preparse=False) sib.result(par_sie) # Output: make_a_parent(names=('foo', 'bar')) # Example 4: With preparse=False and multiplication sib, par_sie = test_setup(preparse=False) sib.result(sib(3) * sib.gen("some parent", 0)) # Output: the_thing = make_a_parent(names=('foo', 'bar')) # foo,bar = the_thing.gens() # ZZ(3)*foo # Example 5: With use_gens=False sib, par_sie = test_setup(use_gens=False) sib.result(par_sie) # Output: make_a_parent(names=('foo', 'bar')) # Example 6: With use_gens=False and multiplication sib, par_sie = test_setup(use_gens=False) sib.result(sib(3) * sib.gen("some parent", 0)) # Output: the_thing = make_a_parent(names=('foo', 'bar')) # foo,bar = the_thing.gens() # 3*foo # Example 7: With subtraction sib, par_sie = test_setup() sib.result(par_sie - sib.gen("some parent", 1)) # Output: the_thing. = make_a_parent() # the_thing - bar ``` ``` -------------------------------- ### Get Limit Start for Single Value Envelope Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/combinat/sage/combinat/integer_lists/base.html Returns the starting index for the limit of an envelope defined by a single value. Use for sequences that are constant from the start. ```python >>> Envelope(Integer(4)).limit_start() 0 ``` -------------------------------- ### Get Conductor of Example Type Space Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/modfrm/sage/modular/local_comp/type_space.html Retrieves the exponent of p dividing the level of the form. This is an example usage. ```python from sage.modular.local_comp.type_space import example_type_space example_type_space().conductor() ``` ```python from sage.all import * from sage.modular.local_comp.type_space import example_type_space example_type_space().conductor() ``` -------------------------------- ### TilingSolver Initialization and Basic Usage Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/combinat/sage/combinat/tiling.html Demonstrates how to initialize the TilingSolver with polyominoes and a box, and shows the default settings for rotations and reflections. ```APIDOC ## TilingSolver Initialization ### Description Initializes a TilingSolver object to find tilings of a given box with specified polyominoes. Demonstrates default settings for rotations and reflections. ### Method `TilingSolver(pieces, box, reusable=False, reflection=False, rotation=True)` ### Parameters * `pieces` (list of Polyomino) - The set of polyominoes to use for tiling. * `box` (Polyomino or tuple) - The shape of the box to be tiled. * `reusable` (bool, optional) - Whether pieces can be reused. Defaults to `False`. * `reflection` (bool, optional) - Whether reflections are allowed. Defaults to `False`. * `rotation` (bool, optional) - Whether rotations are allowed. Defaults to `True`. ### Request Example ```python from sage.combinat.tiling import TilingSolver, Polyomino p = Polyomino([(0,0,0)]) q = Polyomino([(0,0,0), (0,0,1)]) r = Polyomino([(0,0,0), (0,0,1), (0,0,2)]) T = TilingSolver([p,q,r], box=(1,1,6)) print(T) ``` ### Response ``` Tiling solver of 3 pieces into a box of size 6 Rotation allowed: True Reflection allowed: False Reusing pieces allowed: False ``` ``` -------------------------------- ### Get Installed Packages in Python Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/misc/sage/misc/package.html Retrieves a dictionary of all installed packages and their versions. Excludes pip packages by default. ```python from sage.all import * from sage.misc.package import installed_packages sorted(installed_packages().keys()) ``` ```python installed_packages()['gnulib'] ``` -------------------------------- ### Initialize and serialize PartitionAlgebra_rk Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/algebras/sage/combinat/partition_algebra.html Demonstrates creating an instance of PartitionAlgebra_rk and verifying its picklability. ```Sage sage: from sage.combinat.partition_algebra import * sage: p = PartitionAlgebra_rk(QQ, 3, 1) sage: p == loads(dumps(p)) True ``` ```Python >>> from sage.all import * >>> from sage.combinat.partition_algebra import * >>> p = PartitionAlgebra_rk(QQ, Integer(3), Integer(1)) >>> p == loads(dumps(p)) True ``` -------------------------------- ### Generate facade set examples Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/categories/sage/categories/facade_sets.html Creates example facade sets using different configuration choices. ```sage sage: Sets().Facade().example() An example of facade set: the monoid of positive integers sage: Sets().Facade().example(choice='union') An example of a facade set: the integers completed by +-infinity sage: Sets().Facade().example(choice='subset') An example of facade set: the monoid of positive integers ``` ```python >>> from sage.all import * >>> Sets().Facade().example() An example of facade set: the monoid of positive integers >>> Sets().Facade().example(choice='union') An example of a facade set: the integers completed by +-infinity >>> Sets().Facade().example(choice='subset') An example of facade set: the monoid of positive integers ``` -------------------------------- ### Get Installed Packages in Sage Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/misc/sage/misc/package.html Retrieves a dictionary of all installed packages and their versions. Excludes pip packages by default. ```python from sage.misc.package import installed_packages sorted(installed_packages().keys()) ``` ```python installed_packages()['gnulib'] ``` -------------------------------- ### Comparing Solvers (CVXOPT, PPL, Default) Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/numerical/sage/numerical/backends/cvxopt_backend.html This example illustrates the usage of different solvers (cvxopt, ppl, and the default solver) within SageMath's MixedIntegerLinearProgram. It sets up identical problems for each solver and retrieves the results, highlighting potential differences in solution values. ```APIDOC ## GET /api/users/{id} ### Description Retrieves the details of a specific user based on their unique identifier. ### Method GET ### Endpoint /api/users/{id} ### Parameters #### Path Parameters - **id** (integer) - Required - The unique identifier of the user to retrieve. ### Response #### Success Response (200) - **id** (integer) - The unique identifier for the user. - **username** (string) - The username of the user. - **email** (string) - The email address of the user. #### Response Example { "id": 1, "username": "johndoe", "email": "john.doe@example.com" } ``` -------------------------------- ### Sage: Polyhedron Cardinality Example Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/discrete_geometry/sage/geometry/convex_set.html Demonstrates how to get the cardinality of a Polyhedron in SageMath. This example shows a 1-dimensional polyhedron. ```python >>> r = Polyhedron(rays=[(Integer(1), Integer(0))]); r A 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 1 vertex and 1 ray >>> r.cardinality() +Infinity ``` -------------------------------- ### SemidefiniteProgram Initialization with CVXOPT Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/numerical/sage/numerical/sdp.html Demonstrates initializing a SemidefiniteProgram with the CVXOPT solver and checking its base ring. ```APIDOC ## POST /SemidefiniteProgram ### Description Initializes a SemidefiniteProgram, optionally specifying the solver and base ring. ### Method POST ### Endpoint /SemidefiniteProgram ### Parameters #### Request Body - **solver** (string) - Optional - The solver to use (e.g., 'cvxopt'). Defaults to the default solver. - **base_ring** (string) - Optional - The base ring for the program (e.g., 'Real Double Field', 'Rational Field'). Defaults to the default base ring. ### Response #### Success Response (200) - **base_ring** (string) - The base ring of the initialized SemidefiniteProgram. ### Request Example ```json { "solver": "cvxopt" } ``` ### Response Example ```json { "base_ring": "Real Double Field" } ``` ``` -------------------------------- ### GET directive_vector Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/combinat/sage/combinat/words/paths.html Returns the directive vector of the path, which is the vector starting at the start point and ending at the end point. ```APIDOC ## GET directive_vector ### Description Return the directive vector of the path. The directive vector is the vector starting at the start point and ending at the end point of the path. ### Method GET ### Response - **vector** (tuple) - The directive vector of the path. ``` -------------------------------- ### Initialize TilingSolver Source: https://github.com/sagemath/documentation/blob/gh-pages/html/en/reference/combinat/sage/combinat/tiling.html Sets up a TilingSolver with specific polyominoes and a box size. ```Sage sage: from sage.combinat.tiling import TilingSolver, Polyomino sage: p = Polyomino([(0,0,0)]) sage: q = Polyomino([(0,0,0), (0,0,1)]) sage: r = Polyomino([(0,0,0), (0,0,1), (0,0,2)]) sage: T = TilingSolver([p,q,r], box=(1,1,6)) sage: T Tiling solver of 3 pieces into a box of size 6 Rotation allowed: True Reflection allowed: False Reusing pieces allowed: False ``` ```Python >>> from sage.all import * >>> from sage.combinat.tiling import TilingSolver, Polyomino >>> p = Polyomino([(Integer(0),Integer(0),Integer(0))]) >>> q = Polyomino([(Integer(0),Integer(0),Integer(0)), (Integer(0),Integer(0),Integer(1))]) >>> r = Polyomino([(Integer(0),Integer(0),Integer(0)), (Integer(0),Integer(0),Integer(1)), (Integer(0),Integer(0),Integer(2))]) >>> T = TilingSolver([p,q,r], box=(Integer(1),Integer(1),Integer(6))) >>> T Tiling solver of 3 pieces into a box of size 6 Rotation allowed: True Reflection allowed: False Reusing pieces allowed: False ```