Live data from Hacker News

Poisson's Equation

mattferraro.dev

71–80 of 167 posts

Re: Poisson's Equation

#71

Earlier quoted context omitted.

It's the common way to solve a linear system in octave, matlab and julia. You have an invertible square matrix A, a vector b of the same dimension, and you want to find a vector x such that "A*x=b". Then you write "x=A\b", which is like "x=A^(-1)*b" but does not get to compute the full inverse matrix (which is useless).

Sorry, yes I know about the syntax. I'm just struggling with what exactly you would be plugging in. Like with respect to any of the example problems given, what would A and x and B be?

You create matrices that represent the operator. For instance, suppose you had a 1D function and were interested in the evenly spaced points (x1, x2, x3, x4, x5), with the function values at these points being

  y1
  y2
  y3
  y4
  y5
If the differential equation had a first derivative in it, you'd construct something like this, multiplied by some constant (e.g. 1/(2*dx) for an unscaled derivative):

  ? ? ? ? ?
  -1 0 1 0 0
  0 -1 0 1 0
  0 0 -1 0 1
  ? ? ? ? ?
So the derivative at each element is defined by the difference of the next and previous elements. Multiplying the column of function values by this gives you the derivatives. This doesn't work for the first and last element, and in fact you'll usually modify these rows depending on what boundary condition is needed, so I've just left them filled in with "?".

For a solver, you don't know what the y values actually are, so you construct a column that corresponds to the right side of the differential equation. For instance, if the equation was something like the trivial dy/dx = c and you were using the operator above the column would be

  ?
  c
  c
  c
  ?
with the first and last values to be filled in based on the boundary conditions. You then left matrix divide that by the operator matrix (i.e. multiply it by the inverse of the operator matrix). That gives the solution to the equation.

This is just a simple example and in practice the matrices will be larger and more complex.

Re: Poisson's Equation

#72
post #4

Great post, one nitpick -- I wouldn't say that a matrix is a "sparsely defined" function, but rather a function defined on a finite grid. It might also be worth pointing out that same approach works for any graph, not just a grid.

Also, what's confusing is that algebra usually uses matrices to describe linear functions from n-dimensional to m-dimensional vector spaces. Matrix has n rows, m columns, you give it an n-dim vector and after matrix multiplication you get back an m-dim vector. The author uses a matrix quite differently. You give it two integer coordinates i and j and it gives you the value at position (i, j) back. That's a valid use,…

Thanks for calling this out, I thought it might cause confusion. Matrices are super weird objects because they don't fit nicely into the {scalar, vector, function, operator} classes that maybe we're used to. A matrix is a function in that it can take in a vector and map it to a new vector. It is also an operator in that it can take in some other matrix (a function!) and give you a transformed matrix (a new function). It is also a function in the sense that it can map vectors to scalars, where the input vectors (x, y) are the coordinates and the scalar stored there is the output. All of this gets further complicated by the fact that the elements of a matrix can be scalars, complex numbers, or even matrices! They are really strange objects and maybe I'll write up a whole post just about that strangeness.

Re: Poisson's Equation

#73

Earlier quoted context omitted.

I feel the same. How can it be that I went to a world famous institution providing 2-to-1 student-teacher ratios, but I still think the best explanations are these modern internet explanations? I guess the best explanations just bubble up in the modern environment. > you're not supposed to learn everything in college, you're supposed to learn how to learn But to learn how to learn, you gotta learn some things to a so…

Honest question. 2-to-1 student-teacher ratio?? Where is that? Totally stunned.

Oxford tutorials do this. They typically have one, two or three students.

Re: Poisson's Equation

#74
post #65

Earlier quoted context omitted.

Hmmm, this looks more like a minimal surface, i.e. a solution to the minimal-surface equation[0], than a solution to Poisson's equation. Then again, both equations are of elliptic type. Some links for people who've never heard of minimal surfaces: https://en.wikipedia.org/wiki/Minimal_surface https://minimalsurfaces.blog/ (lots of illustrations) https://makmanx.github.io/math3435s18/talks/MSE.pdf (brief intro with hi…

Isn't Poisson's equation basically describing a minimal surface for small z? I'm not saying the badminton racket follows exactly a (discrete) 2D Poisson equation. But it's certainly related enough to be more than a surface similarly. The cords are under high tension, which means that any curvature along x (that is, dz^2/dx^2) will result in a net z-axis tension force unless balanced by an oppositely curved cord runni…

I didn't say you're completely wrong, either. :) (In fact, I stressed that both equations are of elliptic type, so solutions might look similar.)

One can make a similar heuristic argument, though, as to why the surface you observed should follow the minimal-surface equation.

EDIT, as you've updated your comment:

> Isn't Poisson's equation basically describing a minimal surface for small z?

Small changes in z, I think.

Re: Poisson's Equation

#75

Earlier quoted context omitted.

Yup. This wouldn’t get nearly the same amount of attention if the title were “Poisson’s equation is the most powerful tool in your toolbox for finding steady-state solutions to the heat equation with arbitrarily placed sources ”

But it'd make a helluva lot more sense. I tried to skim the article, I started to read comments, and it's only now that I've gotten to yours that I have the slightest idea of what this article is even about. If it wouldn't get as much attention with that title, then perhaps it isn't appropriate for HN in the first place.

The examples are about heat transfer, because it is an intuitive concept for most people, but as the article explains Poisson's Equation and these methods can be applied to a broad range of problems.

Re: Poisson's Equation

#76
The article never explains why ∇2 means "average of neighbors". It's the divergence of the gradient, which is (one kind of) n-dimensional 2nd derivative.

In a one-dimensional function, the second derivative is 0 when there is no curvature, aka a straight line (of any slope), and any point on a line is equal to the average of its neighborhood. A plane also has this property, but in 2+ dimensions you can also make other shapes (like saddles), that are made up of lines (like a plane) but the lines are twisted relative to each other in interesting ways (like "string art"). You can also visualize (aka impose a coordinate system for) these surfaces as having positive curvature (concave up) in one direction, and exactly opposite negative curvature (convex up, or concave down) in the orthogonal direction, summing to 0.

Re: Poisson's Equation

#77
post #9

Earlier quoted context omitted.

This is a typical issue with HN posts. Some poor soul wrote a somewhat competent and maybe even lengthy blog post / article about something they really care about and are knowledgeable about. It may be directed at a specific audience, or maybe just screaming into the void to record down some insight they had for themselves to read again later, or similar. And they use a more-than-necessary general title like "the bes…

I'd rather have more submissions like this on the HN frontpage than the slew of entrepreneurship advice (good or bad), programming-languages-du-jour and disguised content marketing. Anyway, the premise that "everything I see has to appeal to me" would best stay on YouTube where it originated.

It IS a good article, but the audience of the article is fairly specific yet left unspecified. As a general principal in technical writing it is advisable to start with a "why you should care" statement because this naturally informs the reader about the context.

Re: Poisson's Equation

#78
> It is customary when simulating heat flow to use a wacky color palette where red is hot and blue is cold, with all kinds of intermediate colors in between

In an otherwise excellent article, this is the only issue I could find. We really need to stop using/recommending/normalizing rainbow color maps (i.e. jet). They actively confuse readers by creating visual artifacts that aren't actually in the data.

This article has some great explanations and visuals.

https://jakevdp.github.io/blog/2014/10/16/how-bad-is-your-co...

The original post uses a rainbow color map to represent temperature-related things because having a diverging color map is often a useful intuition for temperature heat maps. But in that case, we should prefer one of the following diverging color maps listed on the matplotlib site (this list definitely isn't exhaustive, but it is helpful).

https://matplotlib.org/stable/_images/sphx_glr_colormaps_004...

More on matplotlib's well-chosen color maps:

https://matplotlib.org/stable/tutorials/colors/colormaps.htm...

Re: Poisson's Equation

#79
post #9

Sorry but can there be more context to why it is a powerful tool?

This is a typical issue with HN posts. Some poor soul wrote a somewhat competent and maybe even lengthy blog post / article about something they really care about and are knowledgeable about. It may be directed at a specific audience, or maybe just screaming into the void to record down some insight they had for themselves to read again later, or similar. And they use a more-than-necessary general title like "the bes…

[deleted]

Re: Poisson's Equation

#80

Earlier quoted context omitted.

My reply stems from enriquto's misunderstanding of the purpose of the article, which is the "typical technical education" itself . It's like they are wondering why the article even exists, and isn't just a one line reference to the julia docs. Clearly there's nothing wrong with already having specific knowledge of a subject, but questioning the purpose of technical education because you already have it is bizarre. Ma…

Sorry for the misunderstanding, then. It was not at all my purpose to disparage this article. It is a lovely article and very clearly written and illustrated. I'll state my point following your json parser example. If you write an article about the implementation of several json parsers, you may still want to call JSON.parse at the end, as a sanity check that your implementation is working. The function is right ther…

I agree with your point that it may be valuable to the reader to also mention common libraries or built-ins that solve the same problem that was discussed in the article somewhere near the end. More generally, linking to sources, docs, related work, or next steps can be very nice for readers to further their education. Framing your original comments with "the author should also mention... a standard solver like CHOLMOD" or "a standard solver like CHOLMOD ... as a sanity check that your implementation is working" as you described would have had a good chance of preventing our communication misfire and avoiding my (perhaps unnecessarily strong) snark.
Post reply on HN