From 64fb16faf0c7eabe224ea4dc64e00cba036486d3 Mon Sep 17 00:00:00 2001 From: Christian Bauer Date: Thu, 11 Dec 2003 20:21:25 +0000 Subject: [PATCH] added a check for the expand() problem --- check/exam_paranoia.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/check/exam_paranoia.cpp b/check/exam_paranoia.cpp index 4050b5f5..b581d87b 100644 --- a/check/exam_paranoia.cpp +++ b/check/exam_paranoia.cpp @@ -370,6 +370,41 @@ static unsigned exam_paranoia15(void) return result; } +// Expanding products containing powers of sums could return results that +// were not fully expanded. Fixed on Dec 10, 2003. +static unsigned exam_paranoia16(void) +{ + unsigned result = 0; + symbol a("a"), b("b"), c("c"), d("d"); + ex e1, e2, e3; + + e1 = pow(1+a*sqrt(b+c), 2); + e2 = e1.expand(); + + if (e2.has(pow(a, 2)*(b+c))) { + clog << "expand(" << e1 << ") didn't fully expand\n"; + ++result; + } + + e1 = (d*sqrt(a+b)+a*sqrt(c+d))*(b*sqrt(a+b)+a*sqrt(c+d)); + e2 = e1.expand(); + + if (e2.has(pow(a, 2)*(c+d))) { + clog << "expand(" << e1 << ") didn't fully expand\n"; + ++result; + } + + e1 = (a+sqrt(b+c))*sqrt(b+c)*(d+sqrt(b+c)); + e2 = e1.expand(); + + if (e2.has(a*(b+c))) { + clog << "expand(" << e1 << ") didn't fully expand\n"; + ++result; + } + + return result; +} + unsigned exam_paranoia(void) { unsigned result = 0; @@ -392,6 +427,7 @@ unsigned exam_paranoia(void) result += exam_paranoia13(); cout << '.' << flush; result += exam_paranoia14(); cout << '.' << flush; result += exam_paranoia15(); cout << '.' << flush; + result += exam_paranoia16(); cout << '.' << flush; if (!result) { cout << " passed " << endl; -- 2.50.0