This article is also published on Towards Data Science Blog.
Table of Content
Have you ever wondered why when you turn the hot water knob on in the shower, the water will be cold for a few seconds, and then it gets hot or vice versa?
Let me first elaborate on the question. The phenomenon I mentioned in the question is particularly noticeable in climates, where water supplies are different than the ambient temperature. I lived in both extreme climates. In a hot country where the temperature reaches 45° Celcius (113° Fahrenheit) in summer if you turn the cold water knob, the water supply is first super hot, and then after some time, it gets colder. On the other hand, I’m currently living in a city wherein winter, the temperature reaches -20° Celcius (-13° Fahrenheit), and even less. If you turn the hot water knob, it takes a few seconds for the water supply to get hot. Both phenomena follow a similar behavior from a control engineering perspective.
This article will answer this question from a control system theory perspective. The short answer is that because the water supply system in the shower is a non-minimum phase (NMP) system.
To get a better understanding of how an NMP system behaves, let’s work on an example. We are going to need a mathematical model for our system. Since NMP can be better understood using the transfer function model, we need to be aware of this concept. However because this representation is less common than other mathematical models like differential equations, let’s first briefly go over what the transfer function is and how a model can be represented in this way. If you are already aware of what a transfer function is, then feel free to jump to the example.
There are several ways to represent a physical system’s mathematical model, such as differential equations, state-space representation, and transfer function. Most commonly, we use time-based functions to model our physical systems using the first two approaches mentioned (just to be clear we can write differential equations of a model in frequency domain but it’s less common in mathematical modeling of physical systems). However, a transfer function provides us with another way of looking at a system by analyzing the system in the frequency domain. Now, let’s see what a transfer function is!
What is the Transfer Function?
A transfer function model describes an input-output relationship of a system using a ratio of polynomials. So, an input signal is given to a system to produce a controlled output (aka response). This type of modeling is different than using differential equations and state-space representations where the model dynamics is available.
A transfer function is another way of viewing a dynamical system but in the frequency domain by analyzing the system response for a given input signal.
The transfer function of a control system is the ratio of the Laplace transforms of output signals over the Laplace transform of the input signal. In a nutshell, instead of analyzing a model in the time-domain using time-based differential equations, the goal here is to analyze the model in the frequency-domain using a transformation.
So, let’s say we have a system with and as our input and output signals. The transfer function can be calculated as shown above.
The roots of the numerator polynomial are called the model zeros, and the roots of the denominator polynomials are called the model poles. The zeros affect the input to a system, and the poles affect the system response and its stability. For zero-pole analysis, we should use the s−plane that is a complex plane on which Laplace transforms are graphed.
In this article, we are only interested in the initial response of the system in order to answer the question of why the shower first gets cold before it gets hot? Since the initial system response is closely related to system zeros as noted earlier, therefore, we will not talk about the poles (perhaps that can be a topic for another article).
What are Non-Minimum Phase Systems?
Now that we are familiar with an NMP system, let’s define the system formally:
Note that there is only one minimum phase system for a given magnitude response, but there is an infinite number of NMP systems. This is the reason why we do not hear a term like the maximum phase system. More detail about non-minimum phase systems with mathematical description is available in .
Now that we are familiar with Transfer Functions, let’s see how a non-minimum phase system will look like and answer why we water will first get colder before it gets hot!
Below are two systems that have the same poles but with different zeros. System 1 has a zero at , whereas System 2 has a zero at .
Let’s separate poles and zeros of System 1 for our analysis. As noted earlier, you can think of the zero as a modified input let’s call it . As noted earlier, we are interested in the model zeros in this article, so we will focus on the green block.
Let’s see how the modified input of System 1 is in the time-domain by applying an inverse transform
Following the same procedure for System 2, the modified input for System 2 will be
So, the only difference is in that negative sign. Let’s plot the input and the modified input signals for both systems and see how both differ.
Let’s use the unit step as our input signal (the gray function on the top). Since the input signal is a unit step, the output is referred to as the step response. The modified input is illustrated bellow that is the summation of and a derivative of . The derivative component of is blue for System 1 and red for System 2.
The negative derivative of in System 2 causes the step response of System 2 to go first towards the opposite direction of the expected response (steady-state value) before moving towards the expected response (the red curve). This is in contrast to the step response of System 1 (blue curve) that does not have this undershoot at the beginning.
A nice illustration is available in Ref. .
So, the next question is what to do when we have a non-minimum phase system?
The solution is to just wait ⏳. We have to wait until the undershoot is over. We can also design a controller/compensator for such systems. However, designing a controller is harder for NMP systems for several reasons like the risk of the system getting unstable or having a slower response.
Now, let’s get back to our question in the beginning. Why the water in the shower is cold first when you open the hot water supply before getting hot?
The answer is that when you open the hot water supply in showers, the system experiences an undershoot since it’s a non-minimum phase before the water gets hot. In this case, it’s better to wait a few seconds so that the system recovers (from the undershoot). You should not change the direction or open the other knob since that will end up in a colder shower in the long-run!
Another example that is usually used in Control System books is the aircraft altitude change in response to elevator deflection. In this case, when the aircraft tries to increases its altitude using elevator, the altitude slightly decreases due to the aircraft tailing down (resulting in a downward aerodynamic force) before it increases its altitude. This example is available with the mathematical model in Chapter 6 of the book “Feedback Control of Dynamic Systems” by Franklin (7th edition) .
In this article, we learned about what a non-minimum phase system is and why such a system first experiences response in the wrong direction (you turn the hot water knob, and the water is first cold!). We also talked about the transfer function and how it can be useful in analyzing systems.
The Jupyter notebook containing the code used to create the step responses for the case study is available on GitHub.
Thanks for reading 🙏
And finally, you can find my knowledge forest 🌲 (raw digital notes) at notes.ealizadeh.com.
📩 Join my mailing list
 MATLAB. (2020, October 25). What are Transfer Function Models? Retrieved from https://www.mathworks.com/help/ident/ug/what-are-transfer-function-models.html
 Wikipedia. 2020. Minimum phase. Last modified August 8, 2020, https://en.wikipedia.org/wiki/Minimum_phase
 Jesse B. Hoagg & Dennis S. Bernstein, Nonminimum-Phase Zeros – Much To Do About Nothing (Classical Control Revisited – Part II), June 2007, IEEE Control Systems Magazine (Available here)
 MATLAB. (2019, December 9). Control Systems in Practice, Part 6: What Are Non-Minimum Phase Systems? YouTube. https://www.youtube.com/watch?v=jGEkmDRsq_M
 G. F. Franklin, J. D. Powell, A. Emami-Naeini, Feedback Control of Dynamic Systems, Seventh Edition
⬅️ Previous Post
Copyright © 2021 Esmaeil Alizadeh - All Rights Reserved