84 votes
Accepted

What does "symplectic" mean in reference to numerical integrators, and does SciPy's odeint use them?

Let me start off with corrections. No, odeint doesn't have any symplectic integrators. No, symplectic integration doesn't mean conservation of energy. What does ...
Chris Rackauckas's user avatar
18 votes

What does "symplectic" mean in reference to numerical integrators, and does SciPy's odeint use them?

To complement Chris Rackauckas answer, to state some of the mathematical nonsense as well as some stuff you almost certainly know, a dynamical system is Hamiltonian if there is a description with ...
origimbo's user avatar
  • 2,249
17 votes
Accepted

CUDA & Python for numerical integration and solving differential equations

Julia's DifferentialEquations.jl is all GPU-compatible. If you make your arrays GPU-based arrays, then the solver recompiles to be all on the GPU (no data transfers). For example: ...
Chris Rackauckas's user avatar
13 votes
Accepted

How can I numerically integrate the Kepler problem?

I'm going to assume for the moment that your code is correctly implemented and that this problem isn't a bug. Believe it or not, gradual increase of the energy is the expected behavior of most simple ...
Daniel Shapero's user avatar
10 votes

Finite difference for 1D wave equation: why the spike initial data results in a noisy output?

I think you're probably seeing artifacts that are due to numerical dispersion. In brief, in the discrete case different (spatial) frequencies of a wave function will propagate at different phase/group ...
rchilton1980's user avatar
  • 4,862
10 votes

How to solve a second order differential equation (diffusion) with boundary conditions using Python

I have found that I must keep the value of dt near dx or the results become unstable This behavior you have noticed is known as the Courant–Friedrichs–Lewy (CFL) condition. Indeed, there are ...
Steven Roberts's user avatar
9 votes
Accepted

4th order Runge-Kutta for $y' = y$

The answer is quite simple. You are already comparing apples and oranges in the first equation. Garbage in, garbage out. The equation $y'=y$ if written properly is $$dy/dx=y.$$ Do you see it now? To ...
Kartik's user avatar
  • 206
9 votes
Accepted

Numerical computation of Lyapunov exponent

It is not the Jacobian of $f$ that you need to use to propagate the local basis, but the Jacobian of the propagator of the numerical method. That is, if $$ v_1=v_0+\Phi_f(v_0,dt)dt $$ then $$ U_1=(I+...
Lutz Lehmann's user avatar
  • 6,064
8 votes
Accepted

Visualizing the solutions of the Differential equations by varying different parameters

You can try Geogebra (it is free). With SolveODE command and sliders you can do what yo want. For the usage of SolveODE command see. For example by using following command ...
Ömer's user avatar
  • 643
7 votes

Specifying ode solver options to speed up compute time

Julia's DifferentialEquations.jl has a lot of tooling for automatically deriving (sparse) matrices. For more information, see the JuliaCon 2020 video on Auto-Optimization and Parallelism in ...
Chris Rackauckas's user avatar
7 votes
Accepted

How do people know the classic Lorenz attractor is actually deterministically chaotic at infinite time?

If I am remembering correctly, periodic orbits are known to be dense and countable in the Lorenz attractor, but are also known to be unstable (The first return map has $|F'| >1$ everywhere). A ...
whpowell96's user avatar
  • 2,444
7 votes

Numerical implementation of ODE differs largely from analytical solution

The equation for the square resistance can be easily solved by remembering the pattern $$(e^y)''=e^y\,(y''+y'^2)$$ and considering $u=\exp(-cx)$. This gives $\dot u=cvu$ (with $v=-\dot x$) and $$\ddot ...
Lutz Lehmann's user avatar
  • 6,064
6 votes

Some questions on Trace (operators) on the boundary in the context of PDEs

I think the quote from Wikipedia is misleading (and I should put that on my list of things to fix :-) ). You can think of the trace of a function $u: \Omega \rightarrow {\mathbb R}$ that lives on a ...
Wolfgang Bangerth's user avatar
6 votes

Solving coupled differential equations in Python, 2nd order

The first step is to transform the second order equation to a set of two coupled first order equations. Define an auxiliary function $u(T) = \frac{dr(T)}{dT}$. This results in the system $$\begin{...
GertVdE's user avatar
  • 6,179
6 votes

solve_ivp from scipy does not integrate the whole range of tspan

You can examine the sol object to see why the integration failed. It provides the message 'Required step size is less than spacing between numbers.' This usually ...
Steven Roberts's user avatar
6 votes
Accepted

How does non-dimensionalization improve the behavior of ODE solvers?

Background Let’s have a brief look at what parameters an integrator typically has and what they are used for. All of them govern step-size adaption: Relative tolerance (...
Wrzlprmft's user avatar
  • 2,032
6 votes
Accepted

Python bifurcation diagram of seasonally forced epidemiological models

Recently in https://math.stackexchange.com/questions/4542008/how-to-loop-parameter-a-in-henon-map I came into contact with the idea of an "adiabatically gliding" parameter where one gets the ...
Lutz Lehmann's user avatar
  • 6,064
5 votes
Accepted

Can Runga-Kutta method be used to solve non-linear differential equations?

Runga-Kutta schemes are multistage recipes for numerical discretizations of temporal derivatives. That is they tell to how to solve equations in the form $\dot{\mathbf{y}} = \mathbf{f}(\mathbf(y,t)$. ...
origimbo's user avatar
  • 2,249
5 votes
Accepted

Numerical integration in 2D

You can convert this equation into a Poisson equation and use standard numerical methods to solve it like finite difference to obtain $\theta(x,y)$. If you take a divergence from both side: $$\nabla^{...
Mithridates the Great's user avatar
5 votes
Accepted

Solving the heat diffusion equation with source term

You are starting from a uniform temperature and you have insulated boundary conditions; so there is no heat conduction occurring. Likewise, your initial mole fraction is also constant in $x$ so that ...
Bill Greene's user avatar
  • 6,064
5 votes
Accepted

scipy odeint: excess work done on this call and very sensitive to initial value

Essentially, by combining all the constant factors, your ODE is $$ \frac{dL}{dt} = -A + B L + C L^2 $$ With the initial $L(0)=L_0$ large enough, the positive feed-back of the quadratic term drives ...
Lutz Lehmann's user avatar
  • 6,064
5 votes
Accepted

How to set up the differential equation system to speed up computation?

Some things I can think of: use sparse matrices for Matrix1 and Matrix2 to speed up the computations of ...
Laurent90's user avatar
  • 1,868
5 votes
Accepted

2-DOF Robotic Manipulator Trajectory Tracking Simulation

As far as I understand the fist part of your question is regarding the options of the ode15s, and which ones you can use to make the solver more efficient/accurate. ...
kostas1335's user avatar
5 votes

Numerical integrator for $a'(t)=e^{-a(t)}f(t)$

You want a numerical solution, but this might help you check your computed results. If $a$ satisfies the ODE, you know $e^{a(t)}a'(t) = f(t)$. Integrating you get \begin{align} \int_0^t\, f(\tau)\, d\...
A rural reader's user avatar
5 votes

Solving numerically the 1D Kuramoto-Sivashinsky Equation using spectral methods

Indeed the problem was that you were trying to calculate your nonlinear term incorrectly and you forgot that: $$\mathcal{F}[(f(x))^{2}] \neq (\mathcal{F}[f(x)])^{2}$$ I changed your code to this: <...
Mithridates the Great's user avatar
5 votes
Accepted

Recommendations for ODE solvers for stiff equations

This is a huge open ended question, but I'll copy the recommendation section from the current release of DifferentialEquations.jl: Stiff Problems For stiff problems at high tolerances (>1e-2?) it ...
Chris Rackauckas's user avatar
5 votes

Is there a Python version of the ODE tool pplane?

I do not really know how much this can help you, but maybe you can use this code for rough sketches of the dynamics of planar vector fields. I know that it does not have the functionality that you may ...
Futurologist's user avatar
5 votes
Accepted

Solving constrained odes's using inbuilt solvers in Matlab/Octave

Yes you can. If the term that multiplies $N$ is never zero, then $N$ is an algebraic variable of index 1. Its combination with the ODEs on $x$ yields a system of differentiel-algebraic equations (DAEs)...
Laurent90's user avatar
  • 1,868
5 votes

unconditionally stable schemes better than conditionally stable ones in accuracy?

This is absolutely possible. For example, say you're solving the advection equation $$\frac{\partial q}{\partial t} + \nabla\cdot q\,\mathbf u = 0$$ for the field $q$ using your favorite technique for ...
Daniel Shapero's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible