Tag Info

New answers tagged


Since there's no data source in OP, can't work with it, but I believe your issue boils down to incorrect use of Check: It does not short-ciruit remaining parts of the compound expression, so you'll still get to the Append within even when a message was generated. You need to do the desired append outside of the check, e.g.: res = {}; Do[AppendTo[res, ...


You could use Break to stop the Do iteration: ClearAll[nr]; mat1 = {{-1, 3}, {4, 2}}; mat2 = {{-1, 3}, {nr, 2}}; vec = {1., 1.}; nr = 1; results = Reap[Do[ Check[ Sow[LinearSolve[mat1, vec], sol1]; Sow[LinearSolve[mat2, vec], sol2];, Break[] ]; nr = nr*10.; , {20}], {sol1, sol2}]


Assumptions is an option to Integrate. The message is telling you to add the assumption that x is real (by default, variables are usually treated as complex). f[x_] := Piecewise[{{1, -1/2 <= x <= 1/2}}, 0]; ProbabilityDistribution[ Integrate[f[a], {a, x - 1/2, x + 1/2}, Assumptions -> x ∈ Reals], {x, -2, 2}] For this simple example one ...


As @rasher points out in a comment, the compensated summation form of Total can't be compiled. You can check this using CompilePrint - note the call to MainEvaluate. Needs["CompiledFunctionTools`"] CompilePrint@f2 (* from your question *) There seem to be plenty of options for summing a list in Mathematica. For example, you can use Plus, which ...

Top 50 recent answers are included