GiNac Experience

https://www.ginac.de/tutorial/

GiNac is an exceptional symbol library for C++ development.

Install:

1
2
3
4
tar xf ginac_xxx.tar.gz
cd ginac_xxx
cmake -Bbuild
cmake --build build --parallel 8

Example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using namespace std;
using namespace GiNaC;

ex HermitePoly(const symbol & x, int n)
{
ex HKer=exp(-pow(x, 2));
// uses the identity H_n(x) == (-1)^n exp(x^2) (d/dx)^n exp(-x^2)
return normal(pow(-1, n) * diff(HKer, x, n) / HKer);
}

int main()
{
symbol z("z");

for (int i=0; i<6; ++i)
cout << "H_" << i << "(z) == " << HermitePoly(z,i) << endl;

return 0;
}

GiNac Experience
http://blog.chivier.site/2023-10-23/2023/GiNac-Experience/
Author
Chivier Humber
Posted on
October 23, 2023
Licensed under