Write a function that reduces compositions of linear operators You are given two functions \$g(x)\$ and \$h(x)\$, each of which takes an integer \$x\$ and returns the number \$ax + b\$ (where \$a\$ and \$b\$ are integers defined in the function).
Your task is to write a function \$f(g, h)\$ that takes these two functions, and returns a function \$k(x) = g(h(x))\$, but where the procedure of \$k(x)\$ is also simply of the form \$ax + b\$.
For example, given \$g(x) = 2x + 3\$ and \$h(x) = 3x + 4\$, you would need to return \$k(x) = 6x + 11\$, and not \$k(x) = 2(3x + 4) + 3\$.
GolfScript, 41 40 23 19 characters
{2,0+%/-{@*+}++}:k;

Thanks to Peter Taylor for pointing out this solution. Accepts two function bodies as arguments.
The following examples show how to use function k:
# As function
{2*3+} {3*4+} k         # =&gt; {11 6 @*+}

# Apply to value
5 {2*3+} {3*4+} k ~     # =&gt; 41

If one wants to retain the original output format, the following 22 character solution is possible:
{2,0+%/-{*}+\+{+}+}:k;

{2*3+} {3*4+} k         # =&gt; {6 * 11 +}

Explanation of the code:
{                       # on stack are functions g h
  2,                    # build array [0 1] -&gt; g h [0 1]
  0+                    # append 0 -&gt; g h [0 1 0]
  %                     # apply function h to each element -&gt; g [h(0) h(1) h(0)]
  /                     # apply function g to each element
                        # and break up the array -&gt; g(h(0)) g(h(1)) g(h(0))
  -                     # subtract last two -&gt; g(h(0)) g(h(1))-g(h(0))
  {@*+}++               # append function body to these values
}:k;                    # save function to variable k