Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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?

share|improve this question
1  
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

1 Answer 1

up vote 1 down vote accepted

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$
share|improve this answer
    
Thanks so much +1 –  Babak S. Apr 10 '13 at 16:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.