User:EGM6321.f11.team1.pan/HW3

= R3.4 Construct a class of N1-ODEs =

== Given == Consider a class of N1-ODEs of the form:


 * {| style="width:100%" border="0" align="left"

$$
 * $$\underbrace{\bar b(x,y)c(y)}_{\displaystyle{N(x,y)}}\,y'+\underbrace{a(x)\bar c(x,y)}_{\displaystyle{M(x,y)}}=0$$
 * $$\displaystyle (Equation\;3.4.1)
 * $$\displaystyle (Equation\;3.4.1)
 * }
 * }

in which,


 * $$\bar b(x,y):=\int^x b(s)ds+k_1(y)$$


 * $$\bar c(x,y):=\int^y c(s)ds+k_2(x)$$

where $$a(x), b(x), c(y) \,$$ are arbitrary functions.

Equation 3.4.1satisfies the condition
 * $$\displaystyle \frac{h_x}{h}=-\frac{1}{N}\left(N_x-M_y\right)=:n(x)$$

that an integrating factor $$h(x)$$ can be found to render it exact, only if $$\displaystyle k_1(y)=constant$$.

== Find == Construct a class of N1-ODEs, which is the counterpart of Equation 3.x.x, and satisfies the condition
 * {| style="width:100%" border="0" align="left"

$$
 * $$\displaystyle \frac{h_y}{h}=\frac{1}{M}\left(N_x-M_y\right)=:m(y)$$
 * $$\displaystyle (Equation\;3.4.2)
 * $$\displaystyle (Equation\;3.4.2)
 * }
 * }

that an integrating factor $$h(y)\,$$ can be found to render it exact.

Solution
The condition Equation (3.4.2) means that the intergrating factor only with respect y. According to this, suppose the N1-ODE we want has the form of:

with

$$\displaystyle \bar a(x,y)=\int^y a(s)ds+k_1(x)$$

$$\displaystyle \bar c(x,y)=\int^x c(s)ds+k_2(y)$$ The partial differential are:

$$\displaystyle M_y=a(y)\cdot c(x)$$

$$\displaystyle N_x=b(y)\cdot c(x)$$

$$\displaystyle \frac{h_y}{h}=\frac{1}{M}\left(N_x-M_y\right)=b(y)-a(a):=m(y)$$, which satisfies the condition Equation (3.4.2).

= R3.10 Free vibration of coupled pendulums =

== Given ==

The equations of motion of free vibration coupled pendulums are
 * {| style="width:100%" border="0" align="left"

$$
 * $$m_1l^2\ddot{\theta_1}=-ka^2(\theta_1-\theta_2)-m_1gl\theta_1+u_1l$$
 * $$\displaystyle (Equation\;3.10.1)
 * $$\displaystyle (Equation\;3.10.1)
 * }
 * }
 * $$m_2l^2\ddot{\theta_2}=-ka^2(\theta_2-\theta_1)-m_2gl\theta_2+u_2l$$

A specific case of this coupled pendulums model:
 * Pendulums: $$a=0.3,\,l=1,\,k=0.2$$
 * $$m_1g=3,\,m_2g=6$$
 * No applied forces: $$\displaystyle u_1=u_2=0$$
 * Initial conditions:
 * $$\theta_1(0)=0,\dot\theta_1(0)=-2$$
 * $$\theta_2(0)=0,\dot\theta_2(0)=+1$$

1)
Use matlab's ode45 command to integrate the coupled pendulums system in matrix form for $$t\in [0,7]$$

2)
Find the solution of this coupled pendulums system by using
 * $$\mathbf{x}(t)=[exp{\mathbf{A}(t-t_0)}]\mathbf{x}(t_0)+\int_{t_0}^t[exp{\mathbf{A}(t-\tau)}]\mathbf{B}\mathbf{u}(\tau)d\tau$$

3)
Plot $$\displaystyle \theta_1(t)$$ and $$\displaystyle \theta_2(t)$$.

1)
Use matlab code ode45 to solve the coupled pendulums system, and plot the solution $$\displaystyle \theta_1$$ and $$\displaystyle \theta_2$$. Matlab code: hw3_problem10.m

=== 2) === The equations of motion Equation (3.10.1) can be written in matrix form
 * $$\mathbf{\dot{X}}(t)=\mathbf{A}(t)\mathbf{x}(t)+\mathbf{B}(t)\mathbf{u}(t)$$

The solution is:
 * $$\displaystyle \mathbf{x}(t)=[exp{\mathbf{A}(t-t_0)}]\mathbf{x}(t_0)+\int^t_{t_0}[exp{\mathbf{A}(t-\tau)}]\mathbf{B}\mathbf{u(\tau)}d\tau$$

In this case,
 * $$\mathbf{x}:=\left\lfloor\theta_1\,\dot\theta_1\,\theta_2\,\dot\theta_2\right\rfloor^T$$
 * $$\mathbf{u}:=\begin{Bmatrix}

u_1l\\ u_2l \end{Bmatrix}$$ The equation of motion is:
 * $$\begin{bmatrix}

\dot{\theta_1}\\ \ddot{\theta_1}\\ \dot{\theta_2}\\ \ddot{\theta_2} \end{bmatrix}=\begin{bmatrix} 0 & 1 & 0 & 0\\ -\frac{ka^2}{m_1l^2}-\frac{g}{l} & 0 & \frac{ka^2}{m_1l^2} & 0\\ 0 & 0 & 0 & 1\\ \frac{ka^2}{m_2l^2} & 0 & -\frac{ka^2}{m_2l^2}-\frac{g}{l} & 0 \end{bmatrix}\begin{bmatrix} \theta_1\\ \dot\theta_1\\ \theta_2\\ \dot\theta_2 \end{bmatrix}+\begin{bmatrix} 0 & 0\\ \frac{1}{m_1l^2} & 0\\ 0 & 0\\ 0 & \frac{1}{m_2l^2} \end{bmatrix}\begin{bmatrix} u_1l\\ u_2l \end{bmatrix}$$ Therefore, the solution is:
 * $$\displaystyle \mathbf{x}(t)=[exp{\mathbf{A}t}]\mathbf{x}(t_0)$$

which is
 * $$\begin{bmatrix}

\theta_1\\ \dot\theta_1\\ \theta_2\\ \dot\theta_2 \end{bmatrix}=exp{\begin{bmatrix} 0 & t & 0 & 0\\ -9.8588t & 0 & 0.0588t & 0\\ 0 & 0 & 0 & t\\ 0.0298t & 0 & -9.8298t & 0 \end{bmatrix}}\begin{bmatrix} 0\\ -2\\ 0\\ 1 \end{bmatrix} $$ To calculate the matrix exponential, we use Matlab code expm. Matlab code: matrix_exp.m

3)
As shown, the red line is the solution of Q1 $$\displaystyle \theta_1$$ and the green line is $$\displaystyle \theta_2$$.

And, the solution of Q2, the red is $$\displaystyle \theta_1$$, and the blue line is $$\displaystyle \theta_2$$.

= R*3.15 Verify whether the equation satifies the 2nd exactness condition =

== Given == Consider the particular form of exact N2-ODE:
 * $$\displaystyle G(x,y,y',y)=g(x,y,p)+f(x,y,p)y=0$$

with
 * $$g(x,y,p)=:\phi_x+\phi_yy'$$


 * $$=\phi_x(x,y,p)+\phi_y(x,y,p)p$$


 * $$f(x,y,p):=\phi_p(x,y,p)$$

The 2nd exactness condition for N2-ODEs are
 * {| style="width:100%" border="0" align="left"

$$
 * $$\displaystyle f_{xx}+2pf_{xy}+p^2f_{yy}=g_{xp}+pg_{yp}-g_y$$
 * $$\displaystyle (Equation\;3.15.1)
 * $$\displaystyle (Equation\;3.15.1)
 * }
 * }
 * {| style="width:100%" border="0" align="left"

$$
 * $$\displaystyle f_{xp}+pf_{yp}+2f_y=g_{pp}$$
 * $$\displaystyle (Equation\;3.15.2)
 * $$\displaystyle (Equation\;3.15.2)
 * }
 * }

== Find == There is an equation that
 * {| style="width:100%" border="0" align="left"

$$
 * $$\displaystyle (15p^4cosx^2)y''+(6xy^2)y'+[-6xp^5sinx^2+2y^3]=0$$
 * $$\displaystyle (Equation\;3.15.3)
 * $$\displaystyle (Equation\;3.15.3)
 * }
 * }

Verify whether it satisfies the 2nd exactness condition.

== Solution ==

As for the Equation (3.15.3)

$$\displaystyle f(x,y,p)=15p^4cosx^2=\phi_p(x,y,p)$$

$$\displaystyle g(x,y,p)=\underbrace{(6xy^2)}_{\phi_y(x,y,p)}y'+\underbrace{[-6xp^5sinx^2+2y^3]}_{\phi_x(x,y,p)} $$

And then we got the partial derivative terms:


 * $$\displaystyle f_x=15p^4(-sinx^2)\cdot 2x=-30xp^4sinx^2$$


 * $$\displaystyle f_y=f_{yy}=0$$


 * $$\displaystyle f_{xx}=-30p^4sinx^2-60x^2p^4cosx^2$$


 * $$\displaystyle f_{xy}=0$$


 * $$\displaystyle f_{xp}=-120xp^3sinx^2$$


 * $$\displaystyle g_x=6y^2p-6p^5sinx^2-12x^2p^5cosx^2$$


 * $$\displaystyle g_{xp}=-30p^4sinx^2-60x^2p^4cosx^2+6y^2$$


 * $$\displaystyle g_y=12xyp+6y^2$$


 * $$\displaystyle g_{yp}=12xy$$


 * $$\displaystyle g_p=-30xp^4sinx^2+6xy^2$$


 * $$\displaystyle g_{pp}=-120xp^3sinx^2$$

To verity whether it satisfies the 2nd exactness condition, Substituting them into Equation (3.15.1):

Therefore,

which means it satisfies the condition Equation (3.15.1). Substituting those values into Equation (3.15.2):

Therefore,

which means it satisfies the condition Equation (3.15.2).