+#include <iostream>
+using namespace std;
+
+static unsigned exam_lsolve1()
+{
+ // A trivial example.
+ unsigned result = 0;
+ symbol x("x");
+ ex eq, aux;
+
+ eq = (3*x+5 == numeric(8));
+ aux = lsolve(eq, x);
+ if (aux != 1) {
+ ++result;
+ clog << "solution of 3*x+5==8 erroneously returned "
+ << aux << endl;
+ }
+
+ return result;
+}
+
+static unsigned exam_lsolve2a()
+{
+ // An example from the Maple online help.
+ unsigned result = 0;
+ symbol a("a"), b("b"), x("x"), y("y");
+ lst eqns, vars;
+ ex sol;
+
+ // Create the linear system [a*x+b*y==3,x-y==b]...
+ eqns.append(a*x+b*y==3).append(x-y==b);
+ // ...to be solved for [x,y]...
+ vars.append(x).append(y);
+ // ...and solve it:
+ sol = lsolve(eqns, vars);
+ ex sol_x = sol.op(0).rhs(); // rhs of solution for first variable (x)
+ ex sol_y = sol.op(1).rhs(); // rhs of solution for second variable (y)
+
+ // It should have returned [x==(3+b^2)/(a+b),y==(3-a*b)/(a+b)]
+ if (!normal(sol_x - (3+pow(b,2))/(a+b)).is_zero() ||
+ !normal(sol_y - (3-a*b)/(a+b)).is_zero()) {
+ ++result;
+ clog << "solution of the system " << eqns << " for " << vars
+ << " erroneously returned " << sol << endl;
+ }
+
+ return result;
+}
+
+static unsigned exam_lsolve2b()