Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥...

37
GiNaC Symbolic computation with C ++ Jens Vollinga Institut f ¨ ur Physik Universit ¨ at Mainz GiNaC – p.1/13

Transcript of Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥...

Page 1: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

GiNaCSymbolic computation with C++

Jens Vollinga

Institut fur Physik

Universitat Mainz

GiNaC – p.1/13

Page 2: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

Outline

C++ libraryDeveloped since 1999

¥ CAS in high energy physics¥ Fundamentals of GiNaC¥ Features of GiNaC¥ Applications

GiNaC – p.2/13

Page 3: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

CAS in high energy physics

Perturbation theory

¥ Feynman rules¥ Feynman diagrams¥ Dirac algebra and traces¥ Loop integration¥ Summation of diagrams¥ Phase space integration¥ Checks¥ . . .

Combinatorics(Maple, C, Perl)

Algebra(Maple, FORM)

⇒ Data management(C, BASH, Perl)

Numerics(FORTRAN, C)

I/O(C, Tcl/Tk)

GiNaC – p.3/13

Page 4: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

CAS in high energy physics

Perturbation theory

¥ Feynman rules¥ Feynman diagrams¥ Dirac algebra and traces¥ Loop integration¥ Summation of diagrams¥ Phase space integration¥ Checks¥ . . .

Combinatorics

(Maple, C, Perl)

Algebra

(Maple, FORM)

⇒ Data management

(C, BASH, Perl)

Numerics

(FORTRAN, C)

I/O

(C, Tcl/Tk)

GiNaC – p.3/13

Page 5: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

CAS in high energy physics

Perturbation theory

¥ Feynman rules¥ Feynman diagrams¥ Dirac algebra and traces¥ Loop integration¥ Summation of diagrams¥ Phase space integration¥ Checks¥ . . .

Combinatorics(Maple, C, Perl)

Algebra(Maple, FORM)

⇒ Data management(C, BASH, Perl)

Numerics(FORTRAN, C)

I/O(C, Tcl/Tk)

GiNaC – p.3/13

Page 6: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

CAS in physics

Taming COMPLEXITY → Software Engineering(coding, social, technology,. . . )

What if you are a C++ programmer?

¥ Combinatorics¥ Algebra → GiNaC¥ Data management¥ Numerics¥ I/O

GiNaC – p.4/13

Page 7: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

CAS in physics

Taming COMPLEXITY → Software Engineering(coding, social, technology,. . . )

What if you are a C++ programmer?

¥ Combinatorics¥ Algebra

→ GiNaC

¥ Data management¥ Numerics¥ I/O

GiNaC – p.4/13

Page 8: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

CAS in physics

Taming COMPLEXITY → Software Engineering(coding, social, technology,. . . )

What if you are a C++ programmer?

¥ Combinatorics¥ Algebra

→ GiNaC

¥ Data management¥ Numerics¥ I/O

GiNaC – p.4/13

Page 9: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

CAS in physics

Taming COMPLEXITY → Software Engineering(coding, social, technology,. . . )

What if you are a C++ programmer?

¥ Combinatorics¥ Algebra

→ GiNaC

¥ Data management¥ Numerics¥ I/O

GiNaC – p.4/13

Page 10: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

CAS in physics

Taming COMPLEXITY → Software Engineering(coding, social, technology,. . . )

What if you are a C++ programmer?

¥ Combinatorics¥ Algebra

→ GiNaC

¥ Data management¥ Numerics¥ I/O

GiNaC – p.4/13

Page 11: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

CAS in physics

Taming COMPLEXITY → Software Engineering(coding, social, technology,. . . )

What if you are a C++ programmer?

¥ Combinatorics¥ Algebra → GiNaC¥ Data management¥ Numerics¥ I/O

GiNaC – p.4/13

Page 12: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

Fundamentals of GiNaC

¥ Write a C++ program:

#include <iostream>

using namespace std;

#include <ginac/ginac.h>

using namespace GiNaC;

int main()

{symbol x("x");

ex result = Li(2,x).diff(x);

cout << result << endl;

return 0;

}GiNaC – p.5/13

Page 13: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

Fundamentals of GiNaC

¥ Write a C++ program:

Library header

#include <iostream>

using namespace std;

#include <ginac/ginac.h>

using namespace GiNaC;

int main()

{symbol x("x");

ex result = Li(2,x).diff(x);

cout << result << endl;

return 0;

}GiNaC – p.5/13

Page 14: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

Fundamentals of GiNaC

¥ Write a C++ program:

New data types from GiNaC

#include <iostream>

using namespace std;

#include <ginac/ginac.h>

using namespace GiNaC;

int main()

{symbol x("x");

ex result = Li(2,x).diff(x);

cout << result << endl;

return 0;

}GiNaC – p.5/13

Page 15: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

Fundamentals of GiNaC

¥ Write a C++ program:

Algebra in C++ !

#include <iostream>

using namespace std;

#include <ginac/ginac.h>

using namespace GiNaC;

int main()

{symbol x("x");

ex result = Li(2,x).diff(x);

cout << result << endl;

return 0;

}GiNaC – p.5/13

Page 16: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

Fundamentals of GiNaC

¥ Compile the program:

$ g++ -o myprg myprg.cpp -lginac

¥ Run it:

$ ./myprg

-log(1-x)*x (-1)

GiNaC – p.6/13

Page 17: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

Fundamentals of GiNaC

Container for arbitrary algebraic expressions→ ex

After declarationex myexpr;

or as a function parameter for exampleex nloopfct(ex momentum)

{ ... }

use it like C++ built-in types:momentum = sqrt() * pow(, 2) - ;

myexpr = sin().series(, 10);

cout << myexpr << endl;

if (myexpr.has()) y = myexpr;

GiNaC – p.7/13

Page 18: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

Fundamentals of GiNaC

Container for arbitrary algebraic expressions→ ex

After declarationex myexpr;

or as a function parameter for exampleex nloopfct(ex momentum)

{ ... }

use it like C++ built-in types:momentum = sqrt() * pow(, 2) - ;

myexpr = sin().series(, 10);

cout << myexpr << endl;

if (myexpr.has()) y = myexpr;

GiNaC – p.7/13

Page 19: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

Fundamentals of GiNaC

Container for arbitrary algebraic expressions→ ex

After declarationex myexpr;

or as a function parameter for exampleex nloopfct(ex momentum)

{ ... }

use it like C++ built-in types:momentum = sqrt(p) * pow(mu, 2) - d;

myexpr = sin(x).series(x, 10);

cout << myexpr << endl;

if (myexpr.has(x)) y = myexpr;

GiNaC – p.7/13

Page 20: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

Fundamentals of GiNaC

Container for arbitrary algebraic expressions→ ex

After declarationex myexpr;

or as a function parameter for exampleex nloopfct(ex momentum)

{ ... }

use it like C++ built-in types:momentum = sqrt(p) * pow(mu, 2) - d;

myexpr = sin(x).series(x, 10);

cout << myexpr << endl;

if (myexpr.has(x)) y = myexpr;

GiNaC – p.7/13

Page 21: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

Fundamentals of GiNaC

Symbols → symbol

Declaration:symbol x("x");

symbol eps("\epsilon")

What else?¥ Numbers 1.34, 3/4, 2i, . . .¥ Mathematical functions¥ Matrices¥ Algebras

. . .

GiNaC – p.8/13

Page 22: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

Fundamentals of GiNaC

Symbols → symbol

Declaration:symbol x("x");

symbol eps("\epsilon")

What else?¥ Numbers 1.34, 3/4, 2i, . . .¥ Mathematical functions¥ Matrices¥ Algebras

. . .GiNaC – p.8/13

Page 23: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

Features of GiNaC

¥ Arbitrary symbolic expressions

¥ Complex arithmetics with arbitrary precision¥ Operations on rational functions,

e.g. x2−y2

(x+y)2 → x−yx+y

¥ Symbolic derivation and series expansion¥ Matrices, vectors, linear equation systems¥ In-/Output of expressions in various formats

(text, binary, LaTeX, . . . )¥ New functions and classes can easily be added

GiNaC – p.9/13

Page 24: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

Features of GiNaC

¥ Arbitrary symbolic expressions¥ Complex arithmetics with arbitrary precision

¥ Operations on rational functions,e.g. x2−y2

(x+y)2 → x−yx+y

¥ Symbolic derivation and series expansion¥ Matrices, vectors, linear equation systems¥ In-/Output of expressions in various formats

(text, binary, LaTeX, . . . )¥ New functions and classes can easily be added

GiNaC – p.9/13

Page 25: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

Features of GiNaC

¥ Arbitrary symbolic expressions¥ Complex arithmetics with arbitrary precision¥ Operations on rational functions,

e.g. x2−y2

(x+y)2 → x−yx+y

¥ Symbolic derivation and series expansion¥ Matrices, vectors, linear equation systems¥ In-/Output of expressions in various formats

(text, binary, LaTeX, . . . )¥ New functions and classes can easily be added

GiNaC – p.9/13

Page 26: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

Features of GiNaC

¥ Arbitrary symbolic expressions¥ Complex arithmetics with arbitrary precision¥ Operations on rational functions,

e.g. x2−y2

(x+y)2 → x−yx+y

¥ Symbolic derivation and series expansion

¥ Matrices, vectors, linear equation systems¥ In-/Output of expressions in various formats

(text, binary, LaTeX, . . . )¥ New functions and classes can easily be added

GiNaC – p.9/13

Page 27: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

Features of GiNaC

¥ Arbitrary symbolic expressions¥ Complex arithmetics with arbitrary precision¥ Operations on rational functions,

e.g. x2−y2

(x+y)2 → x−yx+y

¥ Symbolic derivation and series expansion¥ Matrices, vectors, linear equation systems

¥ In-/Output of expressions in various formats(text, binary, LaTeX, . . . )

¥ New functions and classes can easily be added

GiNaC – p.9/13

Page 28: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

Features of GiNaC

¥ Arbitrary symbolic expressions¥ Complex arithmetics with arbitrary precision¥ Operations on rational functions,

e.g. x2−y2

(x+y)2 → x−yx+y

¥ Symbolic derivation and series expansion¥ Matrices, vectors, linear equation systems¥ In-/Output of expressions in various formats

(text, binary, LaTeX, . . . )

¥ New functions and classes can easily be added

GiNaC – p.9/13

Page 29: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

Features of GiNaC

¥ Arbitrary symbolic expressions¥ Complex arithmetics with arbitrary precision¥ Operations on rational functions,

e.g. x2−y2

(x+y)2 → x−yx+y

¥ Symbolic derivation and series expansion¥ Matrices, vectors, linear equation systems¥ In-/Output of expressions in various formats

(text, binary, LaTeX, . . . )¥ New functions and classes can easily be added

GiNaC – p.9/13

Page 30: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

Features of GiNaC

¥ FunctionsΓ, B, ψ,

(

nk

)

, . . .

sin, cos, tan, sinh, . . .√, exp, log, ζ, S, H, Li, . . .

¥ Objects with indices: pµ, Aij

Special algebras: Clifford, SU(3)¥ Automatic code generation (→ numeric integration)¥ Good documentation, open source (GPL)→ www.ginac.de

GiNaC – p.10/13

Page 31: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

Features of GiNaC

¥ FunctionsΓ, B, ψ,

(

nk

)

, . . .

sin, cos, tan, sinh, . . .√, exp, log, ζ, S, H, Li, . . .

¥ Objects with indices: pµ, Aij

Special algebras: Clifford, SU(3)

¥ Automatic code generation (→ numeric integration)¥ Good documentation, open source (GPL)→ www.ginac.de

GiNaC – p.10/13

Page 32: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

Features of GiNaC

¥ FunctionsΓ, B, ψ,

(

nk

)

, . . .

sin, cos, tan, sinh, . . .√, exp, log, ζ, S, H, Li, . . .

¥ Objects with indices: pµ, Aij

Special algebras: Clifford, SU(3)¥ Automatic code generation (→ numeric integration)

¥ Good documentation, open source (GPL)→ www.ginac.de

GiNaC – p.10/13

Page 33: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

Features of GiNaC

¥ FunctionsΓ, B, ψ,

(

nk

)

, . . .

sin, cos, tan, sinh, . . .√, exp, log, ζ, S, H, Li, . . .

¥ Objects with indices: pµ, Aij

Special algebras: Clifford, SU(3)¥ Automatic code generation (→ numeric integration)¥ Good documentation, open source (GPL)→ www.ginac.de

GiNaC – p.10/13

Page 34: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

Applications with GiNaC

¥ Loop calculations: xloops

¥ nestedsums

¥ gTybalt

¥ feelfem, PURRS, MBDyn

¥ PublicationsOn the Invariance of Residues of Feynman Graphs

I. Bierenbaum, R. Kreckel, D. Kreimer, J. Math. Phys. 43 4721-4740 (2002)

The Massless Two-Loop Two-Point Function

I. Bierenbaum, S. Weinzierl, Eur. Phys. J. C32:67-78 (2003)

The Electroweak Standard Model in the Axial Gauge

C. Dams, R. Kleiss, Eur. Phys. J. C34:419-427 (2004)

An Example of Clifford Algebras Calculations with GiNaC

V. Kisil, [arXiv:cs.MS/0410044]GiNaC – p.11/13

Page 35: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

Summary

GiNaC – a C++ library for symbolic computation

¥ Complete computational framework in C++

¥ Features of GiNaC

¥ Developed since 1999Version 1.0 in 2001, current version 1.3.1Technically matured and well documented

¥ Active development going on(better factorization, more special functions, improvedinterface to MC integration)

GiNaC – p.12/13

Page 36: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

Summary

GiNaC – a C++ library for symbolic computation

¥ Complete computational framework in C++

¥ Features of GiNaC¥ Developed since 1999

Version 1.0 in 2001, current version 1.3.1Technically matured and well documented

¥ Active development going on(better factorization, more special functions, improvedinterface to MC integration)

GiNaC – p.12/13

Page 37: Symbolic computation with C++ · 2005-05-19 · GiNaC Œ a C++ library for symbolic computation ¥ Complete computational framework in C++ ¥ Features of GiNaC ¥ Developed since

www.ginac.de

GiNaC – p.13/13