HNHacker News
TopNewBestAskShowJobs

jwmerrill

1,599 karma · joined April 5, 2012

Physicist, probability and geometry enthusiast, and software developer at https://www.desmos.com.

You can reach me at jwmerrill@gmail.com

submissionscomments
jwmerrill··on Subnormal floating-point numbers are expensive on Intel processors
One nice thing that subnormals get you is the property that if x-y == 0 then x == y. If you want to guard against division by 0, and your denominator is a difference of two terms, it’s nice to be able to check equality of those terms and know that if they are not equal, then their difference will not be 0.

More generally, subnormals are needed for Sterbenz Lemma to hold everywhere: https://en.wikipedia.org/wiki/Sterbenz_lemma

jwmerrill··on Amazon confirms 14,000 job losses in corporate division
“Passive voice” is a grammatical term.

“Amazon confirms 14,000 job losses,” is not an example of the passive voice.

“14,000 workers were fired by Amazon,” is an example of the passive voice.

There is not a 1:1 relationship between being vague about agency and using the passive voice.

jwmerrill··on Creating Bluey: Tales from the Art Director
The article is a four part series.
jwmerrill··on 100 Years to Solve an Integral (2020)
This is also the inverse Gudermannian function [1]. That Wikipedia page has some nice geometrical insights.

[1] https://en.m.wikipedia.org/wiki/Gudermannian_function

jwmerrill··on Zig's new LinkedList API (it's time to learn fieldParentPtr)
My mistake! It seems clear in hindsight…
jwmerrill··on Zig's new LinkedList API (it's time to learn fieldParentPtr)
The next pointer doesn’t have to go first in the structure here. It can go anywhere, and you can use @fieldParentPtr to go back from a reference to the embedded node to a reference to the structure.
jwmerrill··on Derivatives don't always act like fractions (2021)
For problems in the plane, it's natural to pick two coordinate functions and treat other quantities as functions of these. For example, you might pick x and y, or r and θ, or the distances from two different points, or...

In thermodynamics, there often isn't really one "best" choice of two coordinate functions among the many possibilities (pressure, temperature, volume, energy, entropy... these are the must common but you could use arbitrarily many others in principle), and it's natural to switch between these coordinates even within a single problem.

Coming back to the more familiar x, y, r, and θ, you can visualize these 4 coordinate functions by plotting iso-contours for each of them in the plane. Holding one of these coordinate functions constant picks out a curve (its iso-contour) through a given point. Derivatives involving the other coordinates holding that coordinate constant are ratios of changes in the other coordinates along this iso-contour.

For example, you can think of evaluating dr/dx along a curve of constant y or along a curve of constant θ, and these are different.

I first really understood this way of thinking from an unpublished book chapter of Jaynes [1]. Gibbs "Graphical Methods In The Thermodynamics of Fluids" [2] is also a very interesting discussion of different ways of representing thermodynamic processes by diagrams in the plane. His companion paper, "A method of geometrical representation of the thermodynamic properties of substances by means of surfaces" describes an alternative representation as a surface embedded in a larger space, and these two different pictures are complimentary and both very useful.

[1] https://bayes.wustl.edu/etj/thermo/stat.mech.1.pdf

[2] https://www3.nd.edu/~powers/ame.20231/gibbs1873a.pdf

jwmerrill··on The Static Site Paradox
`<!DOCTYPE html>` is not an html opening tag. It is a preamble.

https://html.spec.whatwg.org/multipage/syntax.html#writing

jwmerrill··on Evaluating a class of infinite sums in closed form
Instead of differentiating c^(-xn) w.r.t. x to pull down factors of n (and inconvenient logarithms of c), you can use (z d/dz) z^n = n z^n to pull down factors of n with no inconvenient logarithms. Then you can set z=1/2 at the end to get the desired summand here. This approach makes it more obvious that the answer will be rational.

This is effectively what OP does, but it is phrased there in terms of properties of the Li function, which makes it seem a little more exotic than thinking just in terms of differentiating power functions.

jwmerrill··on The Second Law of Thermodynamics (2011)
From later in [1]

> Mind that all of this does not impose how we actually scale temperature.

> How we scale temperature comes from practical applications such as thermal expansion being linear with temperature on small scales.

An absolute scale for temperature is determined (up to proportionality) by the maximal efficiency of a heat engine operating between two reservoirs: e = 1 - T2/T1.

This might seem like a practical application, but intellectually, it’s an important abstraction away from the properties of any particular system to a constraint on all possible physical systems. This was an important step on the historical path to a modern conception of entropy and the second law of thermodynamics [2].

[1] https://physics.stackexchange.com/a/727798/36360

[2] https://bayes.wustl.edu/etj/articles/ccarnot.pdf

jwmerrill··on JavaScript Naked Day
KaTeX supports server side rendering to an html string. If you do this, the client only needs to load the css component of katex, and not the js component.

I believe MathJax has a similar capability.

jwmerrill··on Poincaré Recurrence Theorem
Entropy in Statistical Mechanics is a quantity associated with a probability distribution over states of the system. In classical mechanics, this is a probability distribution over the phase space of the system.

Two probability distributions with different entropy can both assign finite probability density to the same state, so an increase in entropy does not preclude the possibility of the system returning to its initial state.

A great deal of confusion about entropy arises from imagining it as a function of the microstate of a system (in classical mechanics, a point in phase space) when it is actually a function of a probability distribution over possible states of a system.

A further wrinkle: Liouville's Theorem [0] shows that evolution under classical mechanics is _entropy preserving_ (because the evolution preserves local phase space density, and entropy is a function of this density). An analogous result applies to quantum mechanics. However, a simple probability distribution parametrized by a few macroscopic parameters rapidly becomes very complex as it evolves in time. When we imagine the entropy of an isolated classical system increasing over time, the meaning is that if we want to model the (very complicated) evolved probability distribution with a simple probability distribution (describable in terms of a few macroscopic parameters), the simple distribution must have entropy greater than or equal to the complex evolved distribution, which is equal to the original entropy before evolution.

It's difficult to reconcile the idea that entropy is a function of a probability distribution (not a function of a system's microstate) with the idea that Thermodynamical entropy is an experimentally measurable (kind of...) property of a system. Jaynes' "The Evolution of Carnot's Principle" [1] is the clearest description I've seen of the relationship between Thermodynamic entropy and Statistical Mechanical/Information Theoretical entropy. Many of Jaynes' other papers [2] on this topic are also illuminating.

[0] https://en.wikipedia.org/wiki/Liouville's_theorem_(Hamiltoni...

[1] https://bayes.wustl.edu/etj/articles/ccarnot.pdf

[2] https://bayes.wustl.edu/etj/node1.html

jwmerrill··on Why does 0.1 and 0.2 = 0.30000000000000004?
Raku interprets decimal literals (like 0.1) as limited-precision rational numbers (Rats) [0-1].

I think this is a pretty user-friendly compromise.

[0] https://docs.raku.org/syntax/Number%20literals

[1] https://docs.raku.org/type/Rat

jwmerrill··on Dubious Ways to Compute the Zeros of a Polynomial
That paper discusses ways of computing a matrix exponential, rather than ways of computing polynomial zeros.
jwmerrill··on Crafting Interpreters
I’d recommend a language with automatic memory management for the AST walking interpreter in the first half of the book so you don’t have to worry about how everything gets allocated.

Either Zig or Rust would be great for the bytecode compiler/interpreter in the second half of the book, which is written with the expectation of manual memory management. I personally chose Zig and it was fun.

jwmerrill··on rand() may call malloc()
O’Neil has responded to those criticisms here: https://www.pcg-random.org/posts/on-vignas-pcg-critique.html
jwmerrill··on Parsing Expressions by Recursive Descent (1999)
Pratt parsing and precedence climbing are the same or very similar, but they are not the same as recursive descent (and the linked article does not claim this).
jwmerrill··on Floating point numbers, and why they suck
> All you need to do is ensure that your calculations are in no danger of blowing past the max significant digits

If you have a lot of control of the scale of the numbers you’re computing with, you could use fixed point instead of floating point.

The situations that make it useful to have a floating point (rather than fixed point) are also the situations where addition isn’t associative.

jwmerrill··on Floating point numbers, and why they suck
Decimal floating point still doesn’t have associative addition or multiplication.
jwmerrill··on How to invest without knowing the future
> Interesting that the author assumes that US equity dominance will continue.

The author does not assume this—rather this is held up as an assumption that might be wrong.

The article is structured as a list of 5 assumptions that would be tempting to make but could be incorrect, and this is one of them.

jwmerrill··on Tree Shaking
Here’s a conversation about tree shaking in Lisp from 1994 [1] (from the posted Wikipedia page).

[1] https://groups.google.com/g/comp.lang.lisp/c/pspFr1XByZk

jwmerrill··on Florida state of emergency with millions of gallons of “radioactive wastewater”
> what actually happens if you mix sulfuric acid with lye

This reaction produces sodium sulfate (a salt) plus water and heat [1]. No idea if this is practical, though. Maybe it’s difficult to source sufficient quantities of some base to neutralize the acid.

[1] https://en.m.wikipedia.org/wiki/Sodium_sulfate#Chemical_indu...

jwmerrill··on Matrix multiplication inches closer to mythic goal
I don’t think they’re actually intending to refer to physics here—they could have said “as fast as theoretically possible” instead.

A square matrix with n rows and columns has n^2 entries, so if you need to look at all the entries in two matrices to compute their product, then you need to do O(n^2) work just to look at all the relevant entries.

The only way you could get around this is if you know many entries are 0, or identical, or have some other structure such that you don’t need to look at them separately.

jwmerrill··on Geometric Algebra for Python
> Shouldn't 0-grade objects all have the same units?

No, and this is a really important point. Scalars can have any units. For example, you can have a scalar with units of time, or mass, and you can take the dot product of a force vector and a displacement vector to get a scalar with units of [force]·[distance] = [work].

If you instead form the wedge product of those vectors, you get a bivector with the same units: [force]·[distance] = [torque] (note that the units of [work], [torque], and [energy] are all the same).

If you take the geometric product of a force vector and a displacement vector, the result is the sum of a scalar and a bivector, both with the same units of [force]·[distance].

jwmerrill··on A ‘Useless’ Perspective That Transformed Mathematics
I bet it was “Eigenvectors from Eigenvalues”

* https://www.quantamagazine.org/neutrinos-lead-to-unexpected-...

* https://terrytao.wordpress.com/2019/08/13/eigenvectors-from-...

* https://arxiv.org/abs/1908.03795

jwmerrill··on If I could bring one thing back to the internet it would be blogs
Everyone should consider making their own blog! Kind of like everyone should consider baking their own bread, at least once.

Having a blog that I built that is truly “mine,” with a domain name that I own, is one of the most rewarding things I’ve done. Even though I don’t write that often and don’t have that many readers.

I currently host it on github pages, but I could move it somewhere else in a weekend if I wanted to.

Depending on your motivations, discoverability by strangers may be overrated. I’ve had good success just telling people that I respect that I wrote something and getting feedback from them. I’m not selling anything on my blog, so that’s worth a lot more to me than anonymous attention.

Social media like HN, Reddit, Twitter, or Facebook may also help for getting the word out about your writing while still letting you own the space where your writing lives.

jwmerrill··on School districts are sending WiFi-equipped buses to poor and rural neighborhoods
I have to admit that this sounded apocryphal to me because it’s an almost-too-convenient illustration of a general point, but a quick search at least turned up the original study:

https://www.sciencedaily.com/releases/2010/05/100520213116.h...

jwmerrill··on Show HN: Canvas engines performance comparison – PixiJS, Two.js, and Paper.js
I sometimes wish there was a way to demand the same level of proof for claims of readability and productivity that we demand for claims about performance.

Measuring before optimizing is of course a good idea, but it's also time consuming. There's a lot of latitude to make different reasonable choices about how you write code down in the first place before you get to the measuring staging.

Should we criticize someone who reaches for a for loop because they know it doesn't allocate without proving that that matters more than someone who reaches for a map because they think it's more readable and productive without any great way of proving that that's true?

jwmerrill··on Why is Maxwell's theory so hard to understand? (2007) [pdf]
This is a lovely essay, but I think it goes a little too far in claiming that the electromagnetic field is intangible or immeasurable, in slightly forced analogy with quantum mechanics.

> We now take it for granted that electric and magnetic fields are abstractions not reducible to mechanical models. To see that this is true, we need only look at the units in which the electric and magnetic fields are supposed to be measured. The conventional unit of electric field-strength is the square-root of a joule per cubic meter... This does not mean that an electric field-strength can be measured with the square-root of a calorimeter. It means that an electric field-strength is an abstract quantity, incommensurable with any quantities that we can measure directly.

A more conventional way to think of the dimensions of the electric field is [force]/[charge] (e.g. units of Newtons/Coulomb), and you can observe the electric field by observing the force it exerts on a charged particle through

f=qE

for example by observing the trajectory of an electron in a cloud chamber.

Dyson says that the square of the field is a measurable energy density, but it’s arguably harder to measure an energy density than it is to measure a force.

Dyson’s point is much more true for quantum mechanics, where the only measurable things seem to be quadratic combinations of the wave function, and I do like the analogy he points out with electromagnetism, but I think he oversimplifies a bit to make his point.

jwmerrill··on Math Keeps Changing
The default calculator on Android since Marshmallow apparently uses arbitrary precision arithmetic: https://m-cacm.acm.org/magazines/2017/8/219594-small-data-co...
Page 1 of 8Next →