The partial derivative of a function that includes step functions

  • A
  • Thread starter fahraynk
  • Start date
  • #1
184
5

Summary:

a function which includes step functions, but the step function changes with time

Main Question or Discussion Point

I have this function, and I want to take the derivative. It includes a unit step function where the input changes with time. I am having a hard time taking the derivative because the derivative of the unit step is infinity. Can anyone help me?

##S(t) = \sum_{j=1}^N I(R_j(t)) a_j\\
I(R_j) = \begin{array}{cc}
\{ &
\begin{array}{cc}
0 & R_j < 7 \\
1 & R_j \geq 7
\end{array}
\end{array} \\
a_j \text{ is some known constant}
##
##R_j(t) : t \rightarrow Z## (##R_j## is an integer ##\in [1,10]## which decays over time)

##R_j## starts at ##10## and decays over time, and I can approximate its derivative as : ##\frac{dR_j}{dt}= \frac{R_j(t_2) - R_j(t_1)}{t_2-t_1}##

I would like to take the derivative of ##S##

##\frac{\partial S}{\partial t} = \sum_{j=1}^n (\frac{\partial I_j}{\partial R_j} \frac{\partial R_j}{\partial t})a_j##

But, I read that the derivative of a shifted Heaviside function ##H(x-7)## is the dirac delta function ##\delta(x-7)##. But, this dirac delta function, as I am aware, has an infinite value at ##x=7##.

But, the change in ##S## is definitely finite because ##R## decays linearlly with time, so how can ##S## be infinite? How can I get the derivative of ##S##? I want to show how ##S## changes as a function of ##R##

I think the unit step is just by nature not continuous... is there an approximation I can use for this function that would be continuous?
 
Last edited:

Answers and Replies

  • #2
andrewkirk
Science Advisor
Homework Helper
Insights Author
Gold Member
3,836
1,418
You have not specified the functions ##R_1,...,R_N##. They need to be fully specified before we can consider taking derivatives.
 
  • #3
RPinPA
Science Advisor
Homework Helper
571
319
S is a function which takes on discrete values, and jumps instantaneously between those values. The time derivative is either 0 (between jumps) or doesn't exist (at jumps).

But, I read that the derivative of a shifted Heaviside function H(x−7) is the dirac delta function δ(x−7).
Yes, in physics we do that. It's not exactly rigorous but makes a certain kind of sense. The Heaviside function has a vertical line in it. The slope of a vertical line is infinite.

The usual approach to make a statement like the above semi-rigorous is to make a smooth approximation, for instance a function which makes the jump in finite time. And then take the limit as that finite time gets smaller and smaller.

But, this dirac delta function, as I am aware, has an infinite value at x=7.

But, the change in S is definitely finite because R decays linearlly with time, so how can S be infinite?
Sure, S is finite. But its rate of change, being a finite change divided by a time interval of 0, is infinite. Again, the slope of a vertical line is infinite.

I think the unit step is just by nature not continuous... is there an approximation I can use for this function that would be continuous?
Sure. It's just a question of what approximation would be most convenient to work with. First thing that occurs to me is something like this:
$$\hat I(R_j) = \begin{cases}0, & R_j \lt 7 \\
\frac{R_j-7}{a}, & 7 \leq R_j \lt 7 + a \\
1, & R_j \geq 7+a
\end{cases}$$

That interpolates from 0 to 1 over an interval of width ##a##, with a line of slope ##1/a##. This makes ##\hat I## continuous (I'm using a "hat" to indicate that this is a modified version of your indicator function). But its derivative is still not continuous. ##\hat I## is not differentiable at ##7## or ##7+a##.

So my next thing to try for the interpolation is a cubic, a function of the form ##f(R-7) = a_0 + a_1(R-7) + a_2(R-7)^2 + a_3(R-7)^3## with the conditions that it is 0 and 1 at the two endpoints and has derivative 0 at those two endpoints. With a little bit of algebra that leads me to this:

$$\hat I(R_j) = \begin{cases}0, & R_j \lt 7 \\
\frac{3}{a^2}(R_j - 7)^2 - \frac{2}{a^3}(R_j-7)^3, & 7 \leq R_j \lt 7 + a \\
1, & R_j \geq 7+a
\end{cases}$$

This version goes smoothly from 0 to 1 over the interval and is differentiable everywhere. But the piecewise nature might still cause you some headaches. So the other suggestion I have is to use something like ##\hat I(R_j) = \frac{1}{2} \left [1 + \tanh \left ( \frac {R_j - 7}{a} \right ) \right ]##, which becomes the step function in the limit.

In all cases, you would take the limit as ##a \rightarrow 0##.
 
  • Like
  • Love
Likes DEvens and fahraynk
  • #4
184
5
Thanks @RPinPA ! Great answer. If I use that hyperbolic function, its derivative is something like ##\frac{1}{2\alpha} (1 -tanh^2(\frac{R_j - 7}{\alpha} ))##

Which is a function of ##\alpha##.

If ##R_j## is a measurement, would it make sense to set ##\alpha## to be the average time between measurements?
 

Related Threads on The partial derivative of a function that includes step functions

Replies
2
Views
3K
Replies
2
Views
3K
  • Last Post
2
Replies
25
Views
3K
Replies
1
Views
422
Replies
6
Views
4K
Replies
2
Views
3K
Replies
6
Views
4K
Replies
6
Views
13K
Replies
3
Views
6K
Top