Distribute
Usage
• Distribute[f[ , , ... ]] 将 f 分配到出现在任意  中的 Plus上.
• Distribute[expr, g] 分配到g.
• 只用expr 的头为f时,Distribute[expr, g, f] 才进行分配.
Notes
• Distribute有效地实现了算子 f 和 g的分配律. • Distribute明确建立一个分布的完整结果;相反地, Expand只简单地在每一阶段重复建立结果. • 例如: Distribute[f[a+b,c+d]]  . • Distribute[f[a+b,g[x,y],c], g]  . • Distribute[expr, g, f, gp, fp]在分配结果中分别使用 gp 和 fp来代替 g 和 f.
Further Examples
This expresses the classic distributive law of multiplication over addition.
In[1]:=
|
Out[1]=
|
Here is an equivalent way to write the input.
In[2]:=
|
Out[2]=
|
This is how taking a power distributes over addition.
In[3]:=
|
Out[3]=
|
We can generalize this to an arbitrary function.
In[4]:=
|
Out[4]=
|
Here we distribute over a product instead of a sum (two variations).
In[5]:=
|
Out[5]=
|
In[6]:=
|
Out[6]=
|
This example is similar to ComplexExpand. (In ComplexExpand the exponent has to be a number.)
In[7]:=
|
Out[7]=
|
In[8]:=
|
Out[8]=
|
Subsums of a list gives all the possible sums of sublists of the list.
In[9]:=
|
In[10]:=
|
Out[10]=
|
In[11]:=
|
|