Ask
26

Engineers differentiate functions that only exist at whole numbers — is that legitimate or a useful lie?

I am a software engineering student and I keep meeting this in hardware courses. A quantity is only defined for whole numbers — how many adder stages, how many pipeline registers, how many parallel units — and the analysis writes down a continuous function, differentiates it, sets the derivative to zero and rounds the answer to the nearest integer.

That is presented as the method, not as an approximation. But the underlying function does not exist between the integers, so its derivative should not exist either.

Is there a justification for this, and does it ever give the wrong answer?

4 answers Share
Report

Answering anonymously — a moderator will review it first.

  • @discrete_dilek · 3d ago

    You have identified something real. The honest description of what is happening has three steps, and only the middle one is calculus.

    1. Somebody chose a continuous extension. The formula for delay or cost was written using operations that happen to make sense for any real number, so it defines a continuous function that agrees with the discrete one at the integers.
    2. The extension is optimised with ordinary calculus.
    3. The result is rounded back to an integer.

    Step 1 is the part that is never stated and it is where the assumption lives. There is no unique continuous extension of a function on the integers — infinitely many curves pass through the same set of points, and they have their minima in different places. The one being used is whichever one the algebra happened to produce.

    So it is not illegitimate, but it is a modelling choice being presented as a derivation.

    29
    Share
    Reply

    Answering anonymously — a moderator will review it first.

    Report
  • @proof_pinar · 4d ago

    And yes, it can give the wrong answer. The construction is easy: take any function on the integers and pass a wiggly curve through the same points with its minimum between two of them. Rounding the continuous minimum then lands you on a point that is not the discrete minimum.

    What makes the engineering cases work in practice is a property the textbook rarely names: the extension used is typically convex, or at least unimodal, over the range of interest.

    For a convex function on an interval, the discrete minimum is guaranteed to be at one of the two integers bracketing the continuous minimum. That is a real theorem and it is the thing doing the work.

    Which gives you the correct version of the recipe, and it is barely more effort than the one you were taught: differentiate, find the continuous optimum, then evaluate the original discrete function at both neighbouring integers and compare. Do not round — check. Rounding is a guess that happens to be right most of the time; checking two values is certain and costs one extra line.

    26
    Share
    Reply

    Answering anonymously — a moderator will review it first.

    Report
  • @algo_arda · 4d ago

    Practical note from the other side: in real hardware and software design, the continuous model is usually the least wrong part of the analysis.

    The cost function itself is an idealisation — it ignores layout, routing, cache behaviour, manufacturing variation, and everything else that decides the actual answer. Worrying about whether the optimum is at 6 or 7 stages when the model has a twenty percent error is misplaced precision.

    So the honest engineering position is: use the calculus to find the neighbourhood, check the two or three candidates properly, and then measure. The mathematics gets you to the right street; it does not pick the house.

    15
    Share
    Reply

    Answering anonymously — a moderator will review it first.

    Report
  • @numeric_noor · yesterday

    There is a discrete version of the whole toolkit, which is worth knowing exists even if nobody teaches it alongside the calculus.

    Instead of the derivative you use the forward difference: f(n+1) − f(n). The minimum of a discrete convex function is where that difference changes sign from negative to positive. That is the exact analogue of the derivative crossing zero, it needs no continuous extension at all, and it is provably correct rather than approximately so.

    For a lot of the problems in your courses this is genuinely easier than the calculus route, because the difference often simplifies dramatically. It also generalises to the cases where the continuous extension is awkward or does not exist.

    20
    Share
    Reply

    Answering anonymously — a moderator will review it first.

    Report