Ranjith Kumar Engineer in the making

Trigonometric Solvers

This is the blog on progress for week-6. It revolves around solvers for trigonometric equations. The PR on polynomial solvers is merged in.

As I mentioned in my previous blog, I continued my work on solving simple trigonometric equations. I made a PR. See the commit messages for more details. Currently, this PR doesn’t pass the whole test suit. Specifically, the below case.

 auto y = symbol("y");
 eqn = sub(sin(add(x, y)), sin(x));
 soln = solve(eqn, y);

It currently returns a ConditionSet(means it is unable to find any solution). The reason for this traces to problem in expand(). expand(exp(I*(x + y))) stays as exp(I*(x+y)). It should be returning exp(I*x)*exp(I*y). This is needed because subs are not robust enough to handle inputs like exp(x + I*y)->subs(exp(I*y) = z). Even SymPy subs are not robust enough(see example below).

>>> a=sin(x+y).rewrite('exp')
>>> a.subs(exp(I*y),z)
   ⎛   ⅈ⋅(-x - y)    ⅈ⋅(x + y)⎞ 
-ⅈ⋅⎝- ℯ           + ℯ         ⎠ 
>>> a=expand(sin(x+y).rewrite('exp'))
>>> a.subs(exp(I*y),z)
       ⅈ⋅x      -ⅈ⋅x
  ⅈ⋅z⋅ℯ      ⅈ⋅ℯ    
- ──────── + ───────
     2         2⋅z  

Apart from this, I fixed a bug in dummy::compare here.

Next immediate goal is to implement trigonometric simplification using fu and integrate it with current trig_solve. I will add as many rules as possible. Hopefully, we would be able to solve not so simple equations as well after it is successfully integrated. You can track my progress on this at fu branch.

That’s it for now. See you next week. Until then, Goodbye !