*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?

In this article, we are going to answer this question by touching upon two concepts, namely theĀ Minimum PhaseĀ (MP) systems, andĀ Transfer Functions.

**Introduction**

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.

**Transfer Function**

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.

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[1].

**What are Non-Minimum Phase Systems?**

Now that we are familiar with an NMP system, letās define the system formally:

Having a delay in our system or a model zero on the right half of theĀ *s*āplaneĀ (aka Right-Half Plane or RHP) may lead to a non-minimum phase system.

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 [3].

**Case Study**

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. [4].

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) [5].

# Conclusion

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.

**Thanks for reading š**

*If you liked this post, you can join my mailing list to receive similar posts. You can follow me on **LinkedIn**, **GitHub**, **Twitter** and **Medium**.*

*And finally, you can find my knowledge forest š² (raw digital notes) at **notes.ealizadeh.com**.*

**š© Join my mailing list**

# References

[1] MATLAB. (2020, October 25).Ā *What are Transfer Function Models?*Ā Retrieved fromĀ https://www.mathworks.com/help/ident/ug/what-are-transfer-function-models.html

[2] Wikipedia. 2020.Ā *Minimum phase*. Last modified August 8, 2020,Ā https://en.wikipedia.org/wiki/Minimum_phase

[3] 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)

[4] 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

[5] G. F. Franklin, J. D. Powell, A. Emami-Naeini,Ā *Feedback Control of Dynamic Systems*, Seventh Edition

ā¬
ļø **Previous Post **

**ā”ļø Next Post**