Trying to find the asymptote to a function
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.
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]
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]
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]
which is, of course, indistinguishable in a plot from xx
.