[英]How should I find the x_value corresponding to the max or min y_value of a parabola? (in Python)
I've been tying to use np.where
to find the x
value that corresponds to the maximum y
value of a parabola, here is what I did:我一直想使用
np.where
来找到对应于抛物线的最大y
值的x
值,这就是我所做的:
import numpy as np
x = np.arange(-10,10,step=1)
y = x**2+2*x
x = np.where(y=max)
print(x)
This clearly doesn't work这显然行不通
You can simply use argmin您可以简单地使用 argmin
import numpy as np
x = np.arange(-10,10,step=1)
y = x**2+2*x
idx = np.argmin(y)
print(x[idx])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.