Szabolcs
Reputation
87,973
821/400 score
 22h 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. 22h answered UnitaryMatrixQ function not returning true for a unitary matrix 22h 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. 22h 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 22h 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 revised Display line number/stack trace of error in script (i.e. batch mode / command line interface) added 13 characters in body 1d revised Display line number/stack trace of error in script (i.e. batch mode / command line interface) added 242 characters in body 1d answered Display line number/stack trace of error in script (i.e. batch mode / command line interface) 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? 1d comment read Python-generated data file If you are exporting the data from Python yourself, the best solution will be to split the complex numbers into real and imaginary parts and export them as distinct units. Parsing special forms in Mathematica is possible but not fast. If your data file is a simple table with only real numbers, there are very fast builtin functions to read it. 1d comment Is the “Custom Extension of C” that Mathematica is partially written in available for use or review? In any large software project written in C you will find some standardized patterns in how things are implemented. These are often packaged into macros. There are many examples, take a look e.g. at how igraph allocates and frees resources. I think you are reading way too much into this and that's all there is to it. As you know Mathematica is closed source, so no, there's no public documentation on its source code. 1d comment Importing LaTex Have you tried CreateDocument? I do not understand your comment. It will give you the text in a readable, copyable, editable form. 2d comment Importing LaTex You can use it with CreateDocument, or you can pick it to parts and do something with the cells separately. 2d comment How was Mathematica built? reference.wolfram.com/language/tutorial/… 2d comment How to make a flowchart? It's entirely possible with enough VertexShapeFunction and EdgeShapeFunction settings, but it's also a lot of work and very tedious. Why don't you use a dedicated diagramming tool? You could do it in a tenth of the time. No, probably a hundredth of the time.