12
$\begingroup$

I am trying to find the asymptote to a solution of a differential equation.

I solved $x'(t) = \sin(x(t) + t)$ using NDSolve and plotted my solution.

sol = NDSolve[{x'[t] == Sin[x[t] + t], x[0] == 0}, x[t], {t, 0, 10}]

Plot[Evaluate[x[t] /. sol], {t, 0, 10}, PlotRange -> All]

Solution to diff eq

In order to find the asymptote I want to use something like the limit application method here;

https://reference.wolfram.com/language/ref/Limit.html

But I don't know how to do this since I do not have an actual expression for the function, but rather an interpolation function.

I tried substituting the variable sol into my limit calculations, but get an error

General::ivar: 0.0002042857142857143` is not a valid variable.

$\endgroup$
  • $\begingroup$ Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. $\endgroup$ – bbgodfrey Oct 19 '15 at 14:34
  • 2
    $\begingroup$ In this particular case, you've made a good choice as to which answer to accept. In general, however, it is a good idea to wait at least a day before accepting a solution (unless of course, it's really obvious) in order to get more (and possibly better!) answers. Questions with no accepted answers get more notice from potential answerers here, and it's in the best interest of the community to get as many good answers to a question as possible. In any case, welcome to Mathematica.SE! $\endgroup$ – march Oct 19 '15 at 17:18
  • $\begingroup$ Ok, thanks - I will take that on board $\endgroup$ – jm22b Oct 19 '15 at 17:40
  • 1
    $\begingroup$ Incidentally, if you're sufficiently convinced the solution has an asymptote (and it's linear), you can take the large-$t$ limit and plug in $x=at+b$ to get $a=\sin[(1+a)t + b]$. The only way to satisfy this with $a$ and $b$ constant (remember, you're assuming the asymptotic behavior is linear) is if $a = -1$, which gives you $b = 3\pi/2 + 2n\pi$, and you can identify $n=0$ from the initial condition. But this is not a Mathematica solution, and not something that readily generalizes to other equations, which is why I only give it as a comment. $\endgroup$ – David Z Oct 20 '15 at 13:58
12
$\begingroup$

With Version 10, DSolve can provide an explicit answer, and with some help it can even give the right answer. DSolve on its own only gives some of the answer, along with a string of warning messages. However, using Reduce instead of Solve in DSolve, as described here yields the complete answer, after which the resulting constants can be set to zero and the proper solution (of two) chosen to satisfy the initial condition. Plotting dsol yields the curve shown in the question.

opts = Options[Solve]; SetOptions[Solve, Method -> Reduce]; 
dsol = x[t] /. FullSimplify[DSolve[x'[t] == Sin[x[t] + t], x[t], t] 
    /. {C[1] -> 0, C[2] -> 0}][[2]]
SetOptions[Solve, opts]; 
(* -t + 4 ArcTan[(-2 + t + Sqrt[2] Sqrt[2 + (-2 + t) t])/t] *)

Then,

Series[dsol, {t, Infinity, 0}] // Normal//FullSimplify
(* 3 π/2 - t *)

Addendum

In response to a comment by belisarius is forth, x'[t] is given by

solp = D[dsol, t] // FullSimplify
(* -1 + 2/(2 + (-2 + t) t) *)

which is positive for t < 2 and negative thereafter.

enter image description here

$\endgroup$
  • $\begingroup$ DSolve provides the wrong solutions (and two, where there is one) due to it's usage of inverse functions, which is why I used NDSolve. $\endgroup$ – jm22b Oct 19 '15 at 15:42
  • $\begingroup$ @Jacobadtr I just noticed and fixed it. Now I shall expand my answer a bit for clarity $\endgroup$ – bbgodfrey Oct 19 '15 at 15:43
  • $\begingroup$ Awesome! This is exactly what I needed. I didn't know about Options, so I shall read about this. $\endgroup$ – jm22b Oct 19 '15 at 16:12
  • $\begingroup$ @Jacobadtr Learning new things is a great aspect of asking and answering questions on StackExchange. I had seen answer by Michael E2 before but had not paid serious attention. Now, I can say that I understand it. Thanks for accepting my answer. $\endgroup$ – bbgodfrey Oct 19 '15 at 16:22
  • 2
    $\begingroup$ It appears that although the answer is clear from this fine work, it was never added Limit[solp, t -> Infinity] is -1. :) $\endgroup$ – Jack LaVigne Oct 19 '15 at 16:27
7
$\begingroup$

Update

belisarius's sleep-deprived brain is better than my less-sleep-deprived brain. I've fixed the solution.

Original post

This isn't completely automated, but it doesn't require actually solving the differential equation (except that you do to find which solution is correct).

Let's find when the second derivative is zero for all t:

diffEqn = x'[t] == Sin[x[t] + t];
eqn = Simplify[D[diffEqn, t],  x''[t] == 0]
Reduce[eqn, {x[t], x'[t]}]
(* Cos[t+x[t]] (1 + x'[t]) == 0 *)
(* (C[1] ∈ Integers && (x[t] == -(π/2) - t + 2 π C[1] || x[t] == π/2 - t + 2 π C[1])) || x'[t] == -1 *)

This is an infinite number of solutions, of course. We could automate this by detecting which one is closest for large t, but instead, we just do it by inspection, resulting in 3 π/2 - t:

sol = NDSolve[{x'[t] == Sin[x[t] + t], x[0] == 0}, x[t], {t, 0, 10}];
Plot[{3 \[Pi]/2 - t, Evaluate[x[t] /. sol]}, {t, 0, 10}, PlotRange -> All]

enter image description here

$\endgroup$
  • $\begingroup$ Sorry, I'm sleep deprived. Why x'[t] > 0 ? $\endgroup$ – Dr. belisarius Oct 19 '15 at 15:55
  • $\begingroup$ Thank you, it's great to see some different ways of doing things. $\endgroup$ – jm22b Oct 19 '15 at 16:16
  • $\begingroup$ @belisariusisforth. It's a very special derivative that can somehow be negative but always be bigger than zero... The correct statement is actually that x'[t] < -1, which would be true asymptotically according to the graph. I'll fix the solution, thanks to your sleep-deprived brain. $\endgroup$ – march Oct 19 '15 at 16:58
  • $\begingroup$ @belisariusisforth. Wow okay, nevermind. Of course, x'[t] = -1 asymptotically, so I wonder if my solution is just lucky. I need to think more carefully about it. $\endgroup$ – march Oct 19 '15 at 17:05
  • 1
    $\begingroup$ @belisariusisforth. People are quick to upvote wrong answers, aren't they? $\endgroup$ – march Oct 19 '15 at 17:28
5
$\begingroup$

Your approach can be made to work. You can get an approximation good enough for plotting by applying NDSolve over to your equation over two domains, the one near zero and one far out.

Clear[x, xx]
x = NDSolve[{x'[t] == Sin[x[t] + t], x[0] == 0}, x, {t, 0, 10}][[1, 1, 2]];
xx = NDSolve[{xx'[t] == Sin[xx[t] + t], xx[0] == 0}, xx, {t, 100, 1000}][[1, 1, 2]]

Off[InterpolatingFunction::dmval]
Plot[{x[t], xx[t]}, {t, 0, 10}, PlotRange -> All]

plot1

Or should you would prefer to plot the asymptote as the line defined by the intercepts of xx with the axes, you can use

Off[Solve::ifun]
t0 = Solve[xx[t] == 0., t][[1, 1, 2]]
4.63712
asym[t_] = (xx[0] - xx[t0])/(0 - t0) t + xx[0]
4.63172 - 0.998836 t
Plot[{x[t], asym[t]}, {t, 0, 10}, AspectRatio -> Automatic]

plot2

which is, of course, indistinguishable in a plot from xx.

$\endgroup$
  • 1
    $\begingroup$ As a small variation on this you can generate one NDSolve solution for the whole range, then use FunctionInterpolation to pull out an InterpolatingFunction for large t. $\endgroup$ – george2079 Oct 19 '15 at 20:47
  • $\begingroup$ @george2079. Good idea. $\endgroup$ – m_goldberg Oct 19 '15 at 23:43

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.