擅长:python、mysql、java
<p>受@Wrzlprmft注释的启发,如果参数不是常量,则更安全的做法是调用直接在要更新的函数中更新参数的函数。正如他所说,这意味着:</p>
<pre><code>def fun(t, x):
return x - f_param(t)
</code></pre>
<p>但是,该函数(<code>f_param</code>在本例中)可能无法在要集成的函数的命名空间中访问(在上面的示例中是<code>fun</code>)。因此,将函数设置为要集成的函数的参数并在开始时只使用一次<code>set_f_params</code>来指定函数,这样会更方便。在</p>
<p>作为问题代码的延续:</p>
^{pr2}$
<p>显示ode3和ode4提供相同的解决方案:</p>
<p><a href="https://i.stack.imgur.com/p60yk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p60yk.png" alt="solutions"/></a></p>