HNHacker News
TopNewBestAskShowJobs

dmlorenzetti

2,350 karma · joined May 18, 2009

I work on problems of air quality and energy conservation in buildings. Mostly I write simulation and optimization tools, using mainstream languages like C, Python, and F95.
submissionscomments
dmlorenzetti··on Algorithms from the “Book”
In what way is a "discussion on interesting algorithms" not already pseudo-philosophical?

But OK, I'll do it your way:

An interesting class of algorithms is finite-difference approximations [1]. Even more interesting are algorithms for designing such approximations [2]. A key insight to making these algorithms work is that Taylor series approximations can be used to study the truncation errors of discrete approximations to continuous phenomena. However these techniques, by themselves, mainly interest me in the context of the physical problems they are meant to address. Since those problems come from the physical world, I would argue that the algorithms themselves don't satisfy the formal criteria set forth in the original question, of what algorithms god would write down in a book.

[1] See LeVeque, "Finite Difference Methods for Ordinary and Partial Differential Equations".

[2] See Hamming, "Numerical Methods for Scientists and Engineers".

dmlorenzetti··on Algorithms from the “Book”
By "woven into the fabric" I mean that the physical world executes what we think of as algorithms, as part of its natural existence. We write an equation that represents viscosity, but nature just executes viscosity because of the way the atoms interact. Or rather, viscosity emerges because of the way things interact. There is no equation, there is no computational organization, there is no unit testing, there's just doing-- at massive scale.

By the way, I would say not all algorithms occur in reality, and when they do, nature isn't necessarily very good at them. For example, sort and binary search just don't seem that high up on the list of things the physical world cares about. The natural sorting process by which dirt in a container separates out into various gradations of size, corresponds to bubble sort-- not an especially efficient algorithm.

dmlorenzetti··on Algorithms from the “Book”
Nature's primary algorithm is massive parallel computation, at a scale that beggars us all.

"The Book" is all around us. The algorithms that nature cares about are woven into the fabric of the physical world. Our algorithms are just poor approximations, intended to make simulation tractable on discrete computers.

For example, this site occasionally carries posts about making water look realistic in games. Those posts usually acknowledge that the graphics approach they describe is cheating compared to actually solving the Navier-Stokes equations. But the NS equations are just a mathematical expression of reality. We then cook that mathematical expression down even more, in order to arrive at a collection of algorithms (finite-difference approximations, domain partitioning, numerical solvers) that attempt to embody the math.

Yet problems that today we would consider impossibly hard to solve computationally-- for example, fully resolving the flow of water around a sailboat, not to mention the wind in its sails, and the stresses in the mast-- nature solves billions upon billions upon billions of times a second.

dmlorenzetti··on Ask HN: My first attempt at research
As an undergraduate, you may not fall prey to this particular problem, but where I work we have a lot of postdocs, and I often see them falling into ruts because they have a student mind-set of "I need to solve this problem entirely independently" rather than a company mindset of "my job is to deliver a solution to this problem."

Mostly this manifests as a reluctance to seek out advice from people who know the problem space well. It can also show up as a dedication to a particular self-brewed approach, despite strong hints from experts that some other approach probably would work better.

To turn that into direct advice, try to identify a mentor at work-- your boss may be one, but you really want a technical mentor-- who can spare you an hour a week or so to bounce ideas off of, and to give you an occasional nudge when you go astray (which you will). And then respect that mentor's time, by weighing his or her advice carefully before you reject it.

Another thing I've noticed is that physicists are very fast at making inroads on problems they've never encountered before. I'm not a physicist, so I can only speculate about why, but in general I think it relates both to their broad background training, and to an approach that emphasizes estimation as part of the analysis. I feel like physicists are far less likely than others to start off chasing a solution that's likely to tackle only 1% of the problem.

To turn that into direct advice, before you plunge off on some tack that you find interesting, try to perceive the outline to the answer of how this approach is going to solve the problem, or a substantial amount of your problem. Obviously you need time to build up your technical background, but maybe thinking in these terms will help you not only find the most likely research approach, but also figure out where you personally want to invest your time acquiring expertise.

Finally, the fact that you posted your question to HN implies your problem space is programming-related. Another side of the student/employee dichotomy is that students are much less likely to consider IP issues when scavenging code. Make sure you find out what your company guidelines are regarding provenance of any source code you use, and make sure you document where you got every last scrap of code you don't write yourself.

dmlorenzetti··on A new Gmail inbox
I know you can search within Calendar/Invites.

The issue arises if you know the message you want is somewhere under Calendar, but you're not sure whether it's in Calendar/Invites or Calendar/Rejected or Calendar/DateNotSetYet. As far as I know, it's not possible to search them all at once, just by searching under the tag Calendar.

dmlorenzetti··on A new Gmail inbox
How about useful search?

Currently, you can't direct searches within nested folders. You either search all messages, or search within one folder/label. So for example, I have e-mails grouped by project, and within big projects there are sub-labels:

  project1/testing
  project1/doc
  project1/proposals
  ...
  project2/testing
  ...
If I search in "project1", it doesn't look in any of those sub-folders.

Search also could use a grep-like capability. The "advanced search" options are a bit of a joke, especially coming from a company that cut its teeth on search.

dmlorenzetti··on Driving students into science is a fool's errand
It isn't clear what, exactly, Macilwain objects to, because he never bothers to give specific examples of what he finds wasteful.

At the outset, he identifies three broad categories of funding: (1) luring young people into STEM careers; (2) promoting science and technology at graduate schools; and (3) raising standards of science education. But the rest of his argument lumps these all together as if all the spending is for category #1, "luring".

For example, he points out that "no such government-backed programmes exist to pull children into being lawyers or accountants." And his broad argument, as expressed in the subheading, is that the funding biases the system to producing more scientists and technologists than it needs: "If programmes to bolster STEM education are effective, they distort the labour market..."

Only by ignoring the distinction between category #1, "luring", and category #3, "raising standards", can he complain that businesses who want better-educated scientists, if they really meant it, would just pony up and "pay and train newly graduated scientists and engineers properly." Either he thinks that the technical skills businesses want can be achieved by a quick training session after a broad general education, or else he thinks that raising the salaries of engineers will send a market signal to grade-schoolers that they ought to be more interested in STEM education. The problem of poor preparation never seems to enter his head. If all the accounting firms in the country were complaining that few recent college grads can add a column of numbers, and the government responded by trying to improve arithmetic education, would Macilwain complain about the money spent "luring children into accounting"?

In short, he might have an argument. But until he grounds it in specifics, he's just hand-waving with the broad idea that trying to improve STEM education distorts the market. This is obvious tripe, because the same broad argument could be applied to education in general: "If programs to bolster education are effective, they distort the market for educated workers. If they aren't, they're a waste of money. Besides, if businesses really wanted educated workers, they would pay and train new hires properly."

dmlorenzetti··on What are Fortran and Cobol used for today?
Fundamentally I agree with you. In my original comment, I was just trying to give a historical view of why people took the view that "optimizing Fortran compilers are hard to beat," rather than to defend it.

Personally, I think that idea is hard to justify these days, especially when, in my experience, finding 20-30% speed differences between optimizing Fortran compilers isn't all that hard.

dmlorenzetti··on What are Fortran and Cobol used for today?
In general, I agree with you. However, modern Fortran also has a strong module system, and some nice looping constructs (like explicitly-labeled loops that let you control "breaking" and "continuing" in nested loops quite easily), that made me like using it for even non-array-oriented programs (for other reasons, I don't use Fortran so much anymore).

The only thing I absolutely hated about Fortran for parsing data files is that, according to the standard, a text file has to end with what amounts to an empty line. Many Fortran environments break this rule intentionally, but occasionally you'll find one that follows the rules. It inevitably bites people who forget that their last line of data must be followed by a newline, or else the line may never get read.

dmlorenzetti··on What are Fortran and Cobol used for today?
One thing that for years made Fortran stand out is that the language explicitly assumes all arrays passed in to a subprogram have no overlaps.

Thus a Fortran compiler doesn't have to do anything special to make sure it preserves order when storing and accessing from two different arrays. Therefore the compiler can be much more aggressive about unrolling loops and changing the order of operations.

By contrast, given a loop like

  for( i=0; i<N; ++i ) {
    y[i] = 2*x[i];
    }
a C compiler has to assume that y[i] might be the same memory location as x[i+1], for example. Thus it has to ensure that the load into y[i] is complete before accessing x[i].

This is one reason you see a lot of C code that does numerical work hand-unrolled, with explicit stores, like this:

  for( i=0; i<N; i+=4 ) {
    xi = x[i];
    xip1 = x[i+1]; xip2 = x[i+2]; xip3 = x[i+3];
    y[i] = 2*xi; ... y[i+3] = 2*xip3;
    }
Now that C provides the "restrict" keyword, a smart C compiler can do many of the same optimization tricks that Fortran has had since day 1.
dmlorenzetti··on What Makes Code Hard to Understand?
Programmers often feel like the physical properties of notation have only a minor influence on their interpretation process. When in a hurry, they frequently dispense with recommended variable naming, indentation, and formatting as superficial and inconsequential.

It's ironic that the authors of this statement can't be bothered to typeset their opening quote marks in the right direction-- a typical noobie mistake in TeX.

dmlorenzetti··on [dead]
I read an analysis somewhere that claimed this degeneration was a symptom of alcohol and drug use in his early years. However, that analysis was on a partisan website, and I took it with a big grain of salt.

The main thing that struck me about the analysis was that it showed some of his earlier speeches, which I had never seen before, and he did indeed come across like a completely different person.

dmlorenzetti··on Show HN: Differential equations and slope field grapher
This looks like a decent amount of work went into it.

Can the user change the differential equation being shown? By the way, what equation is being shown here?

In my browser (Safari 5.0.6), initial conditions get rounded down to nearest integer. E.g., y(0)==1 graphs the same as 0, y(0)==1.8 graphs same as 1.

You might re-think the title of the "go" button, since it doesn't really "go" anywhere. Maybe "set"?

dmlorenzetti··on The Square Root of Not
Your comment supposes that the column headers are the inputs. However, I used the definition from the article-- "Here the numbers along the left edge, labeling the rows of the matrix, are the inputs to the gate..."

So, taking the columns as the outputs, my point is that adding down the columns corresponds to no particular causal relationship in the physics of the gate.

Your comment did, however, make me realize that I hadn't modified the row probabilities for the second row to sum to one (11-month old under foot). So thanks for that.

dmlorenzetti··on The Square Root of Not
Also note that the probabilities in each column and each row sum to 1, indicating that every possible combination of input and output has been accounted for.

Perhaps a quantum probabilistic NOT gate requires the columns to add up to 1, but it's certainly not a general requirement of any physical device that imperfectly implements a NOT gate.

Consider the following probability matrix:

      0    1
 0  0.1  0.9
 1  0.8  0.2
For any input (say, 0, in the top row), the output will be interpreted as either a 0 or 1, so the row sum must be 1.

However, there's nothing forcing the probability of 0 as an output in one row to depend on its probability in another row. One could implement the gate above in software, with no problems, and a hardware equivalent could certainly be produced.

[Edit-- fixed row probabilities in second row.]

dmlorenzetti··on How Parents Around the World Describe Their Children, in Charts
An interesting read is "Our Babies, Ourselves: How Biology and Culture Shape the Way We Parent" by Meredith Small.

It touches on a lot of the ideas in this article, in much greater depth, and looking across a wider range of cultures and continents.

In short, if you find this article interesting, I would highly recommend the book.

dmlorenzetti··on Facebook Home destroys any notion of privacy
The original post ends with this: "We need to ask our legislative representatives to understand that Facebook wants to go from our desktops and browsers right into our home-- the place where we need to be private."
dmlorenzetti··on Ask HN: What should I do?
I think it's a reference to Jean-Paul Sartre, who had strabismus-- not naming a real developer.
dmlorenzetti··on What’s going on Reddit these days has media manipulation written all over it
There are lots of places where corporate manipulation of the media bother me, but the front page of Reddit just isn't that high on my list.

What's there now? Among other things, there's a cartoon image of a man saying "It's locked." A picture of Keira Knightley, with an atheism/theism quote. A dog catching a piece of cheese. A picture of two shirtless guys jumping around in a hotel room. The top link points to an article with content that does actually seem to be corrupted by corporate manipulation (it could be read as an advert for Lockheed-Martin). However, the article itself is on Reuters, so Reddit is just acting as a low-quality aggregator site at that point.

In short, it's hard for me to take the front page of Reddit seriously as a "media" outlet. While I do find some subreddits interesting and informative, it's not clear how the quality of the front page would somehow get dragged down by a few professionally-produced marketing messages.

dmlorenzetti··on The Coolest Experience I Had as an Apple Store Employee
Admittedly in a few regards the story sounds not-quite-right. However I think if it was "typical internet fiction" then it wouldn't have ended with the revelation that the kids weren't deaf after all. Why deflate the punchline like that?

If pure glurge fiction, it would have ended with the narrator, or more likely the Apple store manager, receiving a note from the school, relating how the deaf kids had been treated poorly at every other store. Better yet, one of the deaf kids would have had a powerful father who went to the Apple store and lavished rewards on all the employees there. Father might even work for Microsoft. Let your imagination run wild.

dmlorenzetti··on Modeled on man: Breathable skin for buildings
One major obstacle this technology will face-- even in regions where ambient air temperatures are appropriate-- is control. The bimetal strip can only act based on its local temperatures.

By contrast, the amount of heating or cooling a building needs generally is set by the distributed conditions throughout the building. For example, many commercial buildings require cooling in the core throughout the year-- without regard for the insolation or the air temperature at the envelope. So this technology will not, in many cases, eliminate the need for mechanical assist.

Another aspect of the control problem is the wishes of occupants in the perimeter spaces. As described, the incident sunlight, or the interior temperature, are meant to control the porosity of the material. Thus occupants get no say in the amount of sunlight they get, or the amount of air passing through the wall.

Competing technologies allow much more control. For example, "smart glass" can regulate the amount of light entering a space, either in response to occupants, or to a building-level controller. Passive inlet vents can maintain a desired airflow rate, in the face of changes in wind pressure and indoor-outdoor temperature differences (controlling to airflow, rather than to local temperature, is desired for air quality reasons).

dmlorenzetti··on The search for better ways of storing electricity is hotting up
The article doesn't mention it, but HNers may be interested to know that a lot of the materials research behind batteries is done computationally. Numerical models are used to vet materials for desired properties, before having to physically test them.

The "Ceder Group" mentioned in the article has a cleverly-chosen name. While Dr. Ceder runs the group, its name also is an acronym for "Computational and Experimental Design of Emerging materials Research".

dmlorenzetti··on Why do some countries regulate baby names?
My great-grandfather came to the U.S. with two sons, Alpo and Ariante. Alpo in particular got a lot of grief about his name.

He mostly just called himself "Al", but I loved watching the scene play out when he had to give his legal name. He would say "Alpo", and the person behind the counter generally would give a visible start. Then grandpa would nod and say, very matter-of-factly, "Like the dog food." It instantly turned his name into a non-issue.

dmlorenzetti··on On calculating Fibonacci numbers in C
The recursive approach isn't necessarily worse, provided the compiler can do a so-called "tail call optimization" (in the original posting, note the line that says of the compiler optimization level, "We need -O2 so gcc will recognize the tail-call.").

Tail-call optimization says that if a function directly returns the result of calling another function, then you don't need to add to the call stack in order to effect the function call-- you just modify the current stack frame as needed. For a recursive function, apparently a good compiler can essentially transform this into code very similar to what you'd get with an explicit loop.

None of this means that a simple for-loop wouldn't be appropriate, or even faster. Personally I use for-loops a lot, and, like you, I would naturally incline to writing this using a loop rather than recursion.

I see yours is a new account, so maybe this is just a cultural thing that I've got used to. To generalize grossly, recursion is more fashionable on HN than iteration. Every once in a while you'll see a post here that touches on iteration-- like maybe somebody will mention the tradeoffs between counting down and counting up a loop variable. But guaranteed at least once a week you'll see something on recursion and functional programming.

My impression is that most people here understand that a simple for-loop will get the job done, but they don't see for-loops as very interesting, and don't figure it adds anything to the discussion to bring it up.

Meanwhile, there are people here who will actively advocate against using for-loops. There's a whole theory of functional languages that says that if your program doesn't directly modify variables, then it's easier to reason about. A for-loop modifies the trip variable, so it's not a functional construct.

dmlorenzetti··on Ask HN: are there (addicting, video) games which improve mathematical thinking?
Though I haven't used it myself, Dragonbox got a lot of attention some time ago.

See, for example, this Wired article: http://www.wired.com/geekdad/2012/06/dragonbox/all/

Here's an earlier HN discussion: http://news.ycombinator.com/item?id=4105397

dmlorenzetti··on The Easy Way To Solve Equations In Python
As for the bisection interval, I am not sure the basic c=(a+b)/2 is not enough. Can you provide an example where it fails?

Sure. I've experienced this myself, for example, when doing the research cited here: http://pubs.acs.org/doi/abs/10.1021/es202359j Unfortunately, my Lab doesn't have our report version of the work up on the web yet (I believe it should be freely available at some point, but they're re-doing the library).

In addition, I knew about this particular effect before I started that work, so I must have run into it earlier.

In most cases, naive bisection works fine. That's especially true if you use pretty loose tolerances-- for example, you if only want to identify the zero to a relative tolerance of 1e-6 or something coarse like that. But this work demanded very tight tolerances (because the output gets used in a time-marching numerical simulation that may iterate on time steps, and hence has to be very repeatable no matter what the initial condition). In this work, the relative tolerance was about 2e-15, and the absolute tolerance about 1e-18 (on a machine with double-precision epsilon about 2e-16).

By the way, if you're testing for convergence according to a bracket on the value, then you want to know (b-a) anyhow. So there's no reason not to go ahead and use it to bisect the interval as well.

Another interesting implementation detail-- at very tight relative tolerances, you also need to calculate the terminating bracket width based on the larger of |b| and |a|-- due to floating point effects, if you find the terminating bracket width by applying the relative tolerance to the smaller value, you can occasionally run into a problem where adding that width to one of a or b fails to change the estimated value.

dmlorenzetti··on The Easy Way To Solve Equations In Python
I hate to bash on this article, but the number of commenters calling it "nice" makes me want to warn that the implementations are not really very good.

Except for the bisection method, all of these implementations take an argument specifying the number of iterations to run. In most cases, the only way to terminate in fewer iterations is by hitting an "exact" root, i.e., calculating the residual as exactly zero. This is poor practice for a number of reasons. First, in practice it's pretty rare for a method to find an exact zero. Second, once a method has converged to the numerical precision of the machine, making more iterations just wastes flops. So a much better approach is to specify a solution tolerance (as shown with the bisection method). Even better is to provide absolute and relative tolerances, and to choose those values based on either the domain requirements, or on the machine characteristics. Dennis & Schnabel's excellent "Numerical Methods for Unconstrained Optimization and Nonlinear Equations" has a good discussion on choosing convergence tolerances.

This dependence on iteration counts to terminate, by the way, is probably why the author equates low iteration counts with greater accuracy. But in fact these methods don't vary in their intrinsic accuracy, rather, they vary in their order of convergence.

Another example of poor practice is in the bisection method implementation. One generally should not bisect an interval using c = (a+b)/2, because the nature of finite-precision arithmetic means there is no guarantee that c will lie between a and b, even if the machine can represent numbers between a and b. A better approach is to ensure a < b, then to set c = a + (b-a)/2. This expression is much less subject to roundoff errors.

dmlorenzetti··on Ask HN: What have I missed?
Are you sure the problem is your programming skills, rather than, say, the way you manage expectations about your productivity? Or the way you present what you've done?

If it was an honest performance review, they should have been more specific than "not completing enough work." Consider pressing for details about their performance expectations, and then either work to meet the metric they name, or work to convince them that the metric isn't the best one by which to measure your performance.

It may not be a problem you can solve by just boning up on exciting new technologies. You may have to educate them on the merits of things you do that, in their opinion, slow you down-- like writing unit tests, automating builds, creating bug databases, or whatever.

This book may not exactly address the situation you're in, but you might have a look at Terrence Ryan's "Driving Technical Change", which talks about how to convince others on your team of the merits of different approaches you've adopted.

dmlorenzetti··on How to implement an algorithm from a scientific paper
It's kind of funny that the article lists "authors citing their own work" as an identifying feature of groundbreaking research.

I don't know about CS, but in most scientific fields, this may be a bad sign. It can mean they're just trying to pump up their own reference counts, or it can mean they don't really know what other people are doing.

The only way to be sure that neither of these is the case is to know, a priori, that they're truly doing groundbreaking work.

dmlorenzetti··on Things I learned by pretending to be blind for a week
As a similar, but easier, experiment, try listening to Adobe Acrobat read a PDF file out loud-- especially if the PDF contains anything at all interesting, like mathematics, figures, tables, or any kind of "float" that pegs to the top of a page as the text flows around it.

While tools are available to let the PDF creator tag the document in order to facilitate reading, in practice they don't seem to be used much, and even then the experience is painful at best.

← PreviousPage 6 of 14Next →