Revision history [back]

Cannot solve simple equations with trig functions?

I'm pretty new to Sage, so forgive if this is a silly question. I'm trying to solve some relatively simple, but nonlinear and coupled equations. I've found that the below, very simple 2-variable problem trips up Sage; is there no way of solving such equations?

The equations are

• $sin(\theta)=0$ and
• $cos(\theta)-x=0$

to which the solutions are $\theta=n \pi$ and $x=\cos\theta$.

Here's my code, which gives TypeError: unable to make sense of Maxima expression. As a sanity check, I put in one solution by hand (which does return 0==0, 0==0 as expected). Note that putting to_poly_solve = 'force') doesn't seem to matter.

x = var('x')
theta = var('theta')

e1 = sin(theta)
e2 = cos(theta)-x

equations = [e1==0, e2==0]
variables = [theta, x]

print('Equations:')
print(equations)
handSoln = {theta:0, x:1}
print('Hand-found solutions')
print(handSoln)
print('Evaluating at hand-found solutions')
print([eq.subs(handSoln) for eq in equations])

soln = solve(equations, variables) #, to_poly_solve = 'force')

print('Found solutions:')
print(soln)