- // 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;
+ // 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;