求二阶导数
现在您已经得到了目标函数的一阶导数,可以继续计算二阶导数。您将使用 sympy 进行符号计算。
上一练习中的 dc_dq、q_opt,以及以数量变量 q 表示的目标函数 c 都已为您准备好。
本练习是课程的一部分
Python 优化入门
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Find the second derivative
d2c_dq2 = ____
# Substitute the optimum into the second derivative
sol = ____(____)
print(f"The 2nd derivative at q_opt is: {sol}")