Ginac 1.8.1 an Open Framework for Symbolic Computation Within the C++ Programming Language 8 August 2021
Total Page:16
File Type:pdf, Size:1020Kb
GiNaC 1.8.1 An open framework for symbolic computation within the C++ programming language 8 August 2021 https://www.ginac.de Copyright c 1999-2021 Johannes Gutenberg University Mainz, Germany Permission is granted to make and distribute verbatim copies of this manual provided the copy- right notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the condi- tions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. i Table of Contents GiNaC :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 1 1 Introduction :::::::::::::::::::::::::::::::::::::::::::::::::::: 2 1.1 License :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 2 2 A Tour of GiNaC::::::::::::::::::::::::::::::::::::::::::::::: 3 2.1 How to use it from within C++ :::::::::::::::::::::::::::::::::::::::::::::::::::: 3 2.2 What it can do for you::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 4 3 Installation:::::::::::::::::::::::::::::::::::::::::::::::::::::: 8 3.1 Prerequisites ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 8 3.2 Configuration :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 8 3.3 Building GiNaC ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 9 3.4 Installing GiNaC::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 9 4 Basic concepts::::::::::::::::::::::::::::::::::::::::::::::::: 11 4.1 Expressions ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 11 4.1.1 Note: Expressions and STL containers ::::::::::::::::::::::::::::::::::::::: 11 4.2 Automatic evaluation and canonicalization of expressions :::::::::::::::::::::::::: 11 4.3 Error handling:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 12 4.4 The class hierarchy ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 13 4.5 Symbols :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 14 4.6 Numbers ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 17 4.6.1 Tests on numbers :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 18 4.6.2 Numeric functions ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 20 4.6.3 Converting numbers:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 22 4.7 Constants :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 22 4.8 Sums, products and powers ::::::::::::::::::::::::::::::::::::::::::::::::::::::: 22 4.9 Lists of expressions ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 23 4.10 Mathematical functions :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 25 4.11 Relations :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 25 4.12 Integrals::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 26 4.13 Matrices::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 27 4.14 Indexed objects:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 30 4.14.1 Indexed quantities and their indices ::::::::::::::::::::::::::::::::::::::::: 30 4.14.2 Substituting indices ::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 33 4.14.3 Symmetries ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 34 4.14.4 Dummy indices ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 35 4.14.5 Simplifying indexed expressions ::::::::::::::::::::::::::::::::::::::::::::: 36 4.14.6 Predefined tensors :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 37 4.14.6.1 Delta tensor ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 37 4.14.6.2 General metric tensor :::::::::::::::::::::::::::::::::::::::::::::::::: 37 4.14.6.3 Minkowski metric tensor ::::::::::::::::::::::::::::::::::::::::::::::: 38 4.14.6.4 Spinor metric tensor ::::::::::::::::::::::::::::::::::::::::::::::::::: 38 4.14.6.5 Epsilon tensor ::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 39 4.14.7 Linear algebra :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 40 ii 4.15 Non-commutative objects :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 40 4.15.1 Clifford algebra ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 42 4.15.1.1 Dirac gamma matrices ::::::::::::::::::::::::::::::::::::::::::::::::: 42 4.15.1.2 A generic Clifford algebra :::::::::::::::::::::::::::::::::::::::::::::: 44 4.15.2 Color algebra ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 47 5 Methods and functions ::::::::::::::::::::::::::::::::::::::: 49 5.1 Getting information about expressions :::::::::::::::::::::::::::::::::::::::::::: 49 5.1.1 Checking expression types:::::::::::::::::::::::::::::::::::::::::::::::::::: 49 5.1.2 Accessing subexpressions ::::::::::::::::::::::::::::::::::::::::::::::::::::: 51 5.1.3 Comparing expressions ::::::::::::::::::::::::::::::::::::::::::::::::::::::: 52 5.1.4 Ordering expressions ::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 52 5.2 Numerical evaluation ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 53 5.3 Substituting expressions :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 54 5.4 Pattern matching and advanced substitutions ::::::::::::::::::::::::::::::::::::: 55 5.4.1 Matching expressions :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 56 5.4.2 Matching parts of expressions :::::::::::::::::::::::::::::::::::::::::::::::: 58 5.4.3 Substituting expressions:::::::::::::::::::::::::::::::::::::::::::::::::::::: 59 5.4.4 The option algebraic ::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 59 5.5 Applying a function on subexpressions :::::::::::::::::::::::::::::::::::::::::::: 59 5.6 Visitors and tree traversal::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 62 5.7 Polynomial arithmetic :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 65 5.7.1 Testing whether an expression is a polynomial :::::::::::::::::::::::::::::::: 65 5.7.2 Expanding and collecting :::::::::::::::::::::::::::::::::::::::::::::::::::: 65 5.7.3 Degree and coefficients ::::::::::::::::::::::::::::::::::::::::::::::::::::::: 66 5.7.4 Polynomial division :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 67 5.7.5 Unit, content and primitive part ::::::::::::::::::::::::::::::::::::::::::::: 67 5.7.6 GCD, LCM and resultant :::::::::::::::::::::::::::::::::::::::::::::::::::: 68 5.7.7 Square-free decomposition:::::::::::::::::::::::::::::::::::::::::::::::::::: 68 5.7.8 Polynomial factorization ::::::::::::::::::::::::::::::::::::::::::::::::::::: 69 5.8 Rational expressions :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 70 5.8.1 The normal method:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 70 5.8.2 Numerator and denominator ::::::::::::::::::::::::::::::::::::::::::::::::: 70 5.8.3 Converting to a polynomial or rational expression :::::::::::::::::::::::::::: 70 5.9 Symbolic differentiation ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 71 5.10 Series expansion ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 72 5.11 Symmetrization:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 73 5.12 Predefined mathematical functions ::::::::::::::::::::::::::::::::::::::::::::::: 75 5.12.1 Overview ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 75 5.12.2 Expanding functions :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 77 5.12.3 Multiple polylogarithms::::::::::::::::::::::::::::::::::::::::::::::::::::: 77 5.12.4 Iterated integrals ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 79 5.13 Complex expressions::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 80 5.14 Solving linear systems of equations::::::::::::::::::::::::::::::::::::::::::::::: 80 5.15 Input and output of expressions:::::::::::::::::::::::::::::::::::::::::::::::::: 81 5.15.1 Expression output :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 81 5.15.2 Expression input:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 83 5.15.3 Compiling expressions to C function pointers :::::::::::::::::::::::::::::::: 85 5.15.4 Archiving ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 86 iii 6 Extending GiNaC ::::::::::::::::::::::::::::::::::::::::::::: 90 6.1 What doesn't belong into GiNaC:::::::::::::::::::::::::::::::::::::::::::::::::: 90 6.2 Symbolic functions:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 90 6.2.1 A minimal example :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 90 6.2.2 The cosine function :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 91 6.2.3 Function options ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 93 6.2.4 Functions with a variable number of arguments ::::::::::::::::::::::::::::::: 94 6.3 GiNaC's expression output system :::::::::::::::::::::::::::::::::::::::::::::::: 94 6.3.1 Print methods for classes::::::::::::::::::::::::::::::::::::::::::::::::::::: 95 6.3.2 Print methods for functions :::::::::::::::::::::::::::::::::::::::::::::::::: 97 6.3.3 Adding new output formats :::::::::::::::::::::::::::::::::::::::::::::::::: 98 6.4 Structures :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 99 6.4.1 Example: scalar products :::::::::::::::::::::::::::::::::::::::::::::::::::: 99