I define a function and then define another function, using the same name for the dummy variables as I used for the first function. Will Mathematica use the first definition in the second definition? I hope not. The code should make my question a little clearer:

s[t_] := Integrate[Sqrt[Sinh[t]^2 + Cosh[t]^2 + 1], t]
t[s_] := ArcSinh[s/Sqrt[2]]

I don't want the s in the second line of code to be identified with the s defined in the first line of code. Obviously, I could just use a different name, but I want to understand the scope of what I naively assume are dummy variables.

  • $\begingroup$ How do I take the tour? $\endgroup$
    – Gene Naden
    Jul 18, 2018 at 19:37
  • 1
    $\begingroup$ OK I went through and did the upvoting. It was not clear whether I can vote on questions that were put on hold or closed. As for the link, the color is very subtle on my machine. I will keep an eye out for the color. $\endgroup$
    – Gene Naden
    Jul 18, 2018 at 19:48
  • 1
    $\begingroup$ Related: What is the distinction between DownValues, UpValues, SubValues, and OwnValues? $\endgroup$ Jul 18, 2018 at 19:56
  • $\begingroup$ It is preferable to have minimal examples. Functions like Sinh in you code are distracting from the actual content of your question. $\endgroup$
    – Hector
    Jul 18, 2018 at 20:01

1 Answer 1


First try a smaller example.

s[t_] := Integrate[Sin[t], t];
t[s_] := s + 1;
{s[x], t[3]}
(*{-Cos[x], 4}*)

It yields your expected result. On the other hand,

w = 1; Integrate[Sin[w], w]
(*Integrate::ilim: Invalid integration variable or limit(s) in 1.*)

does produce an error. So we have two seemingly contradictory pieces of information. The second example does show that Mathematica does not create dummy variables for integration as it does for for sums:

i = 1; Sum[i, {i, 4}]

Why did the small example work? Because t[s_] := … does not assign values to t but values to t[s_]:

{HoldPattern[t[s_]] :> s + 1}

Compare to

{HoldPattern[w] :> 1}

Reading the documentation of Integrate, the only hint at Integrate not creating dummy variables is the sentence

The integration variable can be a construct such as x[i], or any expression whose head is not a mathematical function.

Compare that to the documentation of Sum where it is explicitly stated that

The iteration variable i is treated as local, effectively using Block.

Finally, notice that you can always "test" whether dummies were created by assigning a value to the would-be dummy (the way w and i were assigned above). In that sense, the u in the pattern u_ below is a dummy:

u = 1;
f[u_] := u;
  • $\begingroup$ I get that function definition uses dummy variables and Integrate does not, but I do not understand the example of OwnValues and DownValues. I guess every symbol has rules attached to it, right? $\endgroup$
    – Gene Naden
    Jul 18, 2018 at 20:06
  • $\begingroup$ The comment by JungHwan Min has a link to an extensive discussion: What is the distinction between DownValues, UpValues, SubValues, and OwnValues?. A very short summary would be: t[s_]:= … assigns the right hand side to the expression t[s_] but the bookkeeping is done under t. On the other hand, t= … assigns the right hand side to the expression t and the bookkeeping is done under tas well. $\endgroup$
    – Hector
    Jul 18, 2018 at 20:22
  • $\begingroup$ A "function definition" does not use "dummy variables". s_ is a named pattern. SetDelayed (:=) makes a definition that replaces instances of names on the right hand sides with named patterns on the left hand side. This is profoundly different from the "dummy variables" of other programming languages, although it bears a superficial resemblance. $\endgroup$
    – John Doty
    Jul 19, 2018 at 0:05
  • $\begingroup$ @JohnDoty I did not write that u_ was a variable. I wrote " the u in the pattern u_ below is a dummy". I agree with you that u_ is a named pattern. However, I quote the documentation: "there is nothing special about the name x that appears in the x_ pattern. It is just a symbol, indistinguishable from an x that appears in any other expression." $\endgroup$
    – Hector
    Jul 19, 2018 at 6:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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