# Transfer function model

## Introduction
In this section, we present the transfer-function approach to modeling and analyzing dynamic systems. We first describe the concept of transfer functions and then we use linearization to approximate every possible non-linear model to a transfer function model. Since software plays an important role in obtaining computational solutions of transient response problems, we present a detailed introduction to writing software programs to obtain response curves for time-domain inputs such as the step, impulse, ramp, and others. Finally we illustrate all these concept using various examples.
% In the field of system dynamics, transfer functions are frequently used to characterize the input--output relationships of components or systems that can be described by linear, time-invariant differential equations. We begin this section by defining the transfer function and deriving the transfer function of a mechanical system. Then we discuss the impulse response function, or the weighting function, of the system.

## The Laplace transform

### Definition

The [Laplace transform](https://en.wikipedia.org/wiki/Laplace_transform) constitutes an integral transform with the complex exponential function $e^{s t}$ as kernel. It maps a complex-valued signal $x(t) \in \mathbb{C}$ with real-valued independent variable $t \in \mathbb{R}$ into its complex-valued Laplace transform $X(s) \in \mathbb{C}$ with complex-valued independent variable $s \in \mathbb{C}$. The Laplace transform is named after its discoverer [Pierre-Simon Laplace](https://en.wikipedia.org/wiki/Pierre-Simon_Laplace).

Complex exponential functions constitute eigenfunctions of linear time-invariant (LTI) systems. The Laplace transform is therefore of special use in the context of signals and LTI systems. It is introduced in the following.

### Two-Sided Laplace Transform

The two-sided (or bilateral) Laplace transform is defined as

\begin{equation}
X(s) = \int_{-\infty}^{\infty} x(t) \, e^{- s t} \; dt
\end{equation}

where $X(s) = \mathcal{L} \{ x(t) \}$ denotes the Laplace transform of $x(t)$. A complex signal $x(t) \in \mathbb{C}$ with real-valued independent variable $t \in \mathbb{R}$ is represented by its complex valued Laplace transform $X(s) \in \mathbb{C}$ with complex independent variable $s \in \mathbb{C}$. The variable $s$ can be interpreted as complex frequency $s = \sigma + j \omega$ with $\sigma, \omega \in \mathbb{R}$.

Whether a Laplace transform $X(s) = \mathcal{L} \{ x(t) \}$ exists depends on the complex frequency $s$ and the signal $x(t)$ itself. All values $s$ for which the Laplace transform converges form a [*region of convergence*](https://en.wikipedia.org/wiki/Radius_of_convergence) (ROC). The Laplace transforms of two different signals may differ only with respect to their ROCs. Consequently, the ROC needs to be explicitly given for an unique inversion of the Laplace transform.

### One-Sided Laplace Transform

Causal signals play an important role in the theory of signals and system. For a causal signal $x(t) = 0$ for $t <0$, the relation $x(t) = x(t) \cdot \epsilon(t)$ holds. Introducing this into the definition of the two-sided Laplace transformation yields

\begin{equation}
X(s) = \int_{-\infty}^{\infty} x(t) \cdot \epsilon(t) \, e^{- s t} \; dt = \int_{0}^{\infty} x(t) \, e^{- s t} \; dt
\end{equation}

This motivates the definition of a one-sided Laplace transform

\begin{equation}
X(s) = \int_{0}^{\infty} x(t) \, e^{- s t} \; dt
\end{equation}

In the literature both the one- and two-sided Laplace transform are termed as Laplace transform. Both give the same result for causal signals.

### Transformation of the Dirac Impulse

The transform $\mathcal{L} \{ \delta(t) \}$ of the Dirac impulse is derived by introducing $\delta(t)$ into the definition of the two-sided Laplace transform and exploiting the sifting property of the Dirac delta function

\begin{equation}
\mathcal{L} \{ \delta(t) \} = \int_{-\infty}^{\infty} \delta(t) \, e^{- s t} dt = e^{- s t} \Big\vert_{t=0}  =  1
\end{equation}
for $s \in \mathbb{C}$. The ROC covers the entire complex plane.

The transform of the Dirac impulse is equal to one. Hence, all complex frequencies $s$ are present with equal weight. This is an important property in the theory of signals and systems, since the Dirac impulse is used to characterize linear time-invariant (LTI) systems by their impulse response) $h(t) = \mathcal{H} \{ \delta(t) \}$.

### Transformation of the Causal Complex Exponential Signal

The transform $X(s) = \mathcal{L} \{ x(t) \}$ of the causal complex exponential signal

\begin{equation}
x(t) = \epsilon(t) \cdot e^{-s_0 t}
\end{equation}

with complex frequency $s_0 \in \mathbb{C}$ is derived by evaluation of the definition of the one-sided Laplace transform

\begin{equation}
\begin{split}
X(s) &= \int_{0}^{\infty} e^{-s_0 t} \cdot e^{-s t} \; dt = \frac{-e^{-(s+s_0)t}}{s+s_0} \, \bigg\vert_{0}^{\infty} = \frac{-1}{s+s_0} \left[ \lim_{t \to \infty} \left( e^{- (s+s_0) t} \right) -1 \right] \\
&= \frac{1}{s + s_0}
\end{split}
\end{equation}

As can be concluded from the limit case above, the Laplace transform converges only for $\Re \{ s + s_0 \} > 0$. Hence, the ROC is given as

\begin{equation}
\Re \{ s \} > \Re \{ - s_0 \} 
\end{equation}

Combining above findings, the transformation of the causal complex exponential signal reads

\begin{equation}
\mathcal{L} \{ \epsilon(t) \cdot e^{-s_0 t} \} = \frac{1}{s + s_0} \qquad \text{for } \Re \{ s \} > \Re \{ - s_0 \}
\end{equation}

## Laplace theorems

The theorems of the Laplace transformation relate basic time-domain operations to their equivalents in the Laplace domain. They are of use for the computation of Laplace transforms of signals composed from modified standard signals and for the computation of the response of systems to an input signal. The theorems allow further to predict the consequences of modifying a signal or system by certain operations.

(my-label)=
##Convolution-Theorem

### Convolution Theorem

The convolution theorem states that the Laplace transform of the convolution of two signals $x(t)$ and $y(t)$ is equal to the scalar multiplication of their Laplace transforms $X(s)$ and $Y(s)$

\begin{equation}
\mathcal{L} \{ x(t) * y(t) \} = X(s) \cdot Y(s)
\end{equation}

under the assumption that both Laplace transforms $X(s) = \mathcal{L} \{ x(t) \}$ and $Y(s) = \mathcal{L} \{ y(t) \}$ exist, respectively. The ROC of the convolution $x(t) * y(t)$ includes at least the intersection of the ROCs of $x(t)$ and $y(t)$

\begin{equation}
\text{ROC} \{ x(t) * y(t) \} \supseteq \text{ROC} \{ x(t) \} \cap \text{ROC} \{ y(t) \}
\end{equation}


The theorem can be proven by introducing the definition of the convolution into the definition of the Laplace transform and changing the order of integration

\begin{align}
\mathcal{L} \{ x(t) * y(t) \} &= \int_{-\infty}^{\infty} \left( \int_{-\infty}^{\infty} x(\tau) \cdot y(t-\tau) \; d \tau \right) e^{-s t} \; dt \\
&= \int_{-\infty}^{\infty} \left( \int_{-\infty}^{\infty} y(t-\tau) \, e^{-s t} \; dt \right) x(\tau) \; d\tau \\
&= Y(s) \cdot \int_{-\infty}^{\infty} x(\tau) \, e^{-s \tau} \; d \tau \\
&= Y(s) \cdot X(s)
\end{align}

The convolution theorem is very useful in the context of linear time-invariant (LTI) systems. The output signal $y(t)$ of an LTI system is given as the convolution of the input signal $x(t)$ with the impulse response $h(t)$. The signals can be represented either in the time or Laplace domain. This leads to the following equivalent representations of an LTI system in the time and Laplace domain, respectively

:::{figure-md} Laplace
<img src="figures_src/LTI_system_Laplace_domain.png" alt="fishy" height="200px">

Representation of an LTI system in the time  and Laplace domain.
:::

Calculation of the system response by transforming the problem into the Laplace domain can be beneficial since this replaces the evaluation of the convolution integral by a scalar multiplication. In many cases this procedure simplifies the calculation of the system response significantly. The convolution theorem can also be useful to derive an unknown Laplace transform. The key is here to express the signal as convolution of two other signals for which the Laplace transforms are known. This is illustrated by the following example.

**Example - Transformation of two convolved signals**

The Laplace transform of the convolution of a causal cosine signal $\epsilon(t) \cdot \cos(\omega_0 t)$ with a causal sine signal $\epsilon(t) \cdot \sin(\omega_0 t)$ is derived by the convolution theorem

\begin{equation}
\mathcal{L} \{ \epsilon(t) \cdot ( \cos(\omega_0 t) * \sin(\omega_0 t) \} 
= \frac{s}{s^2 + \omega_0^2} \cdot \frac{\omega_0}{s^2 + \omega_0^2}
= \frac{\omega_0 s}{(s^2 + \omega_0^2)^2}
\end{equation}

where the Laplace transforms of the causal cosine and sine signals were used. The ROC of the causal cosine and sine signal is $\Re \{ s \} > 0$. The ROC for their convolution is also $\Re \{ s \} > 0$, since no poles and zeros cancel out. Above Laplace transform has one zero $s_{0} = 0$, and two poles of second degree $s_{\infty 0} = s_{\infty 1} = j \omega_0$ and $s_{\infty 2} = s_{\infty 3} = - j \omega_0$.


### Differentiation Theorem

Derivatives of signals are the fundamental operations of differential equations. Ordinary differential equations (ODEs) with constant coefficients play an important role in the theory of linear time-invariant (LTI) systems. Consequently, the representation of the derivative of a signal in the Laplace domain is of special interest.

#### Two-sided transform

A differentiable signal $x(t)$ whose temporal derivative $\frac{d x(t)}{dt}$ exists is given. Using the derivation property of the Dirac impulse, the derivative of the signal can be expressed by the convolution

\begin{equation}
\frac{d x(t)}{dt} = \frac{d \delta(t)}{dt} * x(t)
\end{equation}

Applying a two-sided Laplace transformation to the left- and right-hand side together with the [convolution theorem](#Convolution-Theorem) yields the Laplace transform of the derivative of $x(t)$

\begin{equation}
\mathcal{L} \left\{ \frac{d x(t)}{dt} \right\} = s \cdot X(s)
\end{equation}

where $X(s) = \mathcal{L} \{ x(t) \}$. The two-sided Laplace transform $\mathcal{L} \{ \frac{d \delta(t)}{dt} \} = s$ can be derived by applying the definition of the Laplace transform together with the derivation property of the Dirac impulse. The ROC is given as a superset of the ROC for $x(t)$

\begin{equation}
\text{ROC} \left\{ \frac{d x(t)}{dt} \right\} \supseteq \text{ROC} \{ x(t) \}
\end{equation}

due to the zero at $s=0$ which may cancel out a pole.

Above result is known as differentiation theorem of the two-sided Laplace transform. It states that the differentiation of a signal in the time domain is equivalent to a multiplication of its spectrum by $s$.

#### One-sided transform

Many practical signals and systems are causal, hence $x(t) = 0$ for $t < 0$. A causal signal is potentially discontinuous for $t=0$. The direct application of above result for the two-sided Laplace transform is not possible since it assumes that the signal is differentiable for every time instant $t$. The potential discontinuity at $t=0$ has to be considered explicitly for the derivation of the differentiation theorem for the one-sided Laplace transform.

\begin{equation}
\mathcal{L} \left\{ \frac{d x(t)}{dt} \right\} = s \cdot X(s) - x(0+)
\end{equation}

where $x(0+) := \lim_{\epsilon \to 0} x(0+\epsilon)$ denotes the right sided limit value of $x(t)$ for $t=0$. The ROC is given as a superset of the ROC of $x(t)$

\begin{equation}
\text{ROC} \left\{ \frac{d x(t)}{dt} \right\} \supseteq \text{ROC} \{ x(t) \}
\end{equation}

due to the zero at $s=0$ which may cancel out a pole. The one-sided Laplace transform of a causal signal is equal to its two-sided transform. Above result holds therefore also for the two-sided transform of a causal signal.

The main application of the differentiation theorem is the transformation and solution of differential equations under consideration of initial values. Another application area is the derivation of transforms of signals which can be expressed as derivatives of other signals.


## Summary of Properties, Theorems and Transforms

The properties, theorems) and transforms of the two-sided Laplace transform as derived in the previous sections are summarized in the following. The corresponding tables serve as a reference for the application of the Laplace transform in the theory of signals and systems. Please refer to the respective sections for details.

### Definition

The two-sided Laplace transform and its inverse are defined as

\begin{align}
X(s) &= \int_{-\infty}^{\infty} x(t) \, e^{- s t} \; dt \\
x(t) &= \frac{1}{2 \pi j} \int_{\sigma - j \infty}^{\sigma + j \infty} X(s) \, e^{s t} \; ds
\end{align}

where $s \in \text{ROC} \{ x(t) \}$.

### Properties and Theorems

The properties and theorems of the two-sided Laplace transform are given as

| &#65279;  | $x(t)$ | $X(s) = \mathcal{L} \{ x(t) \}$ | $\text{ROC}$ |
|:---|:---:|:---:|:---|
| Linearity| $A \, x_1(t) + B \, x_2(t)$ | $A \, X_1(s) + B \, X_2(s)$ | $\supseteq \text{ROC}\{x_1(t)\} \cap \text{ROC}\{x_2(t)\}$ |
| Real-valued signal | $x(t) = x^*(t)$ | $X(s) = X^*(s^*)$ | | 
| Scaling | $x(a t)$ | $\frac{1}{\lvert a \rvert} X\left( \frac{s}{a} \right)$ | $s: \frac{s}{a} \in \text{ROC}\{x(t)\}$ |
| Convolution | $x(t) * h(t)$ | $X(s) \cdot H(s)$ | $\supseteq \text{ROC}\{x(t)\} \cap \text{ROC}\{h(t)\}$ |
| Shift | $x(t - \tau)$ | $e^{-s \tau} \cdot X(s)$ | $\text{ROC}\{x(t)\}$ |
| Differentiation | $\frac{d}{dt} x(t)$ | $s \cdot X(s) - x(0+)$ | $\supseteq \text{ROC}\{x(t)\}$ |
| Integration | $\int_{-\infty}^{t} x(t) \; dt$ | $\frac{1}{s} \cdot X(s)$ | $\supseteq \text{ROC}\{x(t)\} \cap \{s: \Re \{s\} > 0 \}$ |
| Modulation | $e^{s_0 t}\cdot x(t)$ | $X(s - s_0)$ | $s: s - \Re \{s_0\} \in \text{ROC}\{x(t)\}$ |

where $A, B, s_0 \in \mathbb{C}$, $a \in \mathbb{R} \setminus \{0\}$ and $\tau \in \mathbb{R}$.

### Selected Transforms

Two-sided Laplace transforms which are frequently used are given as

| $x(t)$ | $X(s) = \mathcal{L} \{ x(t) \}$ | $\text{ROC}$ |
|:---:|:---:|:---|
| $\delta(t)$ | $1$ | $\mathbb{C}$ |
| $\epsilon(t)$ | $\frac{1}{s}$ | $\Re \{s\} > 0$ |
| $t \epsilon(t)$ | $\frac{1}{s^2}$ | $\Re \{s\} > 0$ |
| $e^{- s_0 t} \epsilon(t)$ | $\frac{1}{s + s_0}$ | $\Re \{s\} > \text{Re}\{-s_0\}$ |
| $\sin(\omega_0 t) \epsilon(t)$ | $\frac{\omega_0}{s^2 + \omega_0^2}$ | $\Re \{s\} > 0$ |
| $\cos(\omega_0 t) \epsilon(t)$ | $\frac{s}{s^2 + \omega_0^2}$ | $\Re \{s\} > 0$ |
| $t^n e^{-s_0 t} \epsilon(t)$ | $\frac{n!}{(s+s_0)^{n+1}}$ | $\Re \{s\} > \text{Re}\{-s_0\}$ |
| $e^{-s_0 t} \cos(\omega_0 t) \epsilon(t)$ | $\frac{s + s_0}{(s+s_0)^2 + \omega_0^2}$ | $\Re \{s\} > \Re \{-s_0\}$ |
| $e^{-s_0 t} \sin(\omega_0 t) \epsilon(t)$ | $\frac{\omega_0}{(s+s_0)^2 + \omega_0^2}$ | $\Re \{s\} > \Re \{-s_0\}$ |
| $t \cos(\omega_0 t) \epsilon(t)$ | $\frac{s^2 - \omega_0^2}{(s^2 + \omega_0^2)^2}$ | $\Re \{s\} > 0$ |
| $t \sin(\omega_0 t) \epsilon(t)$ | $\frac{2 \omega_0 s}{(s^2 + \omega_0^2)^2}$ | $\Re \{s\} > 0$ |

where $s_0 \in \mathbb{C}$, $\omega_0 \in \mathbb{R}$ and $n \in \mathbb{N}$. More one- and two-sided transforms may be found in the literature or [online](https://en.wikipedia.org/wiki/List_of_Laplace_transforms).


## Transfer Function 

The transfer function of a linear, time-invariant differential-equation system is defined as the ratio of the Laplace transform of the output (response function) to the Laplace transform of the input (driving function) **under the assumption that all initial conditions are zero**.

Consider a general **linear time-invariant system** defined by following differential equation:

\begin{equation}
 a_0 \frac{d^ny}{dt^n} + a_1 \frac{d^{n-1}y}{dt^{n-1}}+ \ldots + a_{n-1} \frac{dy}{dt} + a_n y = b_0 \frac{d^mu}{dt^m}+  \ldots + b_{m-1} \frac{du}{dt} + b_m u \ \ \ \ (m \leq n)
\end{equation}

where $y$ is the system output, $u$ is the input signal. 

The **transfer function** of this system is the ratio of the Laplace-transformed output to the Laplace-transformed input when all initial conditions are zero, or

\begin{eqnarray}
 H(s) &=& \frac{Y(s)}{U(s)} = \left| \frac{\mathcal{L}\{ b_0 \frac{d^mu}{dt^m}+  \ldots + b_{m-1} \frac{du}{dt} + b_m u  \}} {\mathcal{L}\{  a_0 \frac{d^ny}{dt^n} + a_1 \frac{d^{n-1}y}{dt^{n-1}}+ \ldots + a_{n-1} \frac{dy}{dt} + a_n y \} } \right|_{zero \ initial \ conditions}  \\
  &=& \frac{Y(s)}{U(s)} = \frac{b_0 s^m + b_1 s^{m-1}+ \ldots + b_{m-1}s + b_m}{ a_0 s^n + a_1 s^{n-1}+ \ldots + a_{n-1}s + a_n} \label{eq:TF0}
\end{eqnarray}

By using the concept of a transfer function, it is possible to represent system dynamics by algebraic equations in $s$. If the highest power of s in the denominator the transfer function (**after poles -zero cancellations!**) is equal to n, the system is called an **n th-order system**.

### Important remarks regarding transfer functions 

The applicability of the concept of the transfer function is **limited to linear, time-invariant (LTI) differential equation systems*. Still, the transfer function approach is used extensively in the analysis and design of such systems. The following list gives some important comments concerning the transfer function of a system described by a linear, time-invariant differential equation:
- The transfer function of a system is a mathematical model of that system, in that it is an operational method of expressing the **differential equation** that relates the output variable to the input variable.
- The transfer function is a **property of a system** itself, unrelated to the magnitude and nature of the input or driving function.
- The transfer function includes the units necessary to relate the input to the output; however, it does **not provide any information concerning the physical structure of the system**. (The transfer functions of many physically different systems can be identical.)
- If the transfer function of a system is known, the output or **response can be studied** for various forms of inputs with a view toward understanding the nature of the system.
- If the transfer function of a system is unknown, it may be **established experimentally** by introducing known inputs and studying the output of the system. Once established, a transfer function gives a full description of the dynamic characteristics of the system, as distinct from its physical description.

### Example for a LTI system 

Consider the mechanical system shown in Figure {numref}`ex_Laplace1`. The displacement x(t) of the mass m is measured from the equilibrium position. In this system, the external force f(t) is the input and x(t) is the output.

:::{figure-md} ex_Laplace1
<img src="figures_src/Laplace1.png" alt="fishy" height="200px">

Mechanical mass-spring-damper system.
:::

The equation of motion for the system is

```{math}
:label: eq:MSD1
 m \ddot x(t) + b \dot x(t) + kx(t) = f(t) 
```

Taking the Laplace transform of both sides of this equation and assuming that all initial conditions are zero yields

\begin{equation}
(ms^2 + bs + k)X(s) = F(s) 
\end{equation}

where $X(s) = \mathcal{L} [x(t)]$ and $F(s) = \mathcal{L}[f(t)]$. 

Based on equation {eq}`eq:MSD1`, the transfer function for the system becomes

\begin{equation}
\frac{X(s)}{F(s)} = \frac{1}{ms^2 + bs + k} \nonumber 
\end{equation}


## What to do with non-linear time-invariant systems?

  A large majority of physical systems are only linear within a certain range of his variables. Almost all physical systems become non-linear as the variables are increased without limitations. For example, the mass-spring-damper system of Figure  {numref}`ex_Laplace1` is linear as described by equation {eq}`eq:MSD1` as long as the mass is subjected to small deviations $x(t)$. If however $x(t)$ would increase continuously, eventually the spring would overextend and finally break. Therefore the question of \textbf{linearity and the range of applicability} must be considered for each system. 

 In general a necessary condition for a linear system can be determined in term of an excitation $x(t)$ and a response $y(t)$. When a system at rest is subjected to an excitation $x_1(t)$, it exhibits a response $y_1(t)$ and if it is subjected to an excitation $x_2(t)$, it provides a corresponding response $y_2(t)$. For a linear system, it is fundamental that the excitation $x_1(t)+x_2(t)$ corresponds with a response $y_1(t)+y_2(t)$. This important characteristic is called **superposition**.

Furthermore, it is necessary that a magnitude scale factor is preserved by a linear system. Meaning that an input of $\beta$ times $x_1(t)$ results in an response of $\beta$ times the $y_1(t)$. This is called the property of **homogeneity**.

The linearity of many mechanical and electrical systems can be assumed over a reasonable large range of the variables. One can linearize non-linear elements assuming small signal conditions. Consider a response $y(t)$ generated by excitation variables $x_1(t), \ldots, x_n(t)$ related by 

\begin{equation}
 y(t) = g(x_1(t), \ldots,x_n(t)), 
\end{equation}

where $g(x_1(t), \ldots,x_n(t))$ indicates $y(t)$ is a function of the variables $x_1(t),\ldots, x_n(t)$. 

To perform a linearization we first need to determine a normal operation point based on the required behaviour. For a controlled system this implies the desired control value and for a simulation this implies the assumed working point of the system. If we assume a operation point as $x_{1_0}, \ldots,x_{n_0}$ a \textbf{Taylor series} expansion around this operation point may be specified

\begin{eqnarray}
 y(t) &=&  g(x_1(t), \ldots,x_n(t)) \nonumber \\
 &\approx & g(x_{1_0},\ldots,x_{n_0}) + \left. \frac{\partial g}{\partial x_1} \right|_{x=x_{1_0}, \ldots,x_{n_0}} (x_1(t)-x_{1_0}) + \ldots  \nonumber \\
&+&  \left. \frac{\partial g}{\partial x_n} \right|_{x=x_{n_0}, \ldots,x_{n_0}} (x_n(t)-x_{n_0}). \label{eq:taylor}
\end{eqnarray}

The best way to illustrate this is using an example. 

### Pendulum model example

:::{figure-md} pendulum
<img src="figures_src/pendulum.png" alt="fishy" height="200px">

A pendulum with a load mass of M and a length of L. The mass of the wire is neglected together with all the friction.
:::

Consider the pendulum shown in figure {numref}`pendulum`. 

Applying the second law of Newton results in
 

```{math}
:label: eq:pendulum
J \ddot \theta(t)  =- MgL\sin \theta(t) + T(t), 
```

where $g$ is the gravity constant. 

### How to determine your working point? 

The choice of the working point is applications specific. Assume we want to control the pendulum to stay at an angle of $\theta_0$ then we select working condition for the mass at $\theta =\theta_0$.  At this working point we want to be able to remain for a certain period therefore there should  no acceleration  at this point. This translates into the mathematical statement that  $J \ddot \theta_0= -MgL\sin (\theta_0) +T_0 =0$ for the working point. This results in a working point for the input torque equal to  $T_0=MgL\sin (\theta_0)$. 

### First order Taylor approximation

If we take $y(t)= J \ddot \theta(t)$ and $g(\theta(t), T(t)) = -MgL\sin (\theta(t)) +T(t)$  based on equation {eq}`eq:pendulum` and then apply a Taylor approximation around the chosen working point $(\theta_0, T_0)$: 

\begin{eqnarray}
J \ddot \theta &\approx& g(\theta_0,T_0) +  \left. \frac{\partial g(\theta,T)}{\partial \theta} \right|_{\theta=\theta_0,T=T_0} (\theta(t)- \theta_0) + \left. \frac{\partial g(\theta,T)}{\partial T} \right|_{\theta=\theta_0,T=T_0} (T(t)- T_0) \\
J \ddot \theta &\approx&  -MgL \sin(\theta_0)  + T_0 - MgL \left.  \frac{\partial \sin \theta}{\partial \theta } \right|_{\theta=\theta_0} (\theta(t)  -   \theta_0) + 1 (T(t) - T_0), \nonumber \\
&\approx &-MgL \sin(\theta_0)  + T_0 - MgL \cos \theta_0  (\theta(t)  - \theta_0) + 1 (T(t) - T_0), \label{eq:pend2}
\end{eqnarray}

because $T_0=MgL\sin (\theta_0)$ this simplifies to 

```{math}
:label: eq:pend6
  J \ddot \theta \approx -MgL \cos \theta_0  (\theta(t)  - \theta_0) + 1(T(t) - T_0)
```

### Working point offset

When we now introduce new variables $\theta'(t)=\theta-\theta_0$ and $T'(t)= T(t)-T_0$ we can convert equation {eq}`eq:pend6` to:

```{math}
:label: eq:148
  J \ddot \theta \approx -MgL \cos \theta_0  \theta'(t) + T'(t) 
```

Because $\theta'(t)=\theta-\theta_0$ the left term of equation {eq}`eq:148` and $\ddot \theta(t)$) equals the second derivative of $\theta(t)'$ making  

```{math}
:label: eq:149
  J \ddot \theta' \approx -MgL \cos \theta_0  \theta'(t) + T'(t) 
```

If the working point is chosen at $\theta_0=20^0$ and $T_0=MgL \sin(\theta_0)$ equation {eq}`eq:149` becomes

```{math}
:label: eq:pend3
 J \ddot \theta' \approx -MgL \sin(20^0) +T_0-  MgL cos(20^0) (\theta(t) - 20^0) + 1(T(t)-T_0)  
```
```{math}
:label: eq:pend4
\approx -MgL \cos(20^0) (\theta(t) - 20^0) + 1(T(t)-T_0)  
```

### Linearized transfer function

The transfer function between input torque $(T(t)$ and angular position $\theta(t)$ cannot be determined because of the offset. To be able to specify a transfer function we need to change the variables $T(t)$ and $\theta(t)$ to new variables $T'(t)$ and $\theta'(t)$ that are equal to zero at the working point:
\begin{eqnarray}
 T'(t) &=& T(t) - T_0 = T(t)-  MgL \sin(20^0)  \nonumber \\
\theta'(t) &=& \theta(t) - \theta_0= \theta(t)- 20^0 \nonumber 
\end{eqnarray}
Equation {eq}`eq:pend4` can be rewritten in these two new variables $T'(t)$ and $\theta'(t)$ leading to the transfer function
\begin{equation}
 \frac{\Theta'(s)}{T'(s)} = \frac{1}{J s^2+Mg L \cos(20^0)}. 
\end{equation}
You can now perform your analysis using this transfer function but you need to keep in mind that both parameters have an offset in the original parameter space. 
