Thank you Alexey!

There is a symbolic math program call symengine. I think symenigne is also written in C++.

Symengine has a C interface: https://github.com/symengine/symengine/blob/master/symengine/cwrapper.h

But I do not have the knowledge to understand how one makes a C interface for a C++ library.

Yours sincerely,

Xianwen