I am a Software Engineering student and this year I learned about how CPUs work, it turns out that electronic engineers and I also see it a lot in my field, we do use derivatives with discontinuous functions. For instance in order to calculate the optimal amount of ripple adders so as to minimise the execution time of the addition process:

$$\text{ExecutionTime}(n, k) = \Delta(4k+\frac{2n}{k}-4)$$

$$\frac{d\,\text{ExecutionTime}(n, k)}{dk}=4\Delta-\frac{2n\Delta}{k^2}=0$$

$$k= \sqrt{\frac{n}{2}}$$where $n$ is the number of bits in the numbers to add, $k$ is the amount of adders in ripple and $\Delta$ is the “delta gate” (the time that takes to a gate to operate).

Clearly you can see that the execution time function is not continuous at all because $k$ is a natural number and so is $n$.

This is driving me crazy because on the one hand I understand that I can analyse the function as a continuous one and get results in that way, and indeed I think that’s what we do (“I think”, that’s why I am asking), but my intuition and knowledge about mathematical analysis tells me that this is completely wrong, because the truth is that the function is not continuous and will never be and because of that, the derivative with respect to $k$ or $n$ does not exist because there is no rate of change.If someone could explain me if my first guess is correct or not and why, I’d appreciate it a lot, thanks for reading and helping!

**Answer**

In general, computing the extrema of a continuous function and rounding them to integers does *not* yield the extrema of the restriction of that function to the integers. It is not hard to construct examples.

However, your particular function is *convex* on the domain $k>0$. In this case the extremum is at one or both of the two integers nearest to the *unique* extremum of the continuous function.

It would have been nice to explicitly state this fact when determining the minimum by this method, as it is really not obvious, but unfortunately such subtleties are often forgotten (or never known in the first place) in such applied fields. So I commend you for noticing the problem and asking!

**Attribution***Source : Link , Question Author : Santiago Pardal , Answer Author : This site has become a dump.*