I need to understand why my functions doesn't work.

Thus, I have put a Dialog at the beginning of it :

    q = Exp[2 tau];
    (SixJSymbolqDef[{j1, j2, j3}, {j4, j5, j6}, q] - 
      SixJSymbol[{j1, j2, j3}, {j4, j5, j6}]) - 
        ((2*tau)^2 (1/6)) 
          ((1/4) Sum[j[[i]] (j[[i]] + 1), {i, 1, 6}] 
            SixJSymbol[{j1, j2, j3}, {j4, j5, j6}] + 
        Triple[j1, j2, j3, j4, j5, j6])]

The behavior of my function doesn't really matter.

When I evaluate fonction38lhs[0.8], my program freezes because of the dialog and I am able to evaluated commands. But if I want to display the value of tau, it says it is an unknown variable.

To say it differently, my dialog seems to occur out of the function and not inside. Indeed I can show variables of the notebook outside of the function.

How can I gain access to local variable inside of the function within a dialog session?

  • $\begingroup$ tau is not a variable. It is a pattern name. Its value gets substituted directly, without ever assigning a value to the symbol tau. $\endgroup$ – Szabolcs May 29 '17 at 9:26
  • $\begingroup$ When I pass argument to functions I will not be able to check their values inside of the function for example ? $\endgroup$ – StarBucK May 29 '17 at 9:31
  • $\begingroup$ I suggest you use the debugger instead of Dialog[]. $\endgroup$ – Szabolcs May 29 '17 at 9:35
  • $\begingroup$ I used Dialog because someone advised me not to use the debugger here : mathematica.stackexchange.com/questions/146953/… But I feel like mathematica has huge problem with debugging tools... $\endgroup$ – StarBucK May 29 '17 at 9:47
  • 2
    $\begingroup$ Well, I advise you to use the debugger, but do it the way I described it in the answer I linked. Do not try to set any breakpoints using the GUI and you'll be fine. $\endgroup$ – Szabolcs May 29 '17 at 9:59

Inside your function tau is just a number. It does't exist as a variable. To do what you want, you have to introduce an auxiliary variable, say t.

Then you can have session like.



  • Out[154], 8.38906, did not appear until (Dialog) In[157] was evaluated.
  • The returned value of t was used to compute q.
  • Out[157] confirms that t was changed at top-level and that the value returned from fonction38lhs is equal to 1 + Exp[2 t] as it should be.


Another possibility for interacting with tau goes like this,


If you supply tau to Dialog, it becomes available in the dialog session as %.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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