问题描述
我在使用 python 编码时遇到以下问题:
I have the following problem to code using python:
我有 7 个参数:x、y、z、t、HF、M1F 和 M2F.用户应该输入这三个中的任何一个,程序应该计算其余的.
I have 7 parameters: x, y, z, t, HF, M1F, and M2F. The user should input any of these 3 and the program should calculate the rest.
我的关系是:
HF = -xyt
M1F = -2xzt + 4yzt - xyt + 4tz^2
M2F = 2yzt - xyt
1 = -2xt + 2yt + 4zt
尝试解决问题:
我有 7 个参数,用户应该输入 3 => 我将剩下 4 个参数.因此,这一切都是关于求解具有 4 个未知数的 4 个非线性方程组.
I have 7 parameters and the user should input 3 => I will be left with 4 parameters. So it's all about solving a system of 4 nonlinear equations with 4 unknowns.
我在网上读到 scipy.optimize
可用于求解非线性方程组.但我需要一个初步的猜测.
I read online that scipy.optimize
could be used to solve a system of nonlinear equations.But I need an initial guess.
回到问题的物理学,我有以下初始条件:
Going back to the physics of the problem I have the following initial conditions:
x > 0
y > 0
z < 0
HF > 0
M1F > 0
M2F > 0
M2F > M1F (solving this inequality from the above equations I get: -x + y + 2z < 0)
HF > M1F + d (solving this inequality from the above equations I get: -x + 2y + 2z < 0)
这些初始条件如何帮助我获得初始猜测,以便我可以使用 scipy.optimize
解决我的问题?
How can these initial conditions help me get the initial guess so that I can solve my problem using scipy.optimize
?
推荐答案
我不确定优化是否是正确的方法.我个人认为我会从给定的三个变量开始,然后用代数方法解决其余的问题.有很多组合,但所有考虑到的分析解决方案通常是最好的,如果它是可获得的.
I'm not sure optimization is the right way to go here. I think personally I'd start with the three variables given and algebraically solve the rest. There are a lot of combinations, but all things considered the analytic solution is usually best if it's obtainable.
这篇关于在 python 中使用 scipy.optimize 的初步猜测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!