# Ordinary differential equations with signed first derivative

Consider the following coupled set of ordinary diferential equations:

\begin{align} (K_{pa}+K_r)y_1(t)-K_ry_2(t)+C_0\operatorname{sign}(\dot{y}_1(t))\lvert\dot{y}_1(t)\rvert^\alpha &= K_{pa}y_0(t)\\ -K_ry_0(t)+2K_ry_1(t)-K_ry_2(t)+C_0\operatorname{sign}(\dot{y}_1(t))\lvert\dot{y}_1(t)\rvert^\alpha &= 0\\ -K_ry_1(t)+2K_ry_2(t)+C_0\operatorname{sign}(\dot{y}_2(t))\lvert\dot{y}_2(t)\rvert^\alpha &= 0 \end{align}

With the state vector: $$\mathbf{y}(t)=\left[ y_1(t) \quad y_2(t) \right]^T$$

And input displacement: $$y_0(t)$$

The initial conditions are equal to 0.

I would like to solve this is Matlab using 'ode45', hence I require to rewrite the ODE's such that the first derivatives appear on the LHS (outside the equal sign). But I can't find a way to do this because of the $\operatorname{sign}(y_k(t))$ involved.

How can I solve this using ODE45 in Matlab?

EDIT

Thanks for that. So lets assume I have only the following 2 differential equations (to make things easier): $$(K_{pa}+K_r)y_1(t)-K_ry_2(t)+C_0sign(\dot{y}_1(t))\lvert\dot{y}_1(t)\rvert^\alpha = K_{pa}y_0(t)$$ and $$-K_ry_1(t)+2K_ry_2(t)+C_0sign(\dot{y}_2(t))\lvert\dot{y}_2(t)\rvert^\alpha = 0$$

Will the following be correct than? $$\dot{y}_1=sign\left(\frac{-(K_r+K_{pa})y_1+K_ry_2+K_{pa}y_0}{C_0}\right)\lvert\frac{-(K_r+K_{pa})y_1+K_ry_2+K_{pa}y_0}{C_0}\rvert^{1/\alpha}$$ $$\dot{y}_2=sign\left(\frac{K_ry_1-2K_ry_2}{C_0}\right)\lvert\frac{K_ry_1-2K_ry_2}{C_0}\rvert^{1/\alpha}$$

You have expressions of the form $sign(u)\,|u|^α=v$. From that one sees that $sign(u)=sign(v)$ and $|u|^α=|v|$ so that finally $$u=sign(v)\,|v|^{1/α}$$ which allows to write your system as an explicit ODE.
• Yes, that looks correct. However, now you have to prescribe $y_0$. Another way is to take the derivative of the algebraic equation to obtain the derivative of $y_0$. The solution may deviate from the exact satisfaction of the algebraic equation, but it may still be more useful then just ignoring one equation. – LutzL Feb 26 '14 at 14:42
I assume $\alpha>0$. The function $$p_\alpha(x)=\operatorname{sign}(x)|x|^\alpha\text{ is equal to }\begin{cases} x^\alpha &\text{if x\ge0}\\-|x|^\alpha &\text{if x<0.}\end{cases}$$ It is strictly increasing. If $\alpha$ is an odd integer then $p_\alpha(x)=x^\alpha$. Its inverse is $$p_\alpha^{-1}=p_{1/\alpha}.$$ In your equations, from $p_\alpha(\dot y_k)=\text{something}$ you get $\dot y_k=p_{1/\alpha}(\text{something})$.