如何在mathematica中生成不等式集列表

发布于 2024-10-11 21:07:10 字数 394 浏览 2 评论 0原文

我想在 Mma 中执行以下操作。假设我有三个表达式,x1, 3 x1-x2, x2-x1,其中 0<=x1,x2<=1)。我想要另一个指定三个中最大的至少是最小的两倍。因此,这三者的顺序有一些排列:

x1<=3 x1-x2<=x2-x1 && 2 x1<=x2-x1
3 x1-x2<=x1<=x2-x1 && 2 (3 x1-x2)<=x2-x1

...... 其余4个条件类似。

如何自动形成这些条件(与0<=x1,x2<=1一起),然后将它们一一输入Reduce,并根据x1求解x2?

非常感谢!

I want to do the following in Mma. Suppose I have three expressions, x1, 3 x1-x2, x2-x1 where 0<=x1,x2<=1). I want to have another one which specifies the largest among the three is at least twice of the smallest. So there are some permutation of the three in terms of their order:

x1<=3 x1-x2<=x2-x1 && 2 x1<=x2-x1
3 x1-x2<=x1<=x2-x1 && 2 (3 x1-x2)<=x2-x1

....
with the rest 4 similar conditions.

How do I form these conditions automatically (together with 0<=x1,x2<=1), and then feed them into Reduce one-by-one, and solve for x2 in terms of x1?

Many thanks!

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

任性一次 2024-10-18 21:07:10
eqs = {x1, 3 x1 - x2, x2 - x1};
Reduce[Max[eqs] >= 2 Min[eqs], {x1, x2}, Reals]

如果您想与第二大或第三大/最小进行比较,则可以使用 RankedMax

至于求解 x2 - 有许多不同的 x2 值对应到每个x1所以你不能用传统意义上解决它,你可以从RegionPlot看到它

RegionPlot[Max[eqs] >= 2 Min[eqs], {x1, 0, 1}, {x2, 0, 1}, PlotPoints -> 100]
eqs = {x1, 3 x1 - x2, x2 - x1};
Reduce[Max[eqs] >= 2 Min[eqs], {x1, x2}, Reals]

If you want to do comparisons with second-largest or third largest/smallest then can use RankedMax

As far as solving it for x2 -- there are many different values of x2 corresponding to each x1 so you can't solve it in the conventional sense, you can see it from RegionPlot

RegionPlot[Max[eqs] >= 2 Min[eqs], {x1, 0, 1}, {x2, 0, 1}, PlotPoints -> 100]
愛放△進行李 2024-10-18 21:07:10

使用 MaxMin 并在变量列表中的 x1 之前指定 x2,如下

In[1]:= Reduce[
         Max[x1, 3 x1 - x2, x2 - x1] >= 2 Min[x1, 3 x1 - x2, x2 - x1] && 
         0 <= x1 && x2 <= 1, 
         {x2, x1}]

Use Max and Min and specify x2 before x1 in the variable list, as follows

In[1]:= Reduce[
         Max[x1, 3 x1 - x2, x2 - x1] >= 2 Min[x1, 3 x1 - x2, x2 - x1] && 
         0 <= x1 && x2 <= 1, 
         {x2, x1}]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文