# Tag Info

8

From the docs for Label Label must appear as an explicit element of a CompoundExpression object. So this works: p[1] = .9; i = 1; Label[begin]; i++; p[i] = p[i - 1] + 1; Print[i]; If[i < 5, Goto[begin], Goto[end]]; Label[end]; But this doesn't: p[1] = .9; i = 1; Label[begin]; i++; p[i] = p[i - 1] + 1; Print[i]; If[i < 5, Goto[begin], ...

6

I think the information given by AbsoluteOptions will be enough to distinguish one type of Notebook from another. To investigate the differences among the option values of different Notebooks, we first prepare all six types of Notebooks: nblist = Complement[Notebooks[], {EvaluationNotebook[]}] Then we extract all of their AbsoluteOptions, and delete ...

5

You could achieve without If, e.g.: f[x_Integer] := StringForm[" is an integer", x]; f[x_] := StringForm[" is not an integer", x]; Test: test = {1, 3, Pi, E, Sqrt[2], Zeta[3], Zeta[-2]} Mapping: Column[f /@ test] yields: Please note IntegerQ[3] is True, however IntegerQ[3.] is False

5

The third parameter allows control of Optional behavior for multiple function definitions. It is not attached to the number of actual arguments passed to the function but rather to the number of arguments that appear in the function definition itself. Consider this example: ClearAll[f]; Default[f, 1, 3] = a1; Default[f, 2, 3] = a2; Default[f, 3, 3] = a3; ...

5

You can pass a function (or for that matter, anything!) as an argument to another function and you'll need to modify your code accordingly. See this example: ChebyCoeff[func_, m0_] := Module[{m = m0}, f[t] = func[2 Pi t]; Tn[t] = ChebyshevT[j, 2*t - 1]; wt[t] = 1/Sqrt[t - t^2]; p = Table[Chop[NIntegrate[f[t]*Tn[t]*wt[t], {t, 0, ...

4

OK, as an after-meal exercise, I fixed your code. The main modifications I've done are: 1. Based on trick mentioned in this post, change your pattern-matching function into pure function. 2. Change qsum = MapThread[Plus, #] &@Rq(for some unclear reason it can't be compiled, maybe it's because Rq isn't a "explicit" list? ) into qsum=Total@Rq. 3. ...

4

I think the most straight forward would be to use Mathematica packages and importing the definitions in that notebook using the function Get as Szabolcs mentioned in the comments. I suggest that you have a closer look at the documentation on how to set up packages in Mathematica. Th principle is quite simple to understand. Here is a small example of how ...

3

Is this what you are after? Using WhenEvent to find the extrema.. s = Reap[ NDSolve[{y''[t] + (a + b Cos[t]) y[t] == 0, y[0] == 1, y'[0] == 0, WhenEvent[ y'[t] == 0 && y[t] > 0 , Sow[{ t, y[t]}]]}, y, {t, 0, 50}] ] Show[ Plot[Evaluate[y[t] /. s[[1]]], {t, 0, 50 }, PlotRange -> All], ListPlot[s[[2, 1]], ...

2

As was initially mentioned in the comments, you can use the levelspec argument of MapThread to get the behavior you were expecting, but you can also set your floExct function to have the Listable attribute. This is why Plus works well for your first example snippet. In[11]:= floExct[n_, ku_, qr_] := Min[100*ku, (2500*n) - qr]; SetAttributes[floExct, ...

1

You can do that this way: Values = {{1, 2}, {3, 4}, {5, 6}}; VariableS = {{x1, x2}, {x3, x4}, {x5, x6}}; MapThread[Set, {VariableS, Values}, 2]; Integrate[Sin[x], {x, x1, x2}] Cos[1] - Cos[2] Your way is not working because VariableS[[1]] = Values[[1]]; sets the value of the first element of VariableS not the symbol names stored there.

1

I suppose it wouldn't hurt to add a bit of explanation here. Plus is Listable, which is why Plus[{a, b}, {c, d}] evaluates to {Plus[a, c], Plus[b, d]} (it automatically threads over lists in its arguments). In fact, you did not need to use MapThread at all: Plus[Take[#, {3, -2}] & /@ kr, Take[#, {4, -1}] & /@ Rk, Take[#, {3, -2}] & /@ qsum] ...

1

With 1. the note about the behavior of ReplacePart inside Compile made by Daniel Lichtblau and Albert Retey in the comments above, 2. the correction for the simple mistake {a2, _Real} {a3, _Real}, 3. the note about All inside Compile here, 4. a modification for the uncompiled definition of qr i.e. changing qr = MapThread[Join[#1, {#2}, #3, {#4}] ...

1

Names["FrontEnd*" ~~ "" ... ~~ "Notebook"] // Column gives FrontEndButtonNotebook FrontEndClipboardNotebook FrontEndDebuggerStackNotebook FrontEndEvaluationNotebook FrontEndHelpBrowserNotebook FrontEndInputNotebook FrontEndMessagesNotebook FrontEndSelectedNotebook FrontEnd`SetSelectedNotebook Of these, the following seem useful for filtering ...

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