# Converting Piecewise function to Heaviside equation

Good day! I would just like to ask on how to convert a particular piece wise function to a heaviside equation.

For a function,

f(t) = t2 if t < 2
t - 1 if t >= 2

the heaviside equation would be,

H(t) = t + (t-1 -t)u2(t)
or
H(t) = t - u2(t)

but i can't comprehend on how to solve the following function,

g(t) = t if t < 2
0 if t = 2
t if t > 2

i tried solving it, and i my answer is

H(t) = t + (0-t)u2(t) + (t-0)u2(t)
or
H(t) = t

did i do it right? thanks Related Calculus and Beyond Homework Help News on Phys.org
BruceW
Homework Helper
hi alex! welcome to physicsforums :)

for the first example, I don't think that is right. H(t) = t - u2(t) means that for t<2, you get H=t. But that's not right, since you want it to be t2 for this case.

Simon Bridge
Homework Helper
Hmm... intreguing notiation, what would happen is the peicewise boundary was at ##\small t=<\text{not an integer}>## like t=3.5 ... so you'd write ##u_{3.5}(t)## ? Why not ##u(t-3.5)## ?

in general, you have a boundary at t=b, you want f(t) to apply for t<b and g(t) to apply for t>b.

H=f(t) is fine right up until t=b, after that you want to remove f(t) and replace it with g(t).
Can you write the heaviside version of that down?

The trick is to be careful with the substitutions.

Ray Vickson
Homework Helper
Dearly Missed
Good day! I would just like to ask on how to convert a particular piece wise function to a heaviside equation.

For a function,

f(t) = t2 if t < 2
t - 1 if t >= 2

the heaviside equation would be,

H(t) = t + (t-1 -t)u2(t)
or
H(t) = t - u2(t)

but i can't comprehend on how to solve the following function,

g(t) = t if t < 2
0 if t = 2
t if t > 2

i tried solving it, and i my answer is

H(t) = t + (0-t)u2(t) + (t-0)u2(t)
or
H(t) = t

did i do it right? thanks Exactly what definition of the Heaviside function are you employing? There are three common definitions of H(x); they all use H(x) = 0 if x < 0 and H(x) = 1 if x > 0. Where they differ is in their treatment of H(0): some use H(0) = 1, some use H(0) = 0 and some use H(0) = 1/2. How you deal with your problem (if you can at all) depends on how you treat H(0).

Thank you so much for the response good sirs hi alex! welcome to physicsforums :)

for the first example, I don't think that is right. H(t) = t - u2(t) means that for t<2, you get H=t. But that's not right, since you want it to be t2 for this case.
Sorry for that sir Bruce. I missed to proofread that part..that's suppose to be H(t) = t2 - u2(t)

Hmm... intreguing notiation, what would happen is the peicewise boundary was at ##\small t=<\text{not an integer}>## like t=3.5 ... so you'd write ##u_{3.5}(t)## ? Why not ##u(t-3.5)## ?

in general, you have a boundary at t=b, you want f(t) to apply for t<b and g(t) to apply for t>b.

H=f(t) is fine right up until t=b, after that you want to remove f(t) and replace it with g(t).
Can you write the heaviside version of that down?

The trick is to be careful with the substitutions.
Sorry for that notation sir Simon. i was just following the notation uc(t) in preparation for an inverse Laplace transform:
L(uc(t)) = (e-cs)/s

Going back on the heaviside version on what you have given then is it
H = f(t) + (g(t)-f(t))u(t-b) ?

but what if you are given H = f(t) which is fine until t < b, then at t = b you want to remove f(t) and replace it with g(t), then at t> b you want to remove g(t) and replace it with k(t).

How do i then write this in heaviside then?

thank you very much for the help! BruceW
Homework Helper
Sorry for that sir Bruce. I missed to proofread that part..that's suppose to be H(t) = t2 - u2(t)
mm, it's still not right. if t>2, then it does not give the right answer. More proofreading required maybe :)

BruceW
Homework Helper
Going back on the heaviside version on what you have given then is it
H = f(t) + (g(t)-f(t))u(t-b) ?
looks good to me.

alexjesse said:
but what if you are given H = f(t) which is fine until t < b, then at t = b you want to remove f(t) and replace it with g(t), then at t> b you want to remove g(t) and replace it with k(t).
are you actually asked to do this, or are you just wondering?

Simon Bridge
Homework Helper
Going back on the heaviside version on what you have given then is it
H = f(t) + (g(t)-f(t))u(t-b) ?

but what if you are given H = f(t) which is fine until t < b, then at t = b you want to remove f(t) and replace it with g(t), then at t> b you want to remove g(t) and replace it with k(t).

How do i then write this in heaviside then?
As already pointed out: depends on your definition of the Heaviside ;)
The trick is to make sure you are multiplying by zero at that point. (or by 1 ... the values elsewhere can be accommodated by adjusting f and g and k.)
Off the question I am guessing that u(t) is not zero at t=0... so you need to rearrange it to change that.

Look at: 2u(t)-1 perhaps, or u(-t), 1-u(t), for clues.
But it is difficult to guide you without the definition you are using.

Last edited:
BruceW
Homework Helper
As already pointed out: depends on your definition of the Heaviside ;)
The trick is to make sure you are multiplying by zero at that point. (or by 1 ... the values elsewhere can be accommodated by adjusting f and g and k.)
I'm guessing this is not possible by just using Heaviside functions though... unless he uses different types of Heaviside functions, which could get confusing.

and by 'different types' I mean like, one is for x>a and another is for x>=a.

Simon Bridge
Homework Helper
I'm guessing this is not possible by just using Heaviside functions though.
Notice: if you can make an effective function h with behavior:

h(t)= 0:t=0, 1:t≠0
(Finding h is implied in the problem statement in post #1.)

then 1-h(t)=1:t=0, 0:t≠0

something like: fu(-t)+gu(t)+[k-(g+f)u(0))(1-h(t)] gives f:t<0, g:t>0, k:t=0.
the u(0) is needed to account for the different definitions.

Does that work? - need coffee.
Checking:

t<0: 1f + 0g + 0[k - (g + f)u(0)] = f
t>0: 0f + 1g + 0[k - (g + f)u(0)] = g
t=0: u(0)f +u(0)g + 1[k - (g + f)u(0)] = u(0)[(g + f) - (g + f)] + k = k

BruceW
Homework Helper
Notice: if you can make an effective function h with behavior:

h(t)= 0:t=0, 1:t≠0
(Finding h is implied in the problem statement in post #1.)
can you really call that a Heaviside step function though? maybe that is OK, it just seems strange, since I've not seen that kind of Heaviside step function before.

Simon Bridge
Homework Helper
can you really call that a Heaviside step function though?
No, of course not! Which is why I didn't. I said:
me said:
Notice: if you can make an effective function h with behavior:...

h(t) has to be constructed from heaviside step functions.
Since it is the answer to one of the problems in post #1 it is against the rules for me to show you how it's done.

I have to wait for OP to get back to us ... then I can maybe do the next hint.
Oh all right ... hint: it's easiest with the u(0)=1/2 definition.
If you cannot wait - pm me. (after all, I could be wrong :) )

Aside: another exercise is to see if you can use one to the step function types to make each of the other ones. If you can, then your observation that you need to be able to use more than one type is not an obstacle.

Simon Bridge
Homework Helper
@alexjesse: how did you get on?

Simon Bridge
Homework Helper
It's been more than 2 weeks since the thread was started - homework is usually due in 1-2 weeks so it's probably safe to let people off the hook. Presumably alexjesse intends to return to say what the actual answers were, so he can help other people ;) ??
##\renewcommand{\u}{\text{u}} \renewcommand{\h}{\text{h}}##

Using
##\u(t)=\left \{
\begin{array}{rl}
0 & :\; t<0;\\
\frac{1}{2} & :\; t=0;\\
1 & :\; t>0
\end{array}
\right .## means that: ##\; (2\u-1)^2 = \left \{
\begin{array}{rl}
1 & :\; t<0;\\
0 & :\; t=0;\\
1 & :\; t>0
\end{array}
\right .##

... looks promising. With that in mind:

Indexing the other two step-function definitions by the value they take at t=0, so we can tell them apart, gives:

##\u_0(t)=\left \{
\begin{array}{rl}
0 & :\; t\leq0;\\
1 & :\; t>0
\end{array}
\right .## and ##\; \u_1(t)=\left \{
\begin{array}{rl}
0 & :\; t<0;\\
1 & :\; t \geq 0
\end{array}
\right .##

Define h(t) from post #10 as follows:

##\h(t) = \left \{
\begin{array}{rl}
0 & :\; t<0;\\
1 & :\; t=0;\\
0 & :\; t>0
\end{array}
\right .##

I can express h(t) in terms of each of the step-function definitions as follows:

##\h(t)=1-\big(2\u(t)-1\big)^2=\u_1(-t)+\u_1(t)-1 = 1-\frac{1}{2}\big(u_0(-t)+u_0(t)\big)##

I haven't put these in their simplest form - this is so you can see the reasoning (and correct any mistakes I may have made)...

Using h(t) you can convert any of the definitions into any of the others.
i.e. converting ##\u_0## and ##\u_1## into ##\u##:

##\u=\u_1-\frac{1}{2}\h = \u_0+\frac{1}{2}\h##

From these observations, it should be possible to construct any piece-wise function from Heaviside step functions ... with the possible exception of stuff like Cantor's staircase.