Mathematica 9 is now available
 Documentation / Mathematica / Built-in Functions / Programming / Functional Programming  /
Distribute

  • Distribute[ f [ , , ... ]] distributes f over Plus appearing in any of the .
  • Distribute[ expr , g ] distributes over g.
  • Distribute[ expr , g , f ] performs the distribution only if the head of expr is f.
  • Distribute effectively implements the distributive law for operators f and g.
  • Distribute explicitly constructs the complete result of a distribution; Expand, on the other hand, builds up results iteratively, simplifying at each stage.
  • Example: Distribute[f[a+b,c+d]].
  • Distribute[f[a+b,g[x,y],c], g].
  • Distribute[ expr , g , f , gp , fp ] gives gp and fp in place of g and f respectively in the result of the distribution.
  • See the Mathematica book: Section 2.2.10.
  • See also: Expand, Thread, Outer, Inner.

    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]=



    Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
    THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
    SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.