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.

1524 questions
6
votes
2 answers

Solve an implicit ODE (differential algebraic equation DAE)

I'm trying to solve a second order ODE using odeint from scipy. The issue I'm having is the function is implicitly coupled to the second order term, as seen in the simplified snippet (please ignore the pretend physics of the example): import numpy…
Shaun_M
  • 83
  • 1
  • 6
6
votes
1 answer

Python - Scipy : ode module : issue enabling the step option of the solver

I wanted to store the different integration steps taken by the solver itself when I call it : solver1.integrate(t_end) So I did a while loop and enabled the step option setting its value to True: while solver1.successful() and solver1.t < t0+dt: …
kuider
  • 103
  • 5
6
votes
1 answer

Matlab - solving a third order differential equation

y''' + 41y'' + 360y' + 900y = 600x' + 1200x; y(0)= 2 ; y'(0)= 1 ; y''(0) = -0.05 How can I solve this equation using the ODE45 function? I tried this: ==> function dydt=f(t,y) dydt = [y(2) ; y(3) ; -41*y(3)-360*y(2)- 900*y(1)] ==> clear…
ag.alessandro
  • 63
  • 1
  • 1
  • 6
6
votes
1 answer

Using scipy fft and ifft to solve ordinary differential equation numerically

I have an ordinary differential equation in time domain as follows: C*du/dt = -g*u + I where I = A*t/tau*exp^(1-t/tau) in the freq domain: u(w) = I(w)/(g*(1+C/g*j*w)) j being the complex number sqrt(-1) hence i can get u(t) by going into the freq…
user1854231
  • 61
  • 1
  • 2
6
votes
1 answer

How to solve ODEs with an internal threshold?

I have the following function containing some odes: myfunction <- function(t, state, parameters) { with(as.list(c(state, parameters)),{ if (X>20) { # this is an internal threshold! Y <- 35000 dY <- 0 …
Claudia
  • 856
  • 1
  • 8
  • 25
6
votes
2 answers

In search for a good Java ODE solver

I'm working on a project to create a GUI for an algorithm in MATLAB using an ODE solver (ode45). So I have to translate the MATLAB code to Java. The problem is the ode45 solver. Java does not seem to have a solver ready to use, and ODE's are not…
Sander
  • 564
  • 4
  • 16
5
votes
1 answer

vector faster than double*: why?

Here's a loop that I've tried with std::vector and with plain old double*. For 10 million elements, the vector version consistently runs in about 80% of the time that the double* version takes; for pretty much any value of N, vector is…
Hector
  • 53
  • 1
  • 3
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

Convert a numpy array to iterator

I want to use an array as argument of a function which will be used to solve an ODE function. def ode(x, t, read_tau, tau_arr): q_ib = x[0:4] omega = x[4:7] dq_ib = 0.5 * np.dot(gen_omega(omega), q_ib) + read_tau(tau_arr) return…
Lion Lai
  • 1,640
  • 1
  • 18
  • 28
5
votes
1 answer

Ordinary differential equations (ODEs) - Is there any way to prevent negative values?

I am trying to apply a system of ordinary differential equations (ODEs) at each spatial grid cell. Thus, each landscape cell has an associated ODE model. The number of susceptible mosquitoes (Sv), exposed mosquitoes (Se) and infected mosquitoes (St)…
Nell
  • 509
  • 4
  • 18
5
votes
1 answer

How do I use pylab to plot a phase plane for pendulum motion?

I have code that will work for plotting the following predator prey model: dx/dt = x − xy, dy/dt = −y + xy from pylab import * xvalues, yvalues = meshgrid(arange(0, 3, 0.1), arange(0, 3, 0.1)) xdot = xvalues - xvalues * yvalues ydot = - yvalues +…
skrooms
  • 113
  • 1
  • 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
  • 313
  • 1
  • 12
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
  • 399
  • 4
  • 15
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
  • 197
  • 2
  • 9
5
votes
1 answer

Using a loop in an ODE to graphically compare different parameters R

I'm using the deSolve package to plot a couple differential equations (read if interested http://www.maa.org/press/periodicals/loci/joma/the-sir-model-for-spread-of-disease-the-differential-equation-model). My eventual goal is to create an…
EJJ
  • 1,274
  • 7
  • 16