How do I resolve the error " 'Add' function is not callable" in this code using scipy library? [closed]

from sympy import *
from scipy.optimize import *
from numpy import *
import math
x=symbols("x)")
eqn1=20+3*(29.4*(1-(2.71)**(-x/3))-9.8*x)
print(fsolve(eqn1,[0,10]))

This shows a

Type Error: " 'Add' function is not callable" in line 7


Solution 1:

From scipy documentation the way you define your equation is like a python function and then use it in fsolve :

from scipy.optimize import *

def eqn1(x):
    return [20 + 3 * (29.4 * (1 - (2.71) ** (-x[0] / 3)) - 9.8 * x[0])]

print(fsolve(eqn1, [10]))

output:

>>>
[2.26874667]