Distribute

Distribute[e] distributes the function over the Plus expressions.

Attributes[Distribute] := {Protected}

Simple examples

In[1]:= Distribute[(a + b)*(c + d)]
Out[1]= a*c + b*c + a*d + b*d
In[2]:= Distribute[(a + b)*c]
Out[2]= a*c + b*c
In[3]:= Distribute[foo[a + b, c]]
Out[3]= foo[a, c] + foo[b, c]
In[4]:= Distribute[foo[a, b]]
Out[4]= foo[a, b]
In[5]:= Distribute[foo[a, b] + foo[c]]
Out[5]= foo[c] + foo[a, b]
In[6]:= Distribute[(a + b)*c + a]
Out[6]= a + (a + b)*c
In[7]:= Distribute[((a + b)*c + d)*(e + f)]
Out[7]= (a + b)*c*e + d*e + (a + b)*c*f + d*f
In[8]:= Distribute[foo[a, b], test]
Out[8]= test[foo[a, b]]
In[9]:= Distribute[foo[a, test[b, c]], test]
Out[9]= test[foo[a, b], foo[a, c]]
In[10]:= Distribute[foo[a, test[b, c], test[d, e]], test]
Out[10]= test[foo[a, b, d], foo[a, b, e], foo[a, c, d], foo[a, c, e]]
In[11]:= Distribute[foo[a, test[b, c], test[d, e], bar[a]], test]
Out[11]= test[foo[a, b, d, bar[a]], foo[a, b, e, bar[a]], foo[a, c, d, bar[a]], foo[a, c, e, bar[a]]]
In[12]:= Distribute[a, test]
Out[12]= a
In[13]:= Distribute[a + b, 1]
Out[13]= 1[a + b]
In[14]:= Distribute[bar[a, test[b, c], test[d, e]], test]
Out[14]= test[bar[a, b, d], bar[a, b, e], bar[a, c, d], bar[a, c, e]]
In[15]:= Distribute[test[f, g][a, test[b, c], test[d, e]], test]
Out[15]= test[test[f, g][a, b, d], test[f, g][a, b, e], test[f, g][a, c, d], test[f, g][a, c, e]]
In[16]:= Distribute[foo[], test]
Out[16]= test[foo[]]
In[17]:= Distribute[foo[], test[]]
Out[17]= test[][foo[]]
In[18]:= Distribute[foo, test]
Out[18]= foo