如何在Sigle线中找到两个常见的切线?如何求解二进制微分方程?

发布于 2025-02-07 16:27:23 字数 1250 浏览 1 评论 0原文

我有一个名为f的函数,如下所示: 两孔线 我想求解方程,以获取给定范围内函数的两个常见的切线(x1,f(x1)),(x2,f(x2))。 方程是:

F'(x1)=F'(x2)                     (1)

F'(x1)*(x2-x1)+F(x1)=F(x2)        (2)

要求解这两个方程式,我使用sympy.solve.solve。代码是:

x1 = Symbol('x1')
F1 = F(x1,AA, BB, CC, DD, EE, FF)
x2 = Symbol('x2')
F2 = F(x2,AA, BB, CC, DD, EE, FF)
dF1=diff(F1,x1)
dF2=diff(F2,x2)
print(solve([dF1-dF2, F2-F1-dF1*(x2-x1)], [x1, x2]))

但是输出是[(x2,x2)]。 让我感到困惑,

  1. 如何让x1!= x2
  2. 如何获得方程式的数值输出?
  3. 如何在一定范围内让x1x2

我不知道这里有什么问题,以下solve命令具有正确的输出:

print(solve([y1+y2,y1-y2], [x1, x2]))
print(solve(dy1, x1))

但对于二进制微分方程(1)和(2)

谢谢!

@Lutz Lehmann:打印出功能和方程式,以查看它们是否实际上是您认为的:

-------------------------------------------------------------------
In [1]: x1 = Symbol('x1')
F1 = F(x1,AA, BB, CC, DD, EE, FF)
x2 = Symbol('x2')
F2 = F(x2,AA, BB, CC, DD, EE, FF)
dF1=diff(F1,x1)
dF2=diff(F2,x2)
-------------------------------------------------------------------
In [2]: F1
Out[2]: 
              

I have a function named F which looks like below:
a two-well line
and I want to solve equations to get two common tangent points (x1,F(x1)),(x2,F(x2)) of the function in a given range.
the equations are:

F'(x1)=F'(x2)                     (1)

F'(x1)*(x2-x1)+F(x1)=F(x2)        (2)

and to solve these two equations I use sympy.solve. the code is:

x1 = Symbol('x1')
F1 = F(x1,AA, BB, CC, DD, EE, FF)
x2 = Symbol('x2')
F2 = F(x2,AA, BB, CC, DD, EE, FF)
dF1=diff(F1,x1)
dF2=diff(F2,x2)
print(solve([dF1-dF2, F2-F1-dF1*(x2-x1)], [x1, x2]))

but the output is [(x2, x2)].
it is quite confusing me

  1. how to let x1 != x2?
  2. how to get numerical output of the equations?
  3. how to let x1 and x2 in a certain range?

I relly do not know what is wrong here, the following solve command has correct output:

print(solve([y1+y2,y1-y2], [x1, x2]))
print(solve(dy1, x1))

but not work for binary differential equations(1)and (2)

thankyou!

@Lutz Lehmann:Print out the functions and equations to see if they actually are what you think they are:

-------------------------------------------------------------------
In [1]: x1 = Symbol('x1')
F1 = F(x1,AA, BB, CC, DD, EE, FF)
x2 = Symbol('x2')
F2 = F(x2,AA, BB, CC, DD, EE, FF)
dF1=diff(F1,x1)
dF2=diff(F2,x2)
-------------------------------------------------------------------
In [2]: F1
Out[2]: ????1⋅(1−????1)(−0.0501765666583873????1+0.244249682150038(2????1−1)5−0.535363152864316(2????1−1)4+0.197479965493092(2????1−1)3−0.366799918223659(2????1−1)2−0.203076238788926)
(Out [2] is F)
-------------------------------------------------------------------
In [3]:dF1
Out[3]:????1⋅(1−????1)(−2.93439934578927????1+2.44249682150038(2????1−1)4−4.28290522291453(2????1−1)3+1.18487979295855(2????1−1)2+1.41702310623625)−????1(−0.0501765666583873????1+0.244249682150038(2????1−1)5−0.535363152864316(2????1−1)4+0.197479965493092(2????1−1)3−0.366799918223659(2????1−1)2−0.203076238788926)+(1−????1)(−0.0501765666583873????1+0.244249682150038(2????1−1)5−0.535363152864316(2????1−1)4+0.197479965493092(2????1−1)3−0.366799918223659(2????1−1)2−0.203076238788926)
(Out [3] is correct)
-------------------------------------------------------------------
In [4]:print(solve([F1+F2,F1-F2], [x1, x2]))  
[(0.0, 0.0), (0.0, 1.00000000000000), (1.00000000000000, 0.0), (1.00000000000000, 1.00000000000000)]
(In [4] is correct)
-------------------------------------------------------------------
In [5]:print(solve(dF1, x1))
[0.143449671600321, 0.462174698289538, 0.744534434388284, 1.44258261390104, 0.573315370351492 - 0.261496971434863*I, 0.573315370351492 + 0.261496971434863*I]
(In [5] is correct)
-------------------------------------------------------------------
In [6]:print(solve([dF1-dF2, F2-F1-dF1*(x2-x1)], [x1, x2]))
[(x2, x2)]
(In [6] is what I confused??)
-------------------------------------------------------------------

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文