Search results

  1. W

    I EPR and Non-Locality - For and Against

    I think this pretty succinctly hits the nail on the head: "local" by itself is a word that people learn by association from other people, seeing examples of things called "local" and others "nonlocal". So arguing about which box quantum physics should be put into is not interesting by itself...
  2. W

    Python IDLE and print function...

    More precisely, print() prints the default "display" or "aesthetic" string representation of its argument, as returned by calling str() on it. By contrast, Python's interactive interpreter evaluates the expression you give it and tries to display it in source form, as returned by the repr()...
  3. W

    LaTeX Wide equation in Revtex 4.2 is overlapping with other content

    Okay, that makes sense. I don't know for sure, but it may just have been a problem with RevTeX. Personally I usually avoid using RevTeX when I can since it seems to have trouble with placement of things not unlike what you've seen, particularly when using the pra/prb/etc. options. RevTeX with...
  4. W

    LaTeX Wide equation in Revtex 4.2 is overlapping with other content

    Is there a reason you don't just reformat the equation so it fits in a single column, e.g., $$\begin{align} f(x) =& \frac{1}{4} + \frac{2}{\pi}\left(-\frac{\cos{x}}{2} + \frac{\cos{3x}}{6} - \frac{\cos{5x}}{10} + \dotsb \right) \nonumber \\ & {} + \frac{2}{\pi}\left(\frac{\sin{x}}{2} -...
  5. W

    Trying to decide which programming language I want to learn

    C++ has a lot of feature duplication. It often provides two or more different ways of achieving substantially the same thing. This is something you need to accept up front and be ready to deal with if you've made the decision to learn C++. Much of the feature duplication comes from C++ defining...
  6. W

    Trying to decide which programming language I want to learn

    As has been mentioned, most programming languages support writing and printing integers in different bases (decimal, hex, and octal are the ones usually supported). You're meant to just use whichever one is most natural for what you're doing. So typically you'd use hexadecimal for low-level...
  7. W

    Trying to decide which programming language I want to learn

    These are all procedural programming languages that are very similar to each other though. I think there are broadly two reasons to learn a new programming language. The first is that you want to get into or learn more about some specific kind of programming, e.g. systems programming, video...
  8. W

    Courses Should I enroll in a python course or java? (I’m studying physics)

    I'd go with Python, personally. You are much more likely to use it. Java is one of the most important programming languages in the corporate world but as far as I know there's hardly anyone using it in physics, while there are quite a lot of people using Python. Other responders here have...
  9. W

    Comp Sci Recursion double function

    You're assigning to the address of an uninitialised pointer: Why is s a pointer here?
  10. W

    B Solve 3 7 12 18 25 series

    More generally it's easy to check by induction that $$\sum_{n=1}^{a} n (n + 1) (n + 2) \dotsm (n + p - 1) = \frac{a (a + 1) \dotsm (a + p)}{p + 1} \,.$$ The relation can be be seen as the discrete analogue of $$\int_{0}^{a} \mathrm{d}x \, x^{p} = \frac{a^{p+1}}{p + 1}$$ and it can be used to...
  11. W

    I A (probably) simple question about Bell's paper

    You don't need to do any calculus. You're averaging ##\text{sign} \, \boldsymbol{\lambda} \cdot \boldsymbol{a}'## over vectors ##\boldsymbol{\lambda}## that satisfy ##\boldsymbol{\lambda} \cdot \boldsymbol{p} > 0## for some given vectors ##\boldsymbol{a}'## and ##\boldsymbol{p}##. ##\text{sign}...
  12. W

    Second programming language to get under the belt: python vs C

    Why not learn both? It's not like it would necessarily take all that much of your time. Python is among the easiest programming languages to pick up and start using and has lots of libraries available for getting things done. C is much lower level, so less practical for many purposes, but (as...
  13. W

    C/++/# Best resources to learn C++ (free)

    Herbert Schildt's books have a bad reputation among people knowledgeable about C and C++. The 'bullshildt' is named after him. You can find negative expert reviews of Schildt's books on the ACCU (Association of C and C++ Users) website. The USENET alt.comp.lang.learn.c-c++ FAQ (scroll down to...
  14. W

    When Calculators lie will anyone notice?

    Emacs also includes an RPN calculator (calc) in its standard distribution. I haven't really used it but the feature list seems quite impressive for a package included in what is ostensibly a text editor.
  15. W

    When Calculators lie will anyone notice?

    I don't think you're limited for choice if you want to use RPN on a computer. The dc calculator (one of the traditional Unix command-line utilities) and Forth programming language are both stack-based and use RPN notation. I am not sure this is so useful in a programming language though. RPN to...
  16. W

    If you hold a PhD or are a PhD advisor, what do you think students should learn from their PhDs?

    A PhD is basically a research apprenticeship. So if you do a PhD then by the end you should have learned to function as an independent (if still junior) researcher in your field. This includes learning to do some of the things listed by @marcusl above. I think maybe the litmus test is that, by...
  17. W

    When Calculators lie will anyone notice?

    I have an HP-67 that was handed down to me by my aunt. Unfortunately it no longer works. I am hoping I can get it repaired some time. I bought one of these that I saw in a shop about a decade ago. HP introduced it in 2007 to commemorate the 35th anniversary of their first pocket scientific...
  18. W

    A Calculate the expectation value of the product of two electron spins in the singlet state with measurements

    More generally, the density operator associated to the ##\lvert \psi_{-} \rangle## state is invariant under any unitary transformation applied to both parts. The ket ##\lvert \psi_{-} \rangle## itself is invariant under any unitary in ##\text{SU}(2)## applied to both sides and invariant up to a...
  19. W

    A Calculate the expectation value of the product of two electron spins in the singlet state with measurements

    A nice and systematic way to do this kind of calculation is by writing the correlation in terms of the density operator, $$\langle \psi \rvert A \otimes B \lvert \psi \rangle = \text{Tr} \bigl[ (A \otimes B) \lvert \psi \rangle \langle \psi \rvert \bigr] \,,$$ and then expressing the density...
  20. W

    List with lists in Python

    In case you don't know it already it's maybe worth adding that not only the contents of lists but variables in general are all references (a.k.a. pointers) in Python. This has a visible effect in code like the following: >>> a = [1, 2, 3, 4, 5] >>> b = a >>> b[2] = 99 >>> a [1, 2, 99, 4, 5] This...
  21. W

    List with lists in Python

    You can use a list comprehension if you want to create a new list without modifying the original one. newlist = [[x, 5*y] for [x, y] in mylist]
  22. W

    List with lists in Python

    for pair in mylist: pair[1] *= 5
  23. W

    XOR algorithm to find the missing number in a given array

    This depends on the language. Python integers are not machine register integers; their size is only limited by available memory. Still, this just substitutes one possible problem for others (efficiency, and in very very extreme cases maybe exhaustion of memory) that xor doesn't have. On the...
  24. W

    XOR algorithm to find the missing number in a given array

    Not a mathematician myself, but it seems the trick works if you have some subset ##S## of an abelian group (of numbers or some other type of object), you're given a subset ##S'## of ##S## with one element missing, and the problem is to identify that missing element. Being a group means each...
  25. W

    XOR algorithm to find the missing number in a given array

    Just for info, there's a common functional idiom for accumulating a value from a sequence. Python is one of the languages that allows it: from functools import reduce # Only needed in Python 3. A = [2, 3, 1, 4, 6, 7] xor = lambda x, y: x^y # xor(x, y) returns x^y. x1 = reduce(xor, A) x2...
  26. W

    Visual C++ array question

    The problem you're asking about has nothing special to do with the Microsoft Visual Studio environment. Here's one way to do what you're asking: unsigned int digits[4096][4]; for (unsigned int i=0; i<4096; ++i) { digits[i][0] = (i / 512) % 8; digits[i][1] = (i / 64) % 8...
  27. W

    Python Shifting an array one postion to the left -- Non Function Vs Function

    Well the exercise says that the solution function should take K as a parameter, so it's really the line 'K = int(input(...' that shouldn't be there. I was meaning to comment on this. There's also a language-independent reason that the OP's solution is slow which is that it rotates the list K...
  28. W

    Python Shifting an array one postion to the left -- Non Function Vs Function

    The indentation in line 24 is wrong. So the line 'A[len(A)-1] = temp' is outside the 'for x ...' loop in the function version unlike the not-function version.
  29. W

    Python Transpose of a non-square matrix (without using ndarray.transpose)

    Better, using argument unpacking: list(zip(*xmatrix)) This works for a matrix (list of lists) of any size.
  30. W

    Insights Recursion in Programming and When to Use or Not to Use It

    The thing with recursive functions is that they save a copy of all the function arguments and local variables on the stack for each recursive call. (Unless your code is tail recursive and your language or compiler recognises and eliminates tail calls, as mentioned earlier.) The factorial is a...
Top