[GiNaC-list] comparing ex

Markus Knodel mknodel at zino.physik.uni-mainz.de
Thu Aug 18 15:12:37 CEST 2005


Hi,

#include <ginac/ginac.h>
#include <iostream>

using namespace std;
using namespace GiNaC;

int main()
{

   symbol a0("a0"), x("x"), a1("a1");

   ex a = a0 + x*a1;
   ex b = a0 + a1*x;

   ex diff = a - b;

   ex diff_expd = diff.expand();

   cout << "a-b = " << diff_expd << endl;

   // should give: a-b = 0

   return 0;
}


>
> I want to compare (or test the equality of) two ex objects which contain
> symbols.
> a = a0 + x*a1;
> b = a0 + a1*x;
>
> If the ex objects are evaluated (symbolically), such that
> a-b becomes 0, then the test would be finished.
>
> However, how do I evaluate such a expression as a-b symbolically?
>

is this what you wanted?

Cheers
   Markus






More information about the GiNaC-list mailing list