# Tag Info

12

Nothing is like Sequence[]: it gets removed during evaluation. But there is one significant difference: it only gets removed from lists. {{Nothing}, {Sequence[]}} (* {{}, {}} *) {foo[Nothing], foo[Sequence[]]} (* {foo[Nothing], foo[]} *) Update from @ilian It only gets removed from lists is correct for Mathematica 10.4.0 and later; Nothing did get ...

11

To understand this, look at the typesetting: In[1]:= ToBoxes[Button["Print", Dynamic[a++]]] // InputForm Out[1]//InputForm= ButtonBox["\"Print\"", ButtonFunction :> Dynamic[a++], Appearance -> Automatic, Evaluator -> Automatic, Method -> "Preemptive"] Front end options, which includes all box options, can take Dynamic heads. That basically ...

6

It's not a bug and it's not so uncommon. For an explanation have a look here. This and some related issues also appear in this MathGroup thread. Also relevant: 1 2.

5

You can use Trace with TraceDepth option set to 1 to get evaluation steps giving whole expression, and format result as you want it. Function performing this actions can be assigned to $Pre to be automatically used for all inputs. ClearAll[showSetSteps] SetAttributes[showSetSteps, HoldAllComplete] showSetSteps[Set[lhs_, rhs_]] := With[{trace = Replace[... 5 Actually the observed behavior is in full accord with the HoldAll attribute, just check what happens when there is no such attribute: nIntegrate[x + x, {x, 1, 2}] // Trace {{x + x, 2 x}, nIntegrate[2 x, {x, 1, 2}]} From the above it is seen that the arguments are evaluated before applying the rules associated with the function nIntegrate. The purpose ... 5 From the "Details and Options" section in the docs: NIntegrate first localizes the values of all variables, then evaluates f with the variables being symbolic, and then repeatedly evaluates the result numerically. So I guess this is expected behavior. 5 Albert Retey has demonstrated in a similar situation that you can use "EventLocator" to detect an event in NDSolve. For example: eqn = {\!$$\*SubscriptBox[\(∂$$, $$t$$]$$u[t, x]$$\) == 1/100 \!$$\*SubscriptBox[\(∂$$, $$x, x$$]$$u[t, x]$$\) - u[t, x] \!$$\*SubscriptBox[\(∂$$, $$x$$]$$u[t, x]$$\), u[0, x] == Sin[2 π x], u[t, 0] == u[t, 1]}; NDSolve[... 4 This was introduced in 10.0 and fixed in 10.3. curve1 = {Cos[φ] (4. - 1. Cos[4 φ] + 1. Cos[8 φ] - 1. Cos[12 φ]), (4. - 1. Cos[4 φ] + 1. Cos[8 φ] - 1. Cos[12 φ]) Sin[φ]}; curve2 = 2. - 1. Cos[4 φ]; tangent1 = D[curve1, φ]; surface = {{Cos[3 z], Sin[3 z], 0}, {-Sin[3 z], Cos[3 z], 0}, {0, 0, 1}}.Append[(1 - Sqrt[1 - Abs[z]]) (... 3 Since you referenced How do I evaluate only one step of an expression? I might use: (* step loaded from referenced Q&A *) mySet[str_String, val_] := step @ Symbol[str] /. _[s_Symbol] :> (s = val) Now: x = 5; mySet["x", 7]; x 7 (This also makes use of Injecting a sequence of expressions into a held expression.) For clarity the above is ... 3 They are not identical computations. With the first form, (mu/2 gt).gt Mathematica can take advantage of vector arithmetic, usually going through specialized routines like LAPACK. The second form, Sum[(mu[[i]]/2 gt[[i]]) gt[[i]], {i, Length@mu}] however, will usually be calculated term by term because there is a possibility that the input can change ... 3 Fundamentally this is a very common question: Reassign values to symbols How do you programatically load data into symbols? How to pass a symbol name to a function with any of the Hold attributes? MapThread gives different results from ToExpression when trying to assign variables from a list Assigning values to a list of variable names Elegant ... 3 tl;dr You need to call Needs before GetBoundaryMesh definition so it can be parsed correctly or you have to use the full name of ToBoundaryMesh. Confession My recent comment is partially incorrect$Context or $ContextPath changes (done by Get/Needs/BeginPackage and friends) are reflected after/between evaluations[...] Changes of$Context/\$...

2

A method is to write a message handler, like in this answer. The handler is passed an argument of the form Hold[Message[...], boolean] where the boolean tells the handler if the message is to be displayed, or not. Since you are looking to capture the info passed to NDSolve::ndsz, I would write the handler like Clear[messageHandler, vals]; vals = {}; ...

2

Do you mean: ClearAll[A] Attributes@A = HoldAll; A[f[n_]] := A[f[n]] = Module[{d}, d = Numerator@f[n - 1]] I've removed the redundant Return. Module is also irrelevant here actually. Anyway, I suppose you need Module in your real problem so don't take it away. Or you need f to be arbitrary, too? Then: ClearAll[A] Attributes@A = HoldAll; A[f_[n_]] := A[f[...

1

This isn't a very satisfactory answer, but it turns out that this exact same code works on version 10.4.0 for Linux x86 (64-bit) (February 26, 2016) on the same OS and laptop, and as @JHM points out it works on a Windows machine, therefore I suspect this might be a version+OS specific bug. In any case, my problem is solved.

1

With ver 10.4.1, I am unable to evaluate dNdz[0, 12] using the code provided in the question, instead getting the error message, NIntegrate::inumr: The integrand ddndLogMdz[0,var] has evaluated to non-numerical values for all sampling points in the region with boundaries {{12,20}}. >> This occurs because the derivatives of delta and Sigma are undefined....

Only top voted, non community-wiki answers of a minimum length are eligible