Aug-15-2019, 10:08 AM
I want to solve this nonlinear equation. I've tried to use sympy and scipy methods. But I thing something wrong with syntax.
So how to write this code correctly?
So how to write this code correctly?
import sympy import numpy as np import math from scipy.optimize import fsolve def PoissonEqs(p,m,alpha): if m==0: return math.exp(-p)-alpha else: return math.exp(m*math.log(p)-p-math.log(math.gamma(m+1)))+PoissonEqs(p,m-1,alpha) #p=fsolve(PoissonEqs(p,0,0.05,1),1) p=sympy.Symbol('p') p1=sympy.nsolve(math.exp(-p)-0.05,p,1) print(p1)