title: Using SymbolicC++ to solve systems of equations symbolically
body: <p>I am looking for a way to programmatically solve systems of (not necessarily linear) equations, symbolically. My main focus has been on SymbolicC++, but I was unable to find much documentation, and I am unable to get it working.</p>
  
  <p>The code below yields <code>a == 1/2*(-4*b^(2)+4*c^(2))^(1/2)</code>, which is clearly not simplified properly (I even explicitly call <code>simplify</code>.) :</p>
  
  <pre><code>#include &lt;symbolicc++.h&gt;
  #include &lt;iostream&gt;
  
  int main()
  {
      Symbolic a("a");
      Symbolic b("b");
      Symbolic c("c");
  
      auto eq1 = (a^2) + (b^2) == (c^2);
      auto solutions = solve(eq1, a);
  
      for (auto i = solutions.begin(); i != solutions.end(); i++)
          std::cout &lt;&lt; (*i).simplify() &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>The code below is supposed to yield among many solutions <code>a==2, b==2, c==2, d==2</code> and <code>a == 5-2*sqrt(6), b == 5+2*sqrt(6), c == 5-2*sqrt(6), d == 5+2*sqrt(6)</code> but instead encounters the following exception after executing for about 10 seconds:</p>
  
  <blockquote>
    <p>Unhandled exception at 0x73203D5C (vcruntime140.dll) in test.exe: 0xC0000005: Access violation reading location 0x00000018.</p>
  </blockquote>
  
  <pre><code>#include &lt;symbolicc++.h&gt;
  #include &lt;iostream&gt;
  
  int main()
  {
      Symbolic a("a");
      Symbolic b("b");
      Symbolic c("c");
      Symbolic d("d");
  
      auto eq1 = a + b*c*d == 10;
      auto eq2 = b + a*c*d == 10;
      auto eq3 = c + a*b*d == 10;
      auto eq4 = d + a*b*c == 10;
      auto eq = (eq1, eq2, eq3, eq4);
      auto solutions = solve(eq, (a, b, c, d));
  
      for (auto i = solutions.begin(); i != solutions.end(); i++)
          std::cout &lt;&lt; *i &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>(I used Visual Studio to compile the library.)</p>
  
  <p>My test equations seem to be solvable, since WolframAlpha solves them with ease. (I just used <code>solve a^2+b^2 = c^2 for a</code> and <code>solve a+bcd=10, b+acd=10, c+abd=10, d+abc=10</code>.)</p>
  
  <p>Am I doing something wrong? What do I need to get these examples to work correctly?</p>
  
  <p><em>Notes about other libraries:</em><br>
  If possible, I would like to compile the library to ARM systems (Windows Phone). As far as I can tell, only C++ and .NET libraries come into play. Since currently I use MSVC to compile SymbolicC++ anyway, I think cross-compiling it to WP won't be a problem.</p>
  
  <p><em>Notes about sympy:</em><br>
  The code below throws <code>ZeroDivisionError</code> with the message <code>polynomial division</code>. Since it does not really fit my portability needs anyway, I just gave up on it.</p>
  
  <pre><code>import sympy.solvers
  from sympy import Equality
  from sympy.abc import a, b, c, d
  equations = [ Equality(a + b*c*d, 10), Equality(b + a*c*d, 10), Equality(c + a*b*d, 10), Equality(d + a*b*c, 10) ]
  print sympy.solvers.solve(equations, [a, b, c, d])
  </code></pre>