• 9 Posts
  • 71 Comments
Joined 1 year ago
cake
Cake day: June 18th, 2023

help-circle

  • For someone starting out, I would say that a major advantage of Python over any compiled language is that you can just create a file and start writing/running code. With C++ (which I’m also a heavy user of) you need to get over the hurdle of setting up a build system, which is simple enough when you know it, but can quickly be a high bar for an absolute beginner. That’s before you start looking at things like including/linking other libraries, which in Python is done with a simple import, but where you have to set up your build system properly to get things working in C++.

    Honestly, I’m still kind of confused that the beginner course at my old university still insists on giving out a pre-written makefile and vscode config files for everyone instead of spending the first week just showing people how to actually write and compile hello world using cmake. I remember my major hurdle when leaving that course was that I knew how to write basic C++, I just had no idea how to compile and link it when I could no longer use the makefile that we were explicitly told to never touch…


  • Yes, it’s a field. Specifically, a field containing human-readable information about what is going on in adjacent fields, much like a comment. I see no issue with putting such information in a json file.

    As for “you don’t comment by putting information in variables”: In Python, your objects have the __doc__ attribute, which is specifically used for this purpose.


  • My test suite takes quite a bit of time, not because the code base is huge, but because it consists of a variety of mathematical models that should work under a range of conditions.

    This makes it very quick to write a test that’s basically “check that every pair of models gives the same output for the same conditions” or “check that re-ordering the inputs in a certain way does not change the output”.

    If you have 10 models, with three inputs that can be ordered 6 ways, you now suddenly have 60 tests that take maybe 2-3 sec each.

    Scaling up: It becomes very easy to write automated testing for a lot of stuff, so even if each individual test is relatively quick, they suddenly take 10-15 min to run total.

    The test suite now is ≈2000 unit/integration tests, and I have experienced uncovering an obscure bug because a single one of them failed.


  • This is a very “yes but still no” thing in my experience. Typically, I find that if I write “naive” C++ code, where I make no effort to optimise anything, I’ll outperform python code that I’ve spent time optimising by a factor of 10-30 (given that the code is reasonably complex, this obviously isn’t true for a simple matrix-multiplication where you can use numpy). If I spend some time on optimisation, I’ll typically be outperforming python by a factor of 50+.

    In the end, I’ve found it’s mostly about what kind of data structures you’re working with, and how you’re passing them around. If you’re primarily working with arrays of some sort and doing simple math with them, using some numpy and scipy magic can get you speeds that will beat naive C++ code. On the other hand, when you have custom data structures that you want to avoid unnecessarily copying, just rewriting the exact same code in C++ and passing things by reference can give you massive speedups.

    When I choose C++ over python, it’s not only because of speed. It’s also because I want a more explicitly typed language (which is easier to maintain), overloaded functions, and to actually know the memory layout of what I’m working with to some degree.



  • Yes, there are an infinite number of velocities you can use, but if you look at their distribution, you’ll find that it quickly goes to zero somewhere around 1-2 m/s, so the expectation value of the velocity is convergent.

    If you have an object with a velocity taken from a distribution that doesn’t approach zero sufficiently fast as the velocity goes to infinity, the expectation value diverges. A simple example would be a person that would be half as likely to get up at a velocity of 2 m/s as 1 m/s, and half as likely to get up at 4 m/s as 2 m/s, etc.

    The more mathematical version of the same argument is to compute the kinetic energy of a particle whose wavefunction is a delta pulse (i.e. a particle whose position is exactly defined), and you’ll find that the particle has infinite energy.


  • There are a lot of good answers here already, but I’ll try to attack the question from a new angle.

    Firstly, yes: they experience an attractive force from the nucleus, and would in principle have their lowest possible potential energy if they were located exactly in the nucleus. An equilibrium state is the state with lowest energy, so why aren’t they exactly in the nucleus?

    Consider that an electrons position and speed cannot be exactly defined at the same time (uncertainty principle). So an electron with an exact position could have any speed. If you compute the expectation value of a particles kinetic energy, when the particle can have any speed, you’ll find that it’s divergent (goes to infinity).

    So: Because an electron with an exactly defined position must have infinite kinetic energy, the equilibrium state cannot be an electron with an exactly defined position, and so cannot be an electron exactly in the nucleus. So what do we do?

    We have to make the electrons position “diffuse”. Of course, that means it is no longer exactly inside the nucleus, so it gains some potential energy, but on the other hand it can move more slowly and has lower kinetic energy.

    The equilibrium state is the state we find where the trade off between kinetic and potential energy gives us the lowest total energy, which is described as a 1s orbital. The electron is “diffuse” enough to have a relatively low kinetic energy, and “localised” enough to have a relatively low potential energy, giving as low total energy as possible.

    Once you start adding more electrons you need to start taking Pauli exclusion into account, so I won’t go there, but the same manner of thinking still essentially holds up.


  • I love how the mathematician ends the interview by saying

    [this] may help us uncover something beautiful, or maybe even useful.

    It’s great seeing how these people work with science for the sake of science itself, because it’s beautiful, not because they suspect that they’ll find something that immediately changes the world. It makes me think that they see themselves more as artists than as engineers, and I think that if you have a career in science it’s a healthy approach to have. Most scientists never have an “Einstein-like” breakthrough, but contribute pieces to the puzzle that may lead to breakthroughs long after they’re gone. Being satisfied with that is probably key to having peace of mind as a scientist.






  • Assuming

    • cylindrical human, 2m tall, 25 cm diameter.
    • air displaced from the point you teleport to is instantly moved to form a monolayer (1 molecule thick) on your surface.
    • The displacement of air is adiabatic (no heat is transferred, which will be true if the displacement is instantaneous)

    Volume of displaced air: ≈ 100L = 0.1m^3 At atmospheric conditions: ≈ 4 mol

    Surface area of cylindrical human: ≈ 1.58 m^2 Diameter of nitrogen molecule (which is roughly the same as for an oxygen molecule) : ≈ 3 Å Volume of monolayer: ≈ 4.7e-10 m^3

    Treating the air as an ideal gas (terrible approximation for this process) gives us a post-compression pressure of ≈ 45 PPa (you read that right: Peta-pascal) or 450 Gbar, and a temperature of roughly 650 000 K.

    These conditions are definitely in the range where fusion might be possible (see: solar conditions). So to the people saying you are only “trying to science”, I would say I agree with your initial assessment.

    I’m on my phone now, but I can run the numbers using something more accurate than ideal gas when I get my computer. However, this is so extreme that I don’t really think it will change anything.

    Edit: We’ll just look at how densely packed the monolayer is. Our cylindrical person has an area of 1.58 m^2, which, assuming an optimally packed monolayer gives us about 48 micro Å^2 per particle, or an average inter-particle distance of about 3.9 milli Å. For reference, that means the average distance between molecules is about 0.1 % of the diameter of the molecules (roughly 3 Å) I think we can safely say that fusion is a possible or even likely outcome of this procedure.







  • The representation of “real world” is meant to be an exaggeration of real life, both as satire, and to underline issues women face and systematic advantages men receive. I think that part was quite good at doing what it was trying to do, it was funny as well, and Will Ferrell is of course hilarious as CEO.

    What didn’t really resonate with me, and kind of rubbed me the wrong way, was later in the movie, when “men” were portrayed as being simultaneously incompetent at everything they do, and at the same time manipulative and power hungry. By all means, it was funny, and got the point through, but I think they went too far in portraying the “bad guys” as both stupid and malicious, but also hard to overcome.

    I think the message of the movie (the way I understood it) would have gotten through in a better way if they had made the resolution less dependent on the “men are dumb” caricature, and played more to “women are strong”, they could maybe even have brought in some “men and women can actually function together if they talk to each other”.