1

I'm trying to get sympy to solve the trigonometric equations below, but it gives me this error:

NotImplementedError: could not solve b*tan(3*atan(6/b)/2) - 9

Is there a way for me to be able to get sympy to solve the equation below?

import sympy

from sympy import *

a = sympy.symbols("a")
b = sympy.symbols("b")

eq1 = sympy.Eq(b*tan(2*a), 6)
eq2 = sympy.Eq(b*tan(3*a), 9)

result = sympy.solve([eq1, eq2], (a,b))
print(result)
Emmanuel
  • 129
  • 1
  • 6
  • It can't solve it then, hope [this](https://stackoverflow.com/a/64717448/14872512) gives you some ideas. – Younes Feb 19 '21 at 15:15
  • 1
    Removing `b` from the equation seems to lead to a result `solve([Eq(tan(2 * a) / 6, tan(3 * a) / 9)], a)` – JohanC Feb 19 '21 at 19:25

1 Answers1

1

You can use expand to apply the trigonometric addition formulas that reduce everything to rational functions in tan(a):

In [16]: tan(2*a).expand(trig=True)
Out[16]: 
  2⋅tan(a) 
───────────
       2   
1 - tan (a)

Then the equations can be solved:

In [14]: eq1, eq2 = [eq.expand(trig=True) for eq in [eq1, eq2]]

In [15]: solve([eq1, eq2], (a,b))
Out[15]: 
⎡⎛              18⋅√5⋅ⅈ⎞  ⎛             -18⋅√5⋅ⅈ ⎞⎤
⎢⎜-ⅈ⋅atanh(√5), ───────⎟, ⎜ⅈ⋅atanh(√5), ─────────⎟⎥
⎣⎝                 5   ⎠  ⎝                 5    ⎠⎦
Oscar Benjamin
  • 12,649
  • 1
  • 12
  • 14