Simplify a GiNaC expression

254 Views Asked by At

I am trying to do something very simple with GiNaC:

void assert(bool x) {
    if (!x)
        throw runtime_error("Assertion error");
}

#include <ginac/ginac.h>

int main(int argc, char *argv[]) {
    assert(sqrt(ex(32)) == 4 * sqrt(ex(2))); // Raises runtime_error
}

I want to simplify sqrt(32) so that it is equal to 4 * sqrt(2). Of course, from a mathematical standpointm that is the case, but GiNaC does not "realize" this. The documentations mention none of these simplifications and I really don't known whether this is even possible...

0

There are 0 best solutions below