evalf is not producing numerical result for a algebraic expression

163 Views Asked by At

I have this sympy expression.

I am not sure why evalf function doesn't properly evaluate this expression and still I don't get an actual numerical value out of it?

    value = {t1: _t1, t2: _t2, t3: _t3, x_mid: _x_mid, theta: _theta, focal_length: _focal_length, vec_20: vec_2[0],
         vec_21: vec_2[1], vec_22: vec_2[2], r: radius}

    ansx = root1[i][0].evalf(subs=value)

After the following piece of code is run:

        ansx = root1[i][0].evalf(subs=value)

I get the following for ansx:

enter image description here

where root[i][0] is:

enter image description here

I had created a minimal expression that shows evalf should work for sympy:

In [7]: omega, t = sympy.symbols("omega, t")

In [8]: s = sympy.pi * sympy.cos(omega*t)

In [9]: s
Out[9]: pi*cos(omega*t)

In [10]: print(s.evalf().subs({t: 0}))
3.14159265358979
0

There are 0 best solutions below