Is it possible to combine sympy symbolic variables with math operators? I am getting an error

from sympy import symbols, solve
from math import pi, log10, sqrt

D_i = 0.5
epsilon = 0.0005
nu = 1.21*10**(-5)

V = 132.4169

Re = V * D_i / nu

f = symbols('f')

f = solve(-2 * log10((epsilon / D_i) / 3.7 + 2.51 / (Re * sqrt(f))) - 1 / sqrt(f), f)

And I get the error:

TypeError: Cannot convert expression to float

Referring to what’s inside the log10() and sqrt()

Import the functions from sympy, not from stdlib math, i.e. from sympy import sqrt, log10

1 Like