Questions tagged [ode]

An ODE (ordinary differential equation, in contrast to partial differential equation) is a differential equation containing a function or functions of exactly one independent variable.

An ODE (ordinary differential equation, in contrast to partial differential equation) is a differential equation containing a function or functions of exactly one independent variable. Equations of this type can be solved numerically or analytically.

1902 questions
5
votes
2 answers

How to solve a stiff ode with Python?

I'm a Python beginner. I'm trying to switch some programs that I have in matlab. I need solve a stiff ode equation, whose inputs are all matrices. In matlab I use [ttT,uT] = ode23s('SST',t,fT);
marco
  • 915
  • 4
  • 17
  • 35
5
votes
2 answers

How to solve a system of ODE with time dependent parameters in R?

I am trying to solve this system of ODEs through deSolve, dX/dt = -X*a + (Y-X)b + c and dY/dt = -Ya + (X-Y)*b for time [0,200], a=0.30, b=0.2 but c is 1 for time [50,70] and 0 otherwise. The code I have been using is, time <- seq(0, 200,…
5
votes
1 answer

Solving and plotting a piecewise ODE

I have a function dφ/dt = γ - F(φ) (where F(φ) -- a is 2π-periodic function) and the graph of the function F(φ). I need to create a program that outputs 6 plots of φ(t) for different values of γ (γ = 0.1, 0.5, 0.95, 1.05, 2, 5), and t∈[0,100]. Here…
james
  • 109
  • 6
5
votes
1 answer

Second order differential equation in Julia

I'm new to Julia programming I managed to solve some 1st order ODE, but when I thought to move to the second order I don't know how to use the solver to implement to the required equation. I want to solve this equation y" + y = 0 with initial…
5
votes
2 answers

Writing a function for the Implicit Runge-Kutta method (order four)

I am trying to compose a function that will solve a system of ODES using the implicit Runge-Kutta method (IRK) of order 4, but I am having trouble properly defining my loop. Here we define the IRK by Any advice would be greatly…
5
votes
1 answer

How to implement adaptive step size Runge-Kutta Cash-Karp?

Trying to implement an adaptive step size Runge-Kutta Cash-Karp but failing with this error: home/anaconda/lib/python3.6/site-packages/ipykernel_launcher.py:15: RuntimeWarning: divide by zero encountered in double_scalars from ipykernel import…
ZelelB
  • 1,836
  • 7
  • 45
  • 71
5
votes
1 answer

Runge-Kutta 4th order method to solve second-order ODES

I am trying to do a simple example of the harmonic oscillator, which will be solved by Runge-Kutta 4th order method. The second-order ordinary differential equation (ODE) to be solved and the initial conditions are: y'' + y = 0 y(0) = 0 and y'(0) =…
pmoreira
  • 175
  • 1
  • 2
  • 7
5
votes
1 answer

SymPy "solves" a differential equation it shouldn't solve

Here's what I did: from sympy import * x = symbols("x") y = Function("y") dsolve(diff(y(x),x) - y(x)**x) The answer I get (SymPy 1.0) is: Eq(y(x), (C1 - x*(x - 1))**(1/(-x + 1))) But that's wrong. Both Mathematica and Maple can't solve this ODE. …
Frunobulax
  • 345
  • 2
  • 13
5
votes
1 answer

Fastest way to calculate exponential [exp()] function of large complex array in Python

I'm developing code that integrates an ODE using scipy's complex_ode, where the integrand includes a Fourier transform and exponential operator acting on a large array of complex values. To optimize performance, I've profiled this and found the main…
SLater01
  • 459
  • 1
  • 6
  • 17
5
votes
1 answer

Solving a BVP with scipy's solve_bvp

I have a system of 3 differential equations (will be obvious from the code I believe) with 3 boundary conditions. I managed to solve it in MATLAB with a loop to change the initial guess bit by bit without terminating the program if it is about to…
Zack Fair
  • 207
  • 1
  • 3
  • 9
5
votes
2 answers

MATLAB solve ODE on invariant manifold

I have a system that looks like dn/dt=f(n,v) dh/dt=g(h,v) I want to solve this equation on the manifold F(v,n,h)=0, a nonlinear function in v. I tried to use something like v=fzero(@(x) F(x,n,h),0) to solve for the value of v on the manifold at…
Badoe
  • 1,580
  • 1
  • 12
  • 13
5
votes
1 answer

need to understand better how rtol, atol work in scipy.integrate.odeint

Here scipy.integrate.odeint is called with six different standard ode problems with rtol = atol from 1E-06 to 1E-13. I've looked at the max difference between the results at all larger tolerances minus those of the smallest, to get some kind of…
uhoh
  • 3,713
  • 6
  • 42
  • 95
5
votes
2 answers

Numba's jit fails to compile function that has another function as input

I am trying to numerically Solve an ODE that admits discrete jumps. I am using the Euler Method and was hoping that Numba's jit might help me to speed up the process (right now the script takes 300s to run and I need it to run 200 times). Here is my…
gota
  • 2,338
  • 4
  • 25
  • 45
5
votes
3 answers

using a time series of parameters to solve ODE in R

I am trying to solve a simple ODE in R using deSolve: dQ/dt = f(Q)*(P - E).The whole thing is a time series of Q. The trick is that P and E are fixed time series of data themselves, so the diff eq is effectively in Q alone. It's relatively…
Iceberg Slim
  • 451
  • 6
  • 14
5
votes
2 answers

ODE, multiple roots and events, R

I like to solve a system of coupled differential equations which involve multiple thresholds. Going through the R information this leads me to using ODE in combination with the root function and the event function. Going through various examples,…
Linda
  • 51
  • 2