Tag Info

Hot answers tagged

6

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 ...


4

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 ...


3

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, ...


2

The reason for the error message is that C is a reserved system symbol. http://reference.wolfram.com/language/ref/C.html Since C has the attribute Protected, no further definitions can be made for it. http://reference.wolfram.com/language/ref/Protected.html


1

From the comment by Stefan. Try renaming or deleting this file: FileNameJoin[{$UserBaseDirectory, "FrontEnd", "init.m"}]


1

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}]



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