1
$\begingroup$

I want to solve the first-order differential equation $$ \begin{align} \frac{d\alpha}{d\phi} = \frac{\phi \sigma^2 \sin(2d\alpha)+2d\sinh(\sigma^2\alpha \phi)}{-\alpha \sigma^2 \sin(2d\alpha) +2d\cos(2d\alpha)+2d\cosh(\sigma^2\alpha \phi)} \;, \end{align}$$ where $d$ and $\sigma$ are fixed. I can't obtain a solution for this differential equation, and I guess the source of my problem lies in the sinh and cosh functions. Indeed, I can solve for example $d\alpha/d\phi=\phi \sigma^2 \sin(2d\alpha)$ with no trouble at all, but $d\alpha/d\phi=2d\sinh(\sigma^2\alpha \phi)$ returns Warning: Instability detected. Aborting. Why can I numerically solve a differential equation with sine but not with sinh? I put below a MWE reproducing the error.

using DifferentialEquations
using Plots
            
const global s2=81. # σ^2
const global d=-0.00090         

function ode(du,u,p,t)
    α = u[1]
    du[1] = 2*d*sinh(s2*α*t)
end
α0 =[1.0] # This initial value is just a guess
prob = ODEProblem(ode,α0,(-5.0,5.0))
sol = solve(prob)
plot(sol,label="2*d*sinh(s2*α*ϕ)")

$\endgroup$
1
  • 2
    $\begingroup$ It may help to see the slope field of possible solutions. It seems this problem is inherently unstable in the sense that a small change in initial conditions can drastically alter solution. $\endgroup$
    – Tyberius
    May 18, 2021 at 22:06

1 Answer 1

6
$\begingroup$

I inserted a print statement into the RHS function:

function ode(du,u,p,t)
    α = u[1]
    @show d,s2,α,t,2*d*sinh(s2*α*t)
    du[1] = 2*d*sinh(s2*α*t)
end

Here's what it showed for the very first derivative calculation:

(d, s2, α, t, 2 * d * sinh(s2 * α * t)) = (-0.0009, 81.0, 1.0, -5.0, 6.974413306346224e172)

Let me repeat: your derivative is $6.97 \times 10^{172}$ at your starting $t=-5$. this is because $s2 * \alpha * t = -405.0$ and $\sinh(-405) \approx 6.97 \times 10^{172}$. When your derivative is that gigantic, your equation is diverging almost infinitely fast which explains the behavior.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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