- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
documentation对于 scipy.integrate.ode.integrate
没有描述 relax
参数的作用。它有什么作用?打开源代码显示它是一个 bool 标志,但我得到的只有这些。
最佳答案
简答:此参数仅允许方法返回不太精确的答案。保持默认值 False。它与刚性系统的松弛无关。
长答案:current version of documentation将此参数解释为
relax : bool
If True and if the integrator supports the run_relax method, then integrate until t_1 >= t and return. relax is not referenced if step=True. This parameter is provided in order to expose internals of the implementation, and should not be changed from its default value in most cases.
英语:integrate
方法采用您要评估解决方案的值 t
。但是积分器自己选择步长,一般来说 t 不会是它命中的点之一。如何处理?
relax=True
,则计算直到某个点 t1 >= t 的解并返回 t1 处的值。不进行插值。 当然,这意味着该方法会超调并返回不太准确的值,因此您不会希望将其作为最终答案接受。它可能在实现自己的插值的更复杂算法内部很有用,但很难想象这在 SciPy 级别如何发生,因为 t1 未返回。
示例:对 y' = y 和 y(0)=1 进行积分。精确解是 y = exp(t)。比较精确解和在 t = 0.1 时计算的两个近似值:
from scipy.integrate import ode
r = ode(lambda t, y: y).set_integrator('vode').set_initial_value(1, 0)
print(np.exp(0.1), r.integrate(0.1), r.integrate(0.1, relax=True))
输出:
1.10517091808 1.10517178 1.10959337
使用 relax=True 时,超调非常明显。
关于python - "relax"在 scipy 积分器中做什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38065322/
我是一名优秀的程序员,十分优秀!