# A function of two functions that loses dependence on an argument

Say I have two functions:

f[a_,b_]:=a + b
g[c_,d_,e_]:=c + d - e


And I define a third function:

h[u_,v_,w_,x_]:=f[u,v]+g[w,x,u]


It's clear (to me, a human, at least) that h doesn't depend on u, but Mathematica still requires this extra argument to define h without trickery. This is a simple situation where I could replace the occurrences of u with something non-divergent, like 1. But for more complicated cases, such a choice could lead to unwanted (and essentially artificial) divergences. Is there a Correct Way (TM) to do this kind of functional definition, or is the general case really impossible for a CAS like Mathematica?

-
Formally, $h$ does require $u$, as the product on the right hand side is undefined when $u=0$. – Craig Nov 7 '11 at 13:20
Craig: see edit, my case here is really an addition of sorts, so no undefined things pop up. – rubenvb Nov 7 '11 at 13:51
Thanks for the Accept. I see you did not upvote my answer however. If it is lacking, please tell me why, and consider un-Accpting it, since then the question is not resolved. Otherwise, please vote for it. – Mr.Wizard Nov 22 '11 at 9:44

You could define your function using Set rather than SetDelayed and use Simplify or FullSimplify to cancel what Mathematica automatically can. I use Module to avoid collisions with global symbols.

f[a_, b_] := a + b
g[c_, d_, e_] := c + d - e

Module[{u, v, w, x},
h[v_, w_, x_] = f[u, v] + g[w, x, u] // Simplify
]


Now the definition of h reads:

h[v$_, w$_, x$_] = v$ + w$+ x$

-
Thanks so much +1 – Babak S. Apr 10 '13 at 16:28