Reputation
Next tag badge:
821/400 score
77/80 answers
Badges
6 232 498
Impact
~1.1m people reached

12h
comment UnitaryMatrixQ function not returning true for a unitary matrix
@Xavier While sometimes annoying, these Automatic settings are understandable. They want to provide a reasonable default for users, depending on the input. I just implemented a Method option for a shortest path function in IGraph/M today. The default is Automatic and the method it chooses depends on whether the graph is weighted or not, whether there are any negative weights, and the size of the graph. Overall it tries to choose the fastest way that is likely to work well.
12h
comment UnitaryMatrixQ function not returning true for a unitary matrix
@Xavier In practice Automatic means that it could be anything. It could be as simple as SameQ or Equal or it could be a custom function not available to us users. This is pretty common (and pretty annoying) with Mathematica. One example is the ComplexityFunction option of Simplify. People have been asking about this so much that they finally included it in the documentation. But Automatic generally means: unknown unless explicitly documented. My guess is that it's not a single function but selected based on the type of matrices. It is likely different for numeric and symbolic.
14h
comment Reproduce image effect in Mathematica
@macurie One more note: do not export by right-click -> Save Graphics As... You must use the Export command to make sure the effect disappears.
14h
comment Reproduce image effect in Mathematica
@macurie I cannot see this on my high-res screen but I think I know what you mean. Mathematica tends to round everything to screen pixels, which can induce the moire-like effect you describe. Export the graphics to PDF, and view it with a PDF viewer. Alternatively export it to a bitmap at very high resolutions and downscale it to a a more reasonable size. The effect should disappear.
15h
comment ImageSize as absolute (metric) value
@Kuba There's also an in-notebook ruler: mathematica.stackexchange.com/a/750/12
15h
comment ImageSize as absolute (metric) value
@Kuba The ImageResolution option can change this 72. It has to be used in Rasterize or Export. Another thing: do not use ImageSize in Export, use it instead as a Graphics option to get the desired result. Export[..., g, ImageSize -> ..., ImageResolution -> ...] is bad. Export[..., Show[g, ImageSize -> ...], ImageResolution -> ...] is good. At least for bitmap formats like PNG. But I don't understand why!
15h
comment ImageSize as absolute (metric) value
@Kuba When exporting graphics, it's true (with default settings) that pp = px. But I am not certain about exporting other notebook objects, such as Row, Column or Legended (!!!). I think Mma was using the "Printout" environment for notebook objects which has a smaller-than-one scaling factor by default. I don't remember the details, but I know Alexey Popkov had either a question or answer (or both?) on this topic (shrinkage with Printout environment).
17h
comment Small World network on a square grid
@ResidentStiefel Let me know if you have any trouble with IGraph/M! What OS are you using?
20h
comment Small World network on a square grid
Marginal to your question, but it's good to not that if you start with the grid shown here, the rewired networks will not have the small world property as originally defined by Watts and Strogatz because a simple lattice like this does not have a high clustering coefficient.
21h
comment UnitaryMatrixQ function not returning true for a unitary matrix
@Xavier Thank you for the comments, I did not know that. Is it otherwise generally true what I said about Q functions? Are you aware of other exceptions (which are not as trivial as IsomorphicGraphQ saying that multigraph isomorphisms is not yet implemented)?
1d
comment Small World network on a square grid
The IGraph/M package has the IGRewire function which will randomly rewire edges while keeping the degree sequence. There's also IGRewireEdges which keeps the total number of edges (thus also the average degree), but it does not preserve the degree sequence. Take a look. These can be implemented in pure Mathematica too, but I would be lazy to do that ;-) GridGraph will be useful too.
1d
comment UnitaryMatrixQ function not returning true for a unitary matrix
it is SameTest -> (FullSimplify[#1 - #2] == 0 &). If the SameTest doesn't return an explicit True, it is automatically assumed to be False (as if TrueQ were applied to it, think TrueQ[a==1]). At least that's my idea about what is happening. Thinking about it like this explains the behaviour and makes some sense. I'm not sure if these comments constitute an answer ... I'll leave them as comments for now.
1d
comment UnitaryMatrixQ function not returning true for a unitary matrix
But the function just says False. So maybe this should be interpreted as "Hermitian for any value of a,b,c,d"? But that interpretation brings its own problems too: sometimes the system just won't be able to check and come to a certain conclusion, yet the function will always return either True or False. So what is going on? I think that what is really happening is that the function computes the required criterion (i.e. $U\dagger U=I$), but then leaves it to the SameTest setting to test that condition. You can set this manually and the documentation gives an example where
1d
comment UnitaryMatrixQ function not returning true for a unitary matrix
Interesting observations. I never used these functions. There's this (as far as I know unwritten) rule that ...Q functions will always return either True or False but nothing else. Think Equal vs SameQ. a==1 stays unevaluated but SameQ always evaluates. It's also a reason why Positive is not PositiveQ: Positive[x] does evaluate until x gets a value. In light of this I find it a little strange that UnitaryMatrixQ and HermitianMatrixQ have the ...Q naming and behaviour. Is {{a,b},{c,d}} Hermitian? Well, it depends on the value of b and c!
1d
comment Rounded rectangle with color gradient
First ideas: You can use Texture or you can write a formula for a rounded rectangle and use RegionFunction with DensityPlot.
1d
comment Display line number/stack trace of error in script (i.e. batch mode / command line interface)
Mathematica will report the line number of a syntax error. It cannot report the line number of an arbitrary Message because there's no direct link between the in-memory program and the source file. In most of the cases there is no source file at all. Definitions can be issued from the command line, or created completely programmatically. Looking at the title of the question my first reaction would be to say, "inherently impossible". But you are not asking only for line numbers but also for some sort of stack trace, which should be possible. Therefore I suggest re-titling the question.
1d
comment Using ListInterpolation to get a vector-valued function
You could use Interpolation instead of ListInterpolation, but settling for three ListInterpolations might be easier actually. Personally I would go for three ListInterpolations.
1d
comment Using ListInterpolation to get a vector-valued function
Can you note in your question that Interpolation does support interpolating arbitrary dimensional vectors? Just to get this out of the way.
1d
comment read Python-generated data file
How many elements are there approximately? The simplest solutions tend to be the slowest, and often Interpreter is the simplest: Interpreter["ComplexNumber"]["-0.998722569699-0.000124681423362j"] does work for this form.
1d
comment How to equate coefficient of two polynomials?
Are you looking for SolveAlways?