Tag Info

Hot answers tagged

15

To access the errors, you need to invoke the Front End directly from the kernel. In effect, you end up telling the kernel to tell the FE to tell the kernel to do something, so that the FE can report any errors it finds. The method I use is SetAttributes[getFrontEndErrors, HoldAll]; getFrontEndErrors[gexpr_] := Module[{nb}, ...


12

You can do the analytic integral in Mathematica too, by telling it to perform the upper integration limit as follows: With[ { i = Integrate[((r^3 - 7)^(2/3)*(1 - (r^3 - 7)^(2/3)/r^2))/r^3, r] }, Simplify[ Limit[i, r -> Infinity] - i /. r -> 2 ] ] (* ==> 23/64 + Pi/(3 Sqrt[3]) - 2 (-(1/7))^(1/3) Hypergeometric2F1[1/3, 1/3, 4/3, ...


10

Believe the numerical one. Mathematica simply could not do the symbolic integration. Symbolic integration will travel via a different code path. Here the symbolic integration done using Maple, and it agrees with the numerical solution given by Mathematica's NIntegrate The analytical answer is (7/18)*hypergeom([-1/3, 1, 1], [2, 2], ...


8

The number 2045 is suspicious. Add three to it to include stdin, stdout, and stderr, and you get 2048, which I suspect is total number of file descriptors available to you. I conclude your problem is caused by eating up all the available file descriptors. This is usually caused by doing too many file opens without doing any file closings to return some file ...


8

The problem has nothing to do with OpenWrite. You never Close the stream you open in your call to Read. Read, unlike ReadList, does not automatically close a stream (file, pipe, etc.) that's given as its first argument string. (That's because the purpose of Read is to be able to read from the same source in pieces, unlike ReadList which does it all at ...


7

This question probably will not receive a "real" answer because it is based on a misconception about what $MachineEpsilon actually is. But, since the question is upvoted, I suppose there is more than one person who is not yet clear on how this is defined. Therefore, here is a comment to try to clarify the definition and tie up the loose ends of the thread. ...


6

You do it exactly as you would do it on the main kernel. Following example which throws a message when it divides by zero: ParallelMap[1/# &, Mod[Range[30], 3]] Some people prefer to switch specific messages off beforehand. This can be done with ParallelEvaluate[Off[Power::infy]] ParallelMap[1/# &, Mod[Range[30], 3]] Or you use Quiet as ...


6

The problem here is that the Gridlines specification error message is not a kernel error message (you'll note that it is not printed with the standard Func::tag format). Instead, this warning text is generated by the front end during the rendering of the graphic. The actual generation of the gridlines values is deferred to the moment when the graphics ...


6

First, note that turning off messages is technically not the same thing as not printing them. You can avoid printing messages by removing the output channel they're being sent to: $Messages = {} Restore the previous behaviour using $Messages = $Output, provided that you haven't changed $Output. But this won't turn messages off, it will only avoid ...


6

One option would be to restrict the function from funky regions with a Condition liks this f[x_, y_] /; Abs[x - y] > 5 := (Sin[x] - Sin[y])/(x - y); Plot3D[f[x, y], {x, -10, 10}, {y, -10, 10}] Out: One can easily see that Plot3D will also sample points in the region which is "forbidden", the points are just not drawn due to the RegionFunction. ...


5

Somewhat tautologically we can demonstrate that the Front End parses these differently: parseString[s_String, prep : (True | False) : True] := FrontEndExecute[UndocumentedTestFEParserPacket[s, prep]] parseString["?Sin\n2+2"] parseString["??Sin\n2+2"] {BoxData[{RowBox[{"?", "Sin"}], RowBox[{"2", "+", "2"}]}], StandardForm} {BoxData[RowBox[{"??", ...


5

First I'll generate some data in the spirit of what you show. sets = Table[RandomChoice[x Range[1, 2, .5], 20] + RandomChoice[Range[0, 1.5, .5], 20], {i, 5} ]; The issue you are having is a very common one. You must require that only numbers get tried for x if you want this to work because LocationEquivalenceTest cannot work ...


5

This is a short-coming of how the arguments are evaluated. The symbols k.x[t] is treated as a single term, while g is treated as a list; Plus automatically threads over the list creating a little mess: x''[t] == k.x[t] + g (* x''[t] == {1 + {{1.5, 0.}, {0., 1.5}}.x[t], 2 + {{1.5, 0.}, {0., 1.5}}.x[t]} *) If a 2-vector value is substituted for x[t], this ...


5

If you execute the command in your question and do ShowExpression on the output cell containing the pink graphics box, you see the following code: GraphicsBox[{{}, {}, {RGBColor[$CellContext`a], ... This is further indication of what I suggested in the comment - that the error occurred when the FrontEnd was ultimately unable to find a value for a in the ...


5

Not knowing quite what you're doing this may or may not help. I think the problem is you're turning the warnings off in the master kernel and the warnings you're seeing come from the slaves. I'd suggest... ParallelTable[Quiet[your code here],{your iterator here}]; OR ParallelEvaluate[Off[NIntegrate::slwcon]]; ParallelTable[your code here, {your iterator ...


4

By default, NDSolve uses a "shooting" method to satisfy the boundary conditions: it picks an initial condition and then evolves the equation to see what boundary values are produced by the initial conditions. It then rejiggers these initial conditions to produce the boundary values specified by the boundary conditions. Here is the Mathematica documentation ...


4

The ability to recognize vectorial unknowns such as x[t] in NDSolve is a relatively new feature that doesn't seem to work reliably for my applications, either. So I usually find it much safer to do things in a slightly more "old-fashioned" way, by declaring all unknown functions individually using Array. That can be done relatively efficiently and doesn't ...


4

The following expression should result in an error: First@Cases[NotebookGet[EvaluationNotebook[]][[1]], Cell[___, CellTags -> "MyCode", ___]]] because Cases, by default, operates at level {1} and in a notebook's expression, CellTags will never be at level {1}. Thus, Cases returns {} and First throws an error. The solution here, is to use level ...


4

I don't know Python, and there's one aspect of the Python code I don't get; but this does what the last paragraph describes. safeeval[fn_, x_, epsilon_] := ReleaseHold @ Catch @ Quiet @ Check[ fn[x], Check[ ReleaseHold @ Catch @ Quiet @ Check[ fn[x + epsilon], Throw @ Hold[fn[x - epsilon]]], Throw @ ...


3

It looks like you already have your solution, and a rather elegant one at that, but perhaps what is yet lacking is a convenient method that does not require manually writing that nested structure. We can use recursion. The basic form looks like this: SetAttributes[errorTry, HoldAll] errorTry[a_, b__] := Quiet @ Check[a, errorTry[b]] errorTry[x_] := x ...


3

Same idea a belisarius but moving the entire first argument into a separate function, while also localizing x: fn[x0_?NumericQ, v0_?NumericQ] := Module[{x}, {x[0], x'[0]} /. NDSolve[{x''[t] == 1, x'[0] == v0, x[0] == x0}, {x, x'}, {t, 0, 1}] ] StreamPlot[fn[x0, v0], {x0, -2, 2}, {v0, -2, 2}] No errors.


3

So it looks like what you want to do is apply the temporary definitions in defs to code, then show the output. Here's what I came up with. SetAttributes[Rep, HoldAll]; Rep[defs_, code_] := Module[{symsTrans, downVals}, symsTrans = Union[Cases[Hold[defs], HoldPattern[SetDelayed][f_[___], _] :> (f -> "changeMe"[f]), {0, \[Infinity]}]]; ...


3

I believe this is due to special parsing just as I described in: Infix form of PutAppend ( >>> ) does not work with variable. You cannot assume that all input forms are valid syntax at an arbitrary place in an expression. It was my interest in seeing how Mathematica was interpreting certain input (that is, what Box expression were being sent to ...


3

Here is a straightforward way to count the number of nearest neighbor ones in a matrix of zeros. h = RandomChoice[{0.8, 0.2} -> {0, 1}, {10, 10}]; Total[Sign[DeleteSmallComponents[MorphologicalComponents[h], 1]], 2] The h matrix is a 10 by 10 matrix of ones and zeros (change the 10s to change the size) where about 20% of the elements are ones and 80% ...


3

It's a bug: there are more than one call to Message[FindRoot::bbrac], and some of them are suppressed, but only if Quiet is used. Here's a way to check suggested by Szabolcs: messageHandler = Print[{##}] &; Internal`AddHandler["Message", messageHandler]; Quiet@FindRoot[x == 1, {x, 0, 0.5}, Method -> "Brent"] <...> ...


3

This error message may indicate a font problem on Macs. The issue is discussed by WRI at: http://support.wolfram.com/kb/3382 As you can see, the first thing to try is to reset your preferences (reinstalling might not fix this problem since your Base and UserBase directories are not replaced). If that doesn't work, the article steps you through how ...


3

You only have to make sure that the coefficient c[n] in the Fourier series is defined for all n. This means that the If statement defining c[n] must return a value not only for n==0 as it does in your attempt, but also for other values of n. So all you have to do is change your code to c1[n_] := 1/2/Pi Integrate[Sign[x] Exp[-I n x], {x, -Pi, Pi}]; c2[n_] = ...


3

The reason this error occurs is because Set and Part have the Attribute HoldFirst, while functions like Position, which was used to get the position 4, does not have HoldFirst. To verify, the line s[[1]] = Sum[s[[1]] /. b[3] -> k, {k, 3}] adds a parenthesis which does not get evaluated, so (s//Hold)[[1,4]] Out[1] = Part::partw: "Part 4 of ...


3

Assuming there's not a typo in your question, it's doing exactly what it should, meaning perhaps your equation or its entry is incorrect. Using a simplify wrapper: fs[a_] := FullSimplify[a, 0 < r < 1 && r ∈ Reals] I applied it to the blocks of your equation as follows: s1 = fs[4* Pi*(-(r*(1 + r)^2* Sqrt[-(((1 + r)^4 + (-1 + ...


3

According to the documentation center: Goto first scans any compound expression in which it appears directly, then scans compound expressions that enclose this one. Your Goto - Label construction is part of the List so Mathematica fails to find the label. Taking this under consideration, the following will work: k = 0; Do[{ Label[top]; k = k + 1; ...



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