Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Math 两个区间的乘法_Math_Python 3.x_Intervals - Fatal编程技术网

Math 两个区间的乘法

Math 两个区间的乘法,math,python-3.x,intervals,Math,Python 3.x,Intervals,根据从自我培训中挑选的以下问题: 顺便说一下,Ben还隐晦地评论道,“通过测试区间端点的符号,可以将mul_区间分成九种情况,其中一种情况需要两次以上的乘法。”使用Ben的建议编写一个快速乘法函数: 我可以分析,以下是结果的模式: (1, 3)(5, 7) ---> [min(5, 7, 15, 21), max(5, 7, 15, 21)] ---> (5, 21) (-1, -3)(-5, -7) ---> [min(5, 7, 15,

根据从自我培训中挑选的以下问题:

顺便说一下,Ben还隐晦地评论道,“通过测试区间端点的符号,可以将mul_区间分成九种情况,其中一种情况需要两次以上的乘法。”使用Ben的建议编写一个快速乘法函数:

我可以分析,以下是结果的模式:

(1, 3)(5, 7)  ---> [min(5, 7, 15, 21), max(5, 7, 15, 21)]              --->   (5, 21)
(-1, -3)(-5, -7)  --->  [min(5, 7, 15, 21), max(5, 7, 15, 21)]         --->   (5, 21)
+++++++++++++++++++++++++++++++
(1, 3)(5, -7)  --->  [min(5, -7, 15, -21), max(5, -7, 15, -21)]        --->   (-21, 15)
(-1, 3)(5, -7)  --->  [min(-5, 7, 15, -21), max(-5, 7, 15, -21)]       --->   (-21, 15)
(1, -3)(-5, 7)  --->  [min(-5, 7, 15, -21), max(-5, 7, 15, -21)]       --->   (-21, 15)
(-1, -3)(-5, 7)  --->  [min(5, -7, 15, -21), max(5, -7, 15, -21)]      --->   (-21, 15)
+++++++++++++++++++++++++++++++++++
(1, 3)(-5, 7)  --->  [min(-5, 7, -15, 21), max(-5, 7, -15, 21)]        --->   (-15, 21)
(-1, 3)(-5, 7)  --->  [min(5, -7, -15, 21), max(5, -7, -15, 21)]       --->   (-15, 21)
(1, -3)(5, -7)  --->  [min(5, -7, -15, 21), max(5, -7, -15, 21)]       --->   (-15, 21)
(-1, -3)(5, -7)  --->  [min(-5, 7, -15, 21), max(-5, 7, -15, 21)]      --->   (-15, 21)
++++++++++++++++++++++++++++++++
(1, 3)(-5, -7)   ---> [min(-5, -7, -15, -21), max(-5, -7, -15, -21)]   --->   (-21, -5)
(-1, -3)(5, 7)  --->  [min(-5, -7, -15, -21), max(-5, -7, -15, -21)]   --->   (-21, -5)
++++++++++++++++++++++++++++++
(-1, 3)(5, 7)   ---> [min(-5, -7, 15, 21), max(-5, -7, 15, 21)]        --->   (-7, 21)
(1, -3)(-5, -7)  --->  [min(-5, -7, 15, 21), max(-5, -7, 15, 21)]      --->   (-7, 21)
+++++++++++++++++++++++++++++++
(-1, 3)(-5, -7) --->   [min(5, 7, -15, -21), max(5, 7, -15, -21)]      --->   (-21, 7)
(1, -3)(5, 7)  --->  [min(5, 7, -15, -21), max(5, 7, -15, -21)]        --->   (-21, 7)
但是上面的模式并没有显示这九个案例

因此,具体来说,我想了解这一点:
通过测试区间端点的符号,可以将mul_区间分为九种情况,


请帮我做这个区间运算

我不确定我是否完全理解,但是间隔有3种情况
(a1,b1)
a您可以检查这些情况:
调查间隔是否重叠为零,或始终为正或负。您可以将问题分解为最多需要两个倍数的情况

注:原始问题假设x[0] 例如:

if (x[1] <= 0) {
   if (y[1] <= 0) {} // both negative
   if (y[0] >= 0) {} // one negative ane positive
   else {} // y is both negative and positive, x is only negative
}

if (x[0] >= 0) {
   if (y[1] <= 0) {} // one negative ane positive
   if (y[0] >= 0) {} // both positive
   else {} // y is both negative and positive, x is only positive
}
else {} //both overlap zero
如果(x[1]=0){
如果(y[1]=0){}//两者都为正
否则{}//y既为负又为正,x仅为正
}
否则{}//两者都重叠为零

我投票结束这个问题,因为堆栈溢出不是家庭作业服务。你的箭头走错了方向。此外,(-16,8)和(-8,16)是相同类型的结果。应该只有3种结果,但有9种实现方法。另外,请注意(a1,b1)x(a2,b2),其中a11)与值相关?问题是,
通过测试区间端点的符号。2) 我现在改变了箭头标志。你有的更好。现在删除一些案例。例如,任何带有(1,-3)的情况都是不可能的,因为(1,-3)不是一个区间。
if (x[1] <= 0) {
   if (y[1] <= 0) {} // both negative
   if (y[0] >= 0) {} // one negative ane positive
   else {} // y is both negative and positive, x is only negative
}

if (x[0] >= 0) {
   if (y[1] <= 0) {} // one negative ane positive
   if (y[0] >= 0) {} // both positive
   else {} // y is both negative and positive, x is only positive
}
else {} //both overlap zero