PiecewiseExpand[expr]
展开 expr 中嵌套的分段函数以得出一个单分段函数.
PiecewiseExpand[expr,assum]
用假设条件来展开分段函数.
PiecewiseExpand[expr,assum,dom]
在域 dom 之上进行展开.
PiecewiseExpand
PiecewiseExpand[expr]
展开 expr 中嵌套的分段函数以得出一个单分段函数.
PiecewiseExpand[expr,assum]
用假设条件来展开分段函数.
PiecewiseExpand[expr,assum,dom]
在域 dom 之上进行展开.
更多信息和选项
- PiecewiseExpand[expr] 的结果通常是 Piecewise[{e1,e2,…}],其中任何 ei 都不包括 Piecewise.
- PiecewiseExpand 将诸如 If、Which、Abs、Max、UnitStep 和 Floor 的函数转换为 Piecewise.
- PiecewiseExpand[expr,assum,dom] 假设在 expr 中出现的每一个函数的输入和输出都在 dom 域内.
- dom 的一般选择是 Reals 和 Complexes.
- PiecewiseExpand 尽可能地化简 Piecewise 中的条件组合.
- 可以给出下列选项:
-
Assumptions $Assumptions 添加 assum 的缺省的假设条件 Method Automatic 要是用的方法 TimeConstraint 30 对每个条件组化简的时间(以秒为单位)
范例
打开所有单元 关闭所有单元基本范例 (1)
Piecewise[{{Piecewise[{{1, x < 1}}, 2], x > 0}}, 3]PiecewiseExpand[%]把一个特殊的分段函数组合转化为单一的 Piecewise 对象:
If[x > 0, Max[x, y], UnitStep[y]]PiecewiseExpand[%]范围 (5)
Piecewise[{{Piecewise[{{1, x ≥ 0}}, 2], Piecewise[{{x, x ≤ 1}}, x / 2] ^ 2 ≥ 1 / 2}}, 3]PiecewiseExpand[%]PiecewiseExpand[Max[a, b, c, d]]PiecewiseExpand[Floor[x], 0 < x < 4]PiecewiseExpand[PrimePi[x], 0 < x < 6]PiecewiseExpand[0 < Floor[x + Round[x ^ 2]] - x < 4]PiecewiseExpand[Max[Abs[x], Abs[y]], Reals]选项 (11)
Assumptions (3)
PiecewiseExpand[Floor[x], x > 0, Assumptions -> x < 3]Assumptions 选项的缺省值是 $Assumptions:
Assuming[0 < x < 3, PiecewiseExpand[Floor[x]]]当假设条件作为参数给出,也可以应用于 $Assumptions:
Assuming[x ^ 2 < 3, PiecewiseExpand[Floor[x] + Round[y], y ^ 2 < 2]]指定假设条件为一个选项值,阻止了 $Assumptions 使用:
Assuming[x ^ 2 < 3, PiecewiseExpand[Floor[x] + Round[y], Assumptions -> y ^ 2 < 2]]Method (6)
Method 选项容许对与分段函数相关的本地系统选项进行设置:
SystemOptions["PiecewiseOptions"]pw = Min[x ^ 2 + 2x - 2, Max[2x ^ 2 - 3x + 4, x ^ 2 - 3]];PiecewiseExpand[pw]用 Reduce 来化简条件:
PiecewiseExpand[pw, Method -> {"ConditionSimplifier" -> Reduce}]在默认情况下,PiecewiseExpand 用 Together 对值化简:
pw = UnitStep[x + 1] - UnitStep[x - 1](Sin[x] ^ 2 + Cos[x] ^ 2) + 1PiecewiseExpand[pw]用 Simplify 来化简值:
PiecewiseExpand[pw, Method -> {"ValueSimplifier" -> Simplify}]在默认情况下,由 PiecewiseExpand 产生的条件没有交集,则不能重新排序:
pw = Piecewise[{{Piecewise[{{Piecewise[{{4, a}}, 2], b}}, 3], c}}, 1]PiecewiseExpand[pw]PiecewiseExpand[pw, Method -> {"OrderlessConditions" -> True}]在默认情况下,所有特殊的分段函数都要转换成 Piecewise:
pw = If[x > 0, UnitStep[x - 1], Max[x, y]];PiecewiseExpand[pw]PiecewiseExpand[pw, Method -> {"ExpandSpecialPiecewise" -> {If, UnitStep}}]PiecewiseExpand[-1 ≤ Max[x, y] ≤ 1]设置 "BooleanResult"->False 时,表达式用 Piecewise 来表示:
PiecewiseExpand[-1 ≤ Max[x, y] ≤ 1, Method -> {"BooleanResult" -> False}]设置 "BooleanResult"->True 时,所有的值假定为布尔型:
PiecewiseExpand[If[a, b, c]]PiecewiseExpand[If[a, b, c], Method -> {"BooleanResult" -> True}]TimeConstraint (2)
PiecewiseExpand[Max[x ^ 6 + y ^ 6 + z ^ 6 - x y z, 0], (x - 1) ^ 2 + (y - 1) ^ 2 + (z - 1) ^ 2 ≤ 1 / 4]//TimingPiecewiseExpand[Max[x ^ 6 + y ^ 6 + z ^ 6 - x y z, 0], (x - 1) ^ 2 + (y - 1) ^ 2 + (z - 1) ^ 2 ≤ 1 / 2]//TimingPiecewiseExpand[Max[x ^ 6 + y ^ 6 + z ^ 6 - x y z, 0], (x - 1) ^ 2 + (y - 1) ^ 2 + (z - 1) ^ 2 ≤ 1 / 4, TimeConstraint -> 1]//TimingPiecewiseExpand[Max[x ^ 6 + y ^ 6 + z ^ 6 - x y z, 0], (x - 1) ^ 2 + (y - 1) ^ 2 + (z - 1) ^ 2 ≤ 1 / 2, TimeConstraint -> 1]//Timing属性和关系 (11)
PiecewiseExpand 返回一个单一的 Piecewise 对象:
pw = Boole[x ≥ y ^ 2] + Piecewise[{{Max[x, y], x ≥ 0}, {UnitStep[x + 2], x > -5}}, y]PiecewiseExpand[pw]Min,Max,UnitStep 和 Clip 是实数自变量的分段函数:
PiecewiseExpand /@ {Min[x, y], Max[x, y, z], UnitStep[x], Clip[x, {a, b}]}Abs,Sign 和 Arg 在自变量假设为实数时的分段函数:
Assuming[Element[x, Reals], PiecewiseExpand /@ {Abs[x], Sign[x], Arg[x]}]KroneckerDelta 和 DiscreteDelta 是复数自变量的分段函数:
PiecewiseExpand /@ {KroneckerDelta[x, y], DiscreteDelta[x, y]}Boole 是布尔型自变量的分段函数:
PiecewiseExpand[Boole[a]]PiecewiseExpand /@ {If[a, x, y], Which[a, x, b, y, c, z], Switch[u, v, x, w, y]}转换 Floor、Ceiling、Round、IntegerPart 和 FractionalPart 为有限的范围:
Assuming[{0 ≤ x ≤ 3}, PiecewiseExpand /@ {Floor[x], Ceiling[x], Round[x], IntegerPart[x], FractionalPart[x]}]Assuming[0 ≤ k ≤ 3m, PiecewiseExpand /@ {Mod[k, m], Quotient[k, m]}]UnitBox 和 UnitTriangle 是含有实参的分段函数:
PiecewiseExpand /@ {UnitBox[x], UnitTriangle[x]}有限范围内转换 SquareWave、TriangleWave 和 SawtoothWave :
Assuming[{0 ≤ x ≤ 3}, PiecewiseExpand /@ {SquareWave[x], TriangleWave[x], SawtoothWave[x]}]BernsteinBasis 和 BSplineBasis 是含有实参的分段函数:
PiecewiseExpand /@ {BernsteinBasis[3, 2, x], BSplineBasis[3, 2, x]}可能存在的问题 (1)
f[i_Integer, n_Integer, x_] := Piecewise[{{2 ^ (i - 1), Or @@ Table[j <= x < j + 2 ^ (i - 1), {j, 2 ^ (i - 1), 2 ^ n, 2 ^ i}]}}]sums 的第
个元素是
个分段函数的和,每个分段有两种情况:
sums = Table[Sum[f[i, n, x], {i, n}], {n, 10}];Length[First[PiecewiseExpand[#]]] + 1& /@ sums这显示 sums 中的第四个被加元素数的图形;它们的和用红色表示:
{Plot[Evaluate@Table[f[i, 4, x], {i, 4}], {x, 0, 16}, PlotRange -> {0, 16}],
Plot[Evaluate@Sum[f[i, 4, x], {i, 4}], {x, 0, 16}, PlotStyle -> Red]}技术笔记
-
▪
- 逻辑和分段函数
历史
2004年引入 (5.1)
文本
Wolfram Research (2004),PiecewiseExpand,Wolfram 语言函数,https://reference.wolfram.com/language/ref/PiecewiseExpand.html.
CMS
Wolfram 语言. 2004. "PiecewiseExpand." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/PiecewiseExpand.html.
APA
Wolfram 语言. (2004). PiecewiseExpand. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/PiecewiseExpand.html 年
BibTeX
@misc{reference.wolfram_2026_piecewiseexpand, author="Wolfram Research", title="{PiecewiseExpand}", year="2004", howpublished="\url{https://reference.wolfram.com/language/ref/PiecewiseExpand.html}", note=[Accessed: 03-November-2026]}
BibLaTeX
@online{reference.wolfram_2026_piecewiseexpand, organization={Wolfram Research}, title={PiecewiseExpand}, year={2004}, url={https://reference.wolfram.com/language/ref/PiecewiseExpand.html}, note=[Accessed: 03-November-2026]}