Got error about converting expression to float while using sympy

Hello, I am trying to solve the equation when ceta is the unknown using SymPy(Introduction - SymPy 1.11 documentation)

import math
from sympy.solvers import solve
from sympy import Symbol
ceta = Symbol('ceta')
sigmax = 1.0;
sigmay = 6.0;
pw = 5.0;
expr = sigmax+sigmay-2*(sigmax-sigmay)*math.cos(2*ceta)-pw
solution=solve(expr, ceta)

Thank you

Please share the error you are seeing.

The problem is that math.cos takes in float. So, math.cos(2*ceta) is trying to convert ceta into a float.

You should use sympy.cos instead.

1 Like