# Tag Info

31

MatrixForm is a wrapper that pretty-prints your matrices. When you do the following: cov = {{0.02, -0.01}, {-0.01, 0.04}} // MatrixForm you're assigning the prettified matrix to cov (i.e., wrapped inside a MatrixForm). This is not accepted as an input by most functions (perhaps all) that take matrix arguments. What you should be doing to actually assign ...

19

The problem lies in g[x_] := D[f[x], x]; remember that what SetDelayed (that is, :=) does is to replace stuff on the right corresponding to patterns on the left before evaluating. Thus, when one does something like g[2] (and something like this happens within Plot[]), you are in fact evaluating D[f[2], 2], and since one cannot differentiate with respect to a ...

19

Presumably your Notebooks are not being saved in a Trusted Path. Start by reading the tutorial Notebook Security, and note: If the notebook's directory is trusted, the notebook will be allowed to automatically perform dynamic evaluations without alerting the user. If the notebook's directory is untrusted, the user will be alerted upon any attempt by the ...

16

Two of the most common error messages that users encounter when working with parts of lists are Part::partd and Part::partw (look up Message for the error message syntax). Both of these are because the user is trying to access an invalid part of the expression (the "object" referred to in the error message), but there's a subtle difference between the two: ...

16

A bit of historic background Before Mathematica version 6 graphics were produced as a side-effect much as Print works now. In fact you can load this old system using: << Version5Graphics Now you get this behavior: Note that the output is - Graphics - and the plot itself is handled like Print. Since there was often little value in having - ...

15

The problem we encounter here is an instance of rather unexpected limitations of equation solving functionality (i.e. Modulus option in Reduce), e.g. this question : Strange behaviour of Reduce for Mod[x,1] provides another example which has been fixed in the newest version (9.0) of Mathematica. Since Modulus unexpectedly doesn't work here we can take ...

14

You can switch off the 1/0 messages with Off[Power::infy] Now 1/0 only returns ComplexInfinity. If you want to intercept that (your "prevent the divide-by-zero operation from happening in the first place" seems to imply that) you'd have to redefine Power[0,-1]: Unprotect[Power] Power[0, -1] = ...; Protect[Power] with '...' a definition of your choice. ...

14

This is not a bug, the tick specification used in the documentation is incorrect. The tick specification in these examples is {bottom, left} which is the short form of {bottom, left, top, right} which was an older tick specification that was deprecated in v7 (according to the docs). But, it was allowed to continue to work until v10. The form you are ...

13

Here is a function findBadSets that will find any explicitly bad Set/SetDelayed attempts in a given expression. Simply wrap it around a syntactically complete block of code, or follow the block with // findBadSets and the errors are printed one per row, protected symbol followed by complete left-hand side for each bad Set: (* your example *) // findBadSets ...

12

J. M. has already given you a good answer to your question on the General::ivar error and how to avoid it. I wanted to demonstrate another example in the same spirit, where the difference between Set and SetDelayed is important, but you don't have the luxury of getting an error message like you did in this case, because it isn't semantically/syntactically ...

12

There is a certain impedance mismatch between lines of code and Mathematica expressions, because Mathematica code is written more or less directly in the parse trees, and the syntax (which encourages nested expressions) was not particularly designed to make lines a really good concept here. That said, this would be a problem in any language, to various ...

12

You could remove the zero from the denominator, and the corresponding entry from the numerator: a = {1, 2, 3, 4}; b = {5, 6, 0, 8}; Pick[a, Positive[b]]/Pick[b, Positive[b]] (* ==> {1/5, 1/3, 1/2} *)

12

This is because the number you used is extremely large. The number of iterations supported (in either Table or Do) seems to be $2^{31}-1$, i.e. the maximum size of a signed machine integer. I believe this is also an upper bound on the size of an array in Mathematica. This limitation is not unreasonable: the size of the Table you are trying to construct is ...

12

MatrixForm is a function to prettyprint matrices and cannot be used in computations. Just leave the MatrixForm away and you're fine: a = {{1, 0, 1, 0}, {2, 1, 1, 1}, {1, 2, 1, 0}, {0, 1, 1, 1}}; inv = Inverse[a]; b = {{0}, {0}, {0}, {1}}; soln = inv.b {{-(1/2)}, {0}, {1/2}, {1/2}} If you want that result displayed (!) in a nice readable way, you can ...

12

I've just uploaded a new version which again should support loading FeynArts, so that FeynCalc and FeynArts can be used from the same session - which I personally find very convenient. See http://www.feyncalc.org/download/ and http://www.feyncalc.org/cgi-bin/diary.pl FeynArts-3.7 is bundled with the release, so you can simply load FeynCalc with ...

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

12

It's not a syntax mistake. Consider it a suggestion, FrontEnd tells you: "maybe you want to plot it as it has no much sense now". Of course it may have sense, it's just a suggestion. If you take a closer look you will find that storing such Plot makes more sense for FE:

11

To understand why you're getting that error, try your code with _ as the pattern and see what elements are returned: list[[Sequence @@ #]] & /@ Position[list, _] (* {List, List, 1, "A", {1, "A"}, List, 1, "B", {1, "B"}, List, 2, "C", {2, "C"}, {{1, "A"}, {1, "B"}, {2, "C"}}} *) You can see that in your case, Position is walking down every branch ...

11

From a very pragmatic point of view, it might be easier to use an external tool such as xlsx2csv (Python script, but other alternatives exist). Then simply import the comma-separated values: ImportString[StringJoin @Riffle[ReadList[OpenRead["!./xlsx2csv.py test.xlsx"], "String"], "\n"], "CSV"]; On a 21 MB XLSX file on my Mac Book Pro, the above takes ...

11

GUIScreenShot[] (without arguments) works perfectly fine on my Mac, although the front end syntax highlighter indicates a missing argument. As a workaround, you can explicitly give it the dimensions of your screen so that all of it is captured. Here's how you can programmatically get your screen size and use it: Needs["GUIKit`"] ...

11

David's answer is correct and the one you need to solve your specific problem. I thought nonetheless that it is worth providing some additional information that might help explain how to diagnose similar issues. Matrix/tensor operations like Dot and Inverse are designed to work with lists, that is, expressions with a Head of List. It also works with ...

11

While the question has been more than answered there are still some things that seem to me worth adding. The first is that, in my opinion, MatrixForm is "essentially" obsolete. If you wish your matrices always look like matrices (in the output) you can set the format type of output cells to TraditionalForm (use the Appearance tab in the Preferences menu). In ...

11

Use NDSolve antiD = NDSolveValue[{f'[x] == Sqrt[1 + x^3], f[0] == 0}, f, {x, 0, 10}] Example usage: Plot[antiD[x], {x, 0, 10}] Alternatively... This works because this function can be antidifferentiated (by Mathematica). antiD = FunctionInterpolation[ Evaluate @ Integrate[Sqrt[1 + x^3], {x, 0, t}, Assumptions -> 0 < t < 10], {t, 0, ...

11

This is almost certainly an out-of-memory crash. The underlying issue is that the OS X front-end is a 32-bit program, so has a process memory limit of around 2 GB. It is normal for an attempted allocation beyond that limit to lead to a crash. A similar size ArrayPlot example I tried on my Windows machine (where the front-end is 64-bit) used more than 3 GB ...

10

The function Shuffle is not defined. If you define it (say, replace it with RandomSample) it works. Apparently, Rotate in the latter part of the code is being applied to the output of a function that uses edgeNoise which, in turn, (because Shuffle is undefined) is producing the error message you are seeing. To replicate what is happening in a simple setting ...

10

You could try something like the following. bounded[Indeterminate] := \$MaxMachineNumber; bounded[x_?NumericQ] := x This gives a very large number instead of Indeterminate so NMinimize keeps searching. NMinimize[bounded[J[{θ0, θ1, θ2}, X1, y1]], {θ0, θ1, θ2}] (* {0.203498, {θ0 -> -25.1613, θ1 -> 0.206231, θ2 -> 0.201471}} *) Incidentally, ...

10

I assume this is caused by the dynamic content becoming active and trying to run its internal code involving standardBasis which is at that moment undefined (and you can't do a Parton an undefined variable). You may add SaveDefinitions->True to your manipulate to store definitions it depends on. SaveDefinitions has the disadvantage that it may cause ...

10

No, Log is the name of the function and Log[x] is the function applied to x. Using Log without the argument is accepted by the system because Log is a symbol just like any other, but it does not make any sense. The correct way to write it is Solve[Log[x]/x^2 == y, x] or Reduce[Log[x]/x^2 == y, x] The latter tries to give you full solution ...

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

10

One possible solution is using Quiet: ds[All, Quiet[#a/#b]&] Another possible solution is using the FailureAction option: ds[All, #a/#b, FailureAction -> None]

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