两个函数的Python交点

两个函数的Python交点,python,function,numpy,intersection,Python,Function,Numpy,Intersection,我试图找到这两个函数之间的交集。现在P_g是一个常数,但我希望它是灵活的,所以我可以改变它,使之成为sin,或线性增加 import numpy as np import matplotlib.pyplot as plt d = 100. # price at 0 catch sales local market b1 = 0.05 # slope of price curve for species1 p = 50. # # price for species1 global P_g =

我试图找到这两个函数之间的交集。现在P_g是一个常数,但我希望它是灵活的,所以我可以改变它,使之成为sin,或线性增加

import numpy as np
import matplotlib.pyplot as plt


d = 100. # price at 0 catch sales local market
b1 = 0.05 # slope of price curve for species1
p = 50. # # price for species1 global

P_g = p # constant for price species1 global
P_l = d * np.exp(-b1*x) # price species1 local market
在我看来,最合适的解决办法是:

P_g = ImplicitRegion[{y == p}, {x, y}]
P_l = ImplicitRegion[{y == d* np.exp(-b1*x)}, {x, y}]

solve[{k /[Element] P_g, k /[Element] P_l}, {k}]

这给了我:SyntaxError:invalid syntax

你可以通过
scipy.optimize.fsolve(lambda x:d*np.exp(-b1*x)-p\u g,0)找到它

或者解析求解:
x=-np.log(p\u g/d)/b1。


在这两种情况下,您都会发现:
x=13.86294361119906

调用
solve
会引发语法错误。你能澄清一下你想解决的问题吗?这不应该用Mathematica来标记吗?