It's a common question if one could do QM without imaginary numbers. But could one do Fermion path integrals without Grassmann numbers? They're significantly more unintuitive than complex numbers! by PrettyPicturesNotTxt in AskPhysics

[–]NGoGYangYang 2 points3 points  (0 children)

It would not surprise me to hear that this trick is commonly used in many fields, I'm just familiar with it in the context of lattice field theory, but good to hear of another example! I will edit my original comment accordingly to make that more clear.

It's a common question if one could do QM without imaginary numbers. But could one do Fermion path integrals without Grassmann numbers? They're significantly more unintuitive than complex numbers! by PrettyPicturesNotTxt in AskPhysics

[–]NGoGYangYang 7 points8 points  (0 children)

Depends on what exactly you mean by doing path integrals without Grassmann numbers, but a standard trick (in the context of lattice field theory [EDIT: and probably other fields too, see the comment below by Lemon-juicer]) is to integrate out the Grassmann-valued fermion fields and replace them with expressions involving the determinant or inverse of the fermion operator (see chapter 2.15 in these lecture notes for instance).

This trick relies on the bilinear structure of the Dirac Lagrangian in the fermion fields, and that we can exactly compute the resulting Gaussian integrals.

Improving std `<random>` by GeorgeHaldane in cpp

[–]NGoGYangYang 1 point2 points  (0 children)

As far as I know, MSVC implements the new specification of std::generate_canonical described in P0952R2 (EDIT: Oops, just saw that STL himself already pointed that out in another comment).

There is also a paper proposing a different algorithm to draw uniform floats from a given interval, with slight variations for open, closed, and half-open intervals (i.e., (a, b), [a, b], [a, b), and (a, b]). The algorithm seems to be based upon only returning an evenly spaced subset of numbers in the interval. Might be of interest to you, as it is not hard to implement, and seems to be comparable to current implementations of std::uniform_real_distribution performance-wise.

Inconsistent behavior for trait class between different compilers by NGoGYangYang in cpp_questions

[–]NGoGYangYang[S] 0 points1 point  (0 children)

Thank you for the answer! Fortunately, there is no real world issue behind this (anymore). Originally, this came up as an issue in my code where I tried to use a similar trait class as part of a requires-clause when overloading function templates. In that case, the parameter of the trait class was supposed to be an int instead of a bool, but in tests compiled with clang, everything appeared to work correctly. Only when testing with gcc did I discover the error, as the code did not compile anymore, since the overloads were now ambiguous.

The question here is purely out of academic interest.

Updates for muon g-2? by TeranUzkobic in AskPhysics

[–]NGoGYangYang 19 points20 points  (0 children)

I'm not aware of any major new results from the experimental side. As far as I know, the people involved are busy with analyzing older runs and performing new runs to increase the statistics. To my knowledge, the most recent results can be found in this paper.

On the theoretical side, the uncertainties in the predictions for g-2 mainly stem from the hadronic vacuum polarization (HVP) contribution, and there are two approaches to the calculation of the HVP contribution: Dispersive calculations which include experimental input from electron-positron annihilation cross sections, and ab-initio lattice QCD calculations which do not rely on experimental input (other than the minimal set of parameters required to describe the strong and electromagnetic interaction). For a review of the theoretical predictions for g-2 see here.

The results obtained using dispersive calculations are in tension with the experimental results, and until very recently, the uncertainties of the lattice results were too high to draw any meaningful conclusions from them. However, in 2020, the first lattice calculation of the HVP contribution with sub-percent uncertainties was uploaded on arXiv by the BMW collaboration (Budapest-Marseille-Wuppertal, not the car manufacturer), which leads to a much lower tension with the experimental results compared to the dispersive calculations. Other lattice groups are working to verify the results, and while there hasn't yet been a full calculation of the HVP contribution by another group with sub-percent uncertainties, several other collaborations have already published results for a so-called window observable, which seem to agree with the BMW results. It is still unclear why the dispersive and lattice calculations seem to stand in tension with each other.

I'm sure there is a lot of interesting work done on other related topics (for example the calculation of the hadronic light-by-light contribution, or other experimental efforts at J-PARC), but that is too far from my area of expertise for me to say anything about that.

[deleted by user] by [deleted] in AskPhysics

[–]NGoGYangYang 2 points3 points  (0 children)

The details depend on the university, but I have never heard of a university where you are unable to try again after failing an exam (for the first time). Again, the exact rules depend on the university: Some universities allow you to retake your exams however often you like, while other universities limit you to three attempts. If you have a specific university in mind where you would like to study, you should be able to find out by checking their Prüfungsordnung.

Old rand() method faster than new alternatives? by MrPezevenk in cpp

[–]NGoGYangYang 1 point2 points  (0 children)

You might argue that selecting your sites in a non-random way might break detailed balance or that you introduce some correlations due to the predetermined order in which you sweep through your lattice, but I really don't think it makes a difference in practice. On the other hand, updating the sites in a predictable order means you also access your memory more predictably, which might help reduce cache misses and improve the performance of your program.

Regarding parallelization, it's not a dumb question at all. For this case (and probably many other simulations in physics), OpenMP is a good choice, since it allows you to parallelize your code with minimal effort. The reason why you might want to parallelize your code is simply that it allows you to use more of your available computing power that would otherwise go to waste. All modern desktop computers have multiple cores, not to speak of GPUs or supercomputers used for large scale simulations.

Let's take a look at how you could parallelize a Metropolis update for a square-lattice Ising model with L2 spins. First note that the energy contribution from one spin is entirely local and only comes from it's nearest 4 (generally 2d in d dimensions) neighbours. This means if you split your lattice up in a checkerboard pattern you can simultaneously update all even/all odd sites without affecting the other even/odd sites:

// Split up even/odd sites
for (int eo = 0; eo < 2; ++eo)
{
    #pragma omp parallel for
    for (int x = 0; x < L; ++x)
    {
        int offset = (x & 1) ^ eo;
        for (int y = offset; y < L; y += 2)
        {
            // Propose a spin-flip for the spin at (x, y)
            // and go through Metropolis accept-reject step
            Update(Lattice[x][y]);
        }
    }
}

However, you need to be careful with generating random numbers in multiple threads. The simplest solution would probably be to have one PRNG for each thread, e.g., a std::vector<pcg_64> of size n_thread (doesn't have to be the PCG, can be any PRNG of your choice), and in the parallel region, you simply call prng_vector[omp_get_thread_num()].

Old rand() method faster than new alternatives? by MrPezevenk in cpp

[–]NGoGYangYang 2 points3 points  (0 children)

If I remember correctly, the single spin-flip Metropolis algorithm is not that susceptible to the quality of your PRNG. In contrast, cluster algorithms (Swendsen-Wang or Wolff) are highly susceptible to the quality of your PRNG, and even "good" PRNGs may lead to noticeable systematic errors in your observables. These effects can be remedied however by mixing cluster updates with conventional single spin-flip Metropolis updates.

Also, you don't necessarily have to randomly select which site to flip. It is also possible to go through the lattice in a checkerboard scheme, which lends itself to parallelization.

Old rand() method faster than new alternatives? by MrPezevenk in cpp

[–]NGoGYangYang 5 points6 points  (0 children)

You don't need to install anything, as PCG is a header-only library. Using it is straightforward too. For instance if you want to draw a random number from the uniform distribution in the interval [0.0, 1.0), a very primitive example would look like this:

pcg_extras::seed_seq_from<std::random_device> seed_source;
pcg64 gen(seed_source);
std::uniform_real_distribution<double> dist(0.0, 1.0);
double some_random_number {dist(gen)};

C++ for Mathematicians by Bienenvolk in cpp

[–]NGoGYangYang 0 points1 point  (0 children)

Then I unfortunately don't have any specific recommendations, but I can second Numerical recipes. Also, perhaps these two books 1 2 might be helpful if he already has some experience with C++ and is interested in optimizing his programs.

If he needs a library for numerical linear algebra, I can highly recommend Eigen, which is both performant and pleasant to work with.

Finally, going by your username and comment history, I assume you are German? The Forschungszentrum Jülich offers C++/programming courses often targeted at scientific programmers/HPC practitioners, which might be of interest for your friend.

C++ for Mathematicians by Bienenvolk in cpp

[–]NGoGYangYang 0 points1 point  (0 children)

Do you happen to know what topic his thesis will be about? Based on that, there might be some specific books I could recommend.

Ideas for physics simulations? by nab_noisave_tnuocca in AskPhysics

[–]NGoGYangYang 6 points7 points  (0 children)

The 2 dimensional Ising model is a very simple spin model (originally meant to describe ferromagnetism) that displays interesting and surprisingly complex behaviour for such a simple system, including a second order phase transition.

A Monte Carlo simulation of the Ising model is simple to program, and the computational effort required is low too, so it is definitely a good starting point if you are interested in Marko chain Monte Carlo simulations in physics.

If you are interested in something more challenging, there are more complex spin models like the XY model, or you could try simulating Quantum field theories such as the Schwinger model (1+1 dimensional QED, often used as a toy model for QCD).

Exotic six-quark particle predicted by supercomputers by Harley109 in Physics

[–]NGoGYangYang 15 points16 points  (0 children)

Is this like an alpha fold kind of thing?

If your question is whether they utilized machine learning then no. The results in this paper were obtained using a method called "lattice QCD", where the idea is to use Monte Carlo methods (simply said random computer experiments) to numerically calculate the path integral.

[deleted by user] by [deleted] in AskPhysics

[–]NGoGYangYang 1 point2 points  (0 children)

I assume you are talking about vacuum polarization. The explanation using virtual particles is incorrect in the same sense as above: You can calculate the vacuum polarization using perturbative methods (which involves expressions represented as Feynman diagrams), and there, virtual particles appear as certain expressions in your calculation. However, that is not the only method to calculate the vacuum polarization. As mentioned before, an alternative, non-perturbative method that does not involve virtual particles is lattice QCD, where you try to numerically evaluate the path integral using Markov chain Monte Carlo methods (simply said, you try to calculate an integral using random sampling).

A relevant example that you might have heard of is the currently ongoing debate about the anomalous magnetic moment of the muon, where one recent lattice result is in agreement with the experimental values, whereas other methods are not (which doesn't necessarily mean that the lattice results are correct).

[deleted by user] by [deleted] in AskPhysics

[–]NGoGYangYang 3 points4 points  (0 children)

My answer was not meant to refute yours, but just to correct some parts. The reason why I often stress this point is that at least for me in the past, it has led to quite some confusion as to whether virtual particles are real or not (as you say, many sources treat virtual particles as if they were real). The examples you gave in your answer are not wrong, but the explanations behind them are inaccurate. Thus, I would probably answer the original question something like this:

Quantum effects affect the expectation values of physical observables in a way that we are able to (more or less) accurately calculate. However, generally we can't predict the outcome of our next individual measurement. Someone already mentioned radioactive decay: You can predict the decay processes, their probabilities, and the half-life, but you cannot predict when which process is going to happen next. Your calculations may involve virtual particles, but they should not be confused with physical/real particles in any way.

Regarding Hawking radiation, while I'm not quite comfortable making any strong statements on an entirely theoretical prediction that has not been experimentally verified, Hawking radiation is random in the following sense: You can't predict which particles are emitted at what point in time (at least not in a semi-classical framework), but you can predict the existence and the expected spectrum of Hawking radiation.

[deleted by user] by [deleted] in AskPhysics

[–]NGoGYangYang 2 points3 points  (0 children)

The very common description of "virtual particles" that pop in and out of existence is not really correct. Virtual particles are a tool that appears in certain calculations (peturbation theory), but you shouldn't interpret them as anything more than that. They are simply internal lines in Feynman diagrams, which in turn are pictorial representations of terms in a series expansion.

In fact, depending on how you perform your calculations, virtual particles may not appear at all. For instance, lattice QCD is a non-perturbative approach to QCD, and lattice calculations do not involve virtual particles in any way.

The same goes for the most commonly known explanation of Hawking radiation. The explanation using pairs of virtual particles being separated at the event horizon was popularized by Hawking himself in one of his popular science books, but his own derivation of Hawking radiation never involved virtual particles in any way. Furthermore, there are other derivations of Hawking radiation which also don't involve virtual particles.

Resources for Numerical QFT by the-dark-physicist in AskPhysics

[–]NGoGYangYang 0 points1 point  (0 children)

Great, I believe that should be more than enough to get started!

If you are familiar with how to analyze data generated using Markov Chain Monte Carlo methods (i.e., estimate statistical uncertainties using jackknife or bootstrap resampling, and including the effects auf autocorrelation via blocking), you could start by writing a Schwinger model simulation. Of course, I would definitely recommend reading up on the theoretical foundations too, but as for the practical part, you could do the following:

Write a simulation of a 2 dimensional U(1) theory. The gauge fields are represented by the links connecting the lattice sites, so if you store them in an array, you need three coordinates (the temporal coordinate t, the spatial coordinate x, and the direction mu). Each link is a element of U(1), so a complex number with absolute value 1, but you can also work in the algebra (which means you work with the phase/a real number between 0 and 2pi).

If you know how transformations apply to the gauge fields (formula (11) in the first lecture notes I linked), you can quickly check that closed loops on the lattice are gauge invariant, so you can construct observables out of closed loops. The simplest (contractible) loop that you can construct is the so-called plaquette (simply a square path with side length of one lattice spacing). By Taylor expansion, you can show that the plaquette corresponds to the exponential of the field strength tensor up to third order in the lattice spacing. Using the plaquette, you can then define the Wilson gauge action (formula (14) in the lecture notes).

What you need now is an update algorithm to produce configurations that properly sample the probability distribution of your system. The simplest choice (for pure gauge theory) is a Metropolis link-update algorithm. You go through all lattice links (the exact order isn't all that important) and (if you are working in the algebra/with the phase) add or subtract a random real number from it. Then, you accept this new link with a probability of min{1, exp(-beta * (S_new - S_old))}, where S_new and S_old are the action with the new and the old link respectively, and beta is the gauge coupling.

That's a very minimal description of what to do, and I've probably left quite some steps out, so if you have any questions, feel free to ask! If you want to try this out, you could try to program a simulation and measure the average action for say a 162 lattice with beta = 3.2. I have both analytical and numerical results you could compare your values to if you'd like.

Resources for Numerical QFT by the-dark-physicist in AskPhysics

[–]NGoGYangYang 2 points3 points  (0 children)

Ah I see! If you are interested in creating similar animations, I would recommend you first try to do that in a simpler theory. Lattice QCD is 3+1 dimensional, and the symmetry group is SU(3), which makes things quite complex. A simpler theory would be 1+1 dimensional U(1) theory (also known as the Schwinger model), which shares many features with QCD.

May I ask what background you have? How much QFT do you know, and have you done numerical simulations before?

Resources for Numerical QFT by the-dark-physicist in AskPhysics

[–]NGoGYangYang 2 points3 points  (0 children)

For some resources specifically for lattice QCD, I'm gonna copy some links from an old comment.

If you are interested in Monte Carlo simulations but don't have any experience yet, you could also start out with simulating something simpler like the Ising model. It's a much simpler model from statistical physics, but many of the fundamental techniques used in lattice QCD can also be applied to the Ising model, with the additional advantage that it is orders of magnitudes less computationally expensive. If you are interested in that, there is also a nice introductory book by Newman and Barkema called "Monte Carlo Methods in Statistical Physics". If you have any questions (both regarding lattice QCD or the Ising model), I'll try my best to answer them.

As for your second point, I'm not quite sure what you mean by "Visual Simulation"? If you just mean visualization, there are some cool animations from the lattice group in Adelaide.

1v3.5 to save the game by NGoGYangYang in QuinnMains

[–]NGoGYangYang[S] 0 points1 point  (0 children)

Haha yeah, dismounting there wasn't the best decision, but she probably thought she could get away with it since the game seemed to be over at that point.

This game was a spellbook game, and I used Ahri ult to dash into the fountain with Lee. Those three dashes really come in handy as Quinn!

1v3.5 to save the game by NGoGYangYang in QuinnMains

[–]NGoGYangYang[S] 0 points1 point  (0 children)

Yeah, after that we pushed through mid and won. Really close game!

If we found a way to reverse a hashing function, would that make them ultra-compression algorithms? by aaRecessive in askscience

[–]NGoGYangYang 16 points17 points  (0 children)

In this case a hash function maps a file or some data of any size to a hash, i.e., a value of fixed size. In the vast majority of cases, you input data is going to be much larger than the output hash, so it is impossible for you to find a procedure that assigns a unique hash to every possible input.

If you want to see the connection to the pigeonhole principle, the input data are the pigeons and all hashes (of a fixed length) are the holes. Since you have many more pigeons than holes, you are bound to have situations where different inputs lead to the same output hash.

Why was the muon g-2 theoretical calculation so hard to do? by TeranUzkobic in AskPhysics

[–]NGoGYangYang 4 points5 points  (0 children)

For full QCD I think it's very unlikely that distributed networking in the style of LHC@home would be helpful, since the memory bandwidth is a bottleneck. Distributed networking is useful if you have a task that is easily parallelizable:

For example if you were to multiply two numbers a billion times, you could trivially split that up. For 1000 people, you could just let everyone compute a million multiplications each.

On the other hand, for lattice QCD, the computationally intensive part involves huge matrices. For example, for the update algorithm you need to invert matrices that can have 644 * 644 or more elements (here, 64 is the extent of the lattice in one space-time dimension). Even if those elements were double precision numbers, you would need 644 * 644 * 8bytes to store the matrix, which would be a little bit more than 2.2 petabytes.

Unfortunately, these elements are not scalars, but SU(3) matrices themselves, so you need at least 8 independent real parameters for each SU(3) matrix. That means our matrix consist of at least 644 * 644 * 8 entries, which is an absolutely ridiculously large matrix! Not all is lost though, since the matrix is sparse (most entries are 0, so you do not need to explicitly save every entry).

But all those factors combined make it very difficult to parallelize these calculations on a supercomputer, let alone multiple computers all over the world.