static unsigned exam_expand_subs(void)
{
unsigned result = 0;
- symbol a1("a1");
symbol a[VECSIZE];
ex e, aux;
- a[1] = a1;
- for (unsigned i=0; i<VECSIZE; ++i) {
+ for (unsigned i=0; i<VECSIZE; ++i)
e = e + a[i];
- }
// prepare aux so it will swallow anything but a1^2:
aux = -e + a[0] + a[1];
e = expand(subs(expand(pow(e, 2)), a[0] == aux));
- if (e != pow(a1,2)) {
+ if (e != pow(a[1],2)) {
clog << "Denny Fliegner's quick consistency check erroneously returned "
<< e << "." << endl;
++result;
return result;
}
+static unsigned exam_expand_power(void)
+{
+ unsigned result = 0;
+ symbol x("x"), a("a"), b("b");
+ ex e;
+
+ e = pow(x,pow(a+b,2)-pow(a,2)-pow(b,2)-a*b*2).expand();
+
+ if (e != 1) {
+ clog << "e = pow(x,pow(a+b,2)-pow(a,2)-pow(b,2)-a*b*2).expand(); erroneously returned "
+ << e << " instead of simplifying to 1." << endl;
+ ++result;
+ }
+
+ return result;
+}
+
unsigned exam_misc(void)
{
unsigned result = 0;
result += exam_expand_subs(); cout << '.' << flush;
result += exam_expand_subs2(); cout << '.' << flush;
+ result += exam_expand_power(); cout << '.' << flush;
if (!result) {
cout << " passed " << endl;