0
$\begingroup$

You know, NDsolve coupled with Piecewise can be used to solve a series of discontinuous differential equations. But what if one of the function is different? For example:

$$z''(t)=\begin{cases}x(t)-(1+y(t)), & \text{if } x>(1+y) \\ \\ \\ x(t)+(1+y(t)), & \text{if } x<-(1+y) \end{cases} $$ $$\rm{and}$$ $$z'(t)=0, \rm{if } |x|<(1+y) $$ I tried something like below

xyz = First@NDSolve[{x''[t] == -2.25 Cos[1.5 t] - x[t] - x'[t], 
x[0] == 0, x'[0] == 0, 
y''[t] == -1.125 Cos[1.5 t] - 4 y[t] - y'[t], 
y[0] == 0, y'[0] == 0, 
z''[t] == Piecewise[{
    {x[t] - (1 + y[t]), x[t] > 1 + y[t]}, 
    {0, Abs[x[t]] <= 1 + y[t]}, 
    {x[t] + (1 + y[t]), x[t] < -1 - y[t]}}], 
z[0] == 0}, 
{x, y, z}, {t, 0, 30}];

but have no idea how to correctly incorporate $z'(t)$ condition.

$\endgroup$
  • $\begingroup$ Please write down the code you've tried $\endgroup$ – Dr. belisarius Jan 23 '14 at 14:58
  • $\begingroup$ @belisarius What f are you talking about? $\endgroup$ – Sjoerd C. de Vries Jan 23 '14 at 16:55
  • $\begingroup$ @SjoerdC.deVries I need a new pair of lenses $\endgroup$ – Dr. belisarius Jan 23 '14 at 17:03
1
$\begingroup$

Without making any claims about whether the problem is well posed, it appears possible to make Mathematica compute a solution. Maybe I've taken too many liberties with the problem, but consider the following. $$ z'(t) = \begin{cases} 0, & \text{if}~|x|<(1+y) \\ q(t), & \text{if}~|x|>(1+y) \end{cases} $$ $$ q'(t)=\begin{cases} x(t)-(1+y(t)), & \text{if}~x>(1+y) \\ x(t)+(1+y(t)), & \text{if}~x<-(1+y) \\ 0, & \text{if}~|x|<(1+y) \end{cases} $$

The code below gives a result for $z(t)$ that looks like a staircase. Is that what you expect?

T = 30;
xySol = First@NDSolve[{
  x''[t] == -2.25 Cos[1.5 t] - x[t] - x'[t], x[0] == 0, x'[0] == 0,
  y''[t] == -1.125 Cos[1.5 t] - 4 y[t] - y'[t], y[0] == 0, y'[0] == 0}, {x, y}, {t, 0, T}];

zSol = First@NDSolve[{
  q'[t] == Piecewise[{
    {x[t] - (1 + y[t]), x[t] > (1 + y[t])},
    {x[t] + (1 + y[t]), x[t] < -(1 + y[t])}} /. xySol, 0],
  z'[t] == Piecewise[{
    {0, Abs[x[t]] < (1 + y[t])}} /. xySol,
    q[t]],
  q[0] == 0,z[0] == 0}, {q, z}, {t, 0, T}]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.