# Questions tagged [scipy]

SciPy is a Python-based ecosystem of open-source software for mathematics, science, and engineering.

268 questions
Filter by
Sorted by
Tagged with
1 vote
81 views

### Convert scipy integration with one step to matlab integration

Scipy integration allows us to do ode integration one adaptive timestep at a time and do something to it. However, matlab ode needs us to specify a timespan , and determine the adaptive timestep ...
• 121
1 vote
213 views

### vectorizing optimization or root finding [closed]

I need to find the roots of a function. I am currently using scipy.optimize.fsolve ...
• 163
2k views

### integral including a vector

I need to calculate the integral of this function def f(z): return ((1-2*z)*np.exp(-d/z))/(((1-z)**(2+d))*(z**(2-d))) Here d is a constant. I am using this ...
• 163
1 vote
349 views

### Vectorize function integration

I need to implement the following in python: For a given discrete time series $Z_t$ ($t={0...T}$), find the smallest $t$ such that: $$c\sum_{s=0}^t e^{[k(Z_t-Z_s)+m(t-s)]} \geq \frac{p^*}{1-p^*}$$ ...
• 163
956 views

### Why does LSODA fail to integrate the logistic function?

I'm comparing some of the different ODE integrators in scipy.integrate.ode on solving the logistic function: $$x(t) = \frac{1}{1+e^{-rt}}$$ $$\dot{x} = rx(1-x)$$ ...
• 173
1k views

### Use of scipy sparse in ode solver

I am trying to solve a differential equation system $$x´=Ax\quad \text{with } x(0) = f(x)$$ in Python, where $A$ indeed is a complex sparse matrix. For now i have been solving the system using the ...
890 views

### Matrix Balancing Algorithm

I have been writing a control system toolbox from scratch and purely in Python3 (shameless plug : harold ). From my past research, I have always complaints about ...
• 393
401 views

### How to reuse permutation-orderings within scipy's SuperLU-wrapper?

i'm solving sparse linear equations within scipy 0.18 which internally resorts to SuperLU (after umfpack got removed due to license-issues). Current, i'm doing a complete re-factorization in each ...
• 131
4k views

### Applying the result of Cuthill-McKee in SciPy

I have applied SciPy's implementation of the Cuthill-McKee algorithm to a $48 \times 48$ sparse non-symmetric matrix in Compressed Sparse Row (CSR) format and the output is an array of length $48$ ...
284 views

### Fast Python implementation of short-range interacting particles under Metroplis algorithm

Can anyone write a Python implementation of a set of particles interacting in 2D according to a short-range particle-particle force and evolving in time under a Metropolis algorithm, which randomly ...
697 views

### Gradients of non-uniformly sampled data in 3D space

I have measurements of magnetic field on a 3d grid. My measurements are distributed on four x-y planes similar to what is shown in the image below. The measurements roughly follow a Cartesian grid but ...
• 133
1 vote
1k views

### linearly interpolate and determine gradients for data on non-uniform grid

I have measurements of a quantity on a 3d grid. My measurements are distributed on four x-y planes similar to what is shown in the image below. The measurements roughly follow a Cartesian grid but ...
• 133
4k views

### What does Python offer for distributed/parallel/GPU computing?

Using the SciPy/NumPy libraries, Python is a pretty cool and performing platform for scientific computing. I just wonder: When I have to go parallel (multi-thread, multi-core, multi-node, gpu), what ...
• 1,463
1 vote
806 views

• 325
1 vote
191 views

### Generalized Hermite Function as eigenfunction of a differential operator

I'm going through this paper. The article defines function function $\phi_n^\mu(x)$ that is orthonormal on $L^2$ with measure $dm = dx$: \phi^\mu_n =\left(\frac{\gamma_\mu(n)}{\...
520 views

### Repeated 1d minimization with similar parameters (scipy)

I have a function f(x,k1,k2) and I am trying to minimize it over x for different values of ...
• 115
439 views

### Why do Newton-Krylov iterations stagnate in this problem? [closed]

Consider this integro-differential heat equation taken from SciPy documentation page: $\nabla^2 P = \alpha \left(\iint_\Omega \cosh(P)dx dy \right)^2$ which was found in this question. In the ...
• 1,832
176 views

### Methods for solving $x'=Ax+b$ for small, sparse, singular $A$

I am in the process of building a robotics physics engine. I have been using the Linear ODE $x' = Ax + b$ for the core of my physics integration, but have never found a really good solution method for ...
813 views

### (numpy/scipy) Build a random vector given mean vector and covariance matrix

After running several calculations with numpy, I end with the mean vector and covariance matrix for a state vector. Is there a way with numpy or scipy to sample a random vector around this mean and ...
34k views

### Plot integral function with scipy and matplotlib

I want to plot a numerical integral function of some function $f$ using scipy and matplotlib. How can I do this? I tried the ...
• 231
1 vote
196 views

### Is it worth switching to timesteppers provided by PETSc if I can't write down a Jacobian for my problem? Case study with "the amoeba" toy problem

I am considering using petsc4py instead of scipy.integrate.odeint (which is a wrapper for Fortran solvers) for a problem ...
• 659
11k views

### LCM builtin in Python / Numpy

I can write a function to find LCM (lowest common multiple) of an array of integers, but I thought it must have been implemented in numpy or scipy and was expecting something like ...
• 143
2k views

### Numerical solution of Geodesic differential equations with Python

I have made a solver based on the SymPy.diffgeom library, where I use Scipy.Integrate to solve the following system of second order differential equations : \begin{align} u'' &+ \Gamma^0_{00}(u')...
• 425
255 views

### Solve a pair of coupled nonlinear equations within certain limits

This answer to this question works only for situations in which the desired solution to the coupled functions is not restricted to a certain range. But what if, for example, we wanted a solution such ...
• 107
1k views

### Numerical integration with singularities

I need to compute some integrals numerically. The integrand is this: $$f(x,y) = \left ( \sum_{mn=-j}^{j}A(m,n)\dfrac{\tan^{2j+m+n}(x/2)}{(1+\tan^2(x/2))^{2j}}e^{iy(n-m)} \right )^{N}$$ Note: sums ...
133 views

### Use scipy to get any vertex of polytope

I need to get just a random vertex of a polytope. Any will do. The only way I can do this now is to pick a random function (say 0s) to maximize with scipy.optimize.linprog. However, this is wasteful, ...
3k views

### Scipy OdeInt solver with Neumann boundary conditions

I'm using scipy.odeint to solve Fisher-Kolmogorov equation: $$u_t = u_{xx}+u(1-u)$$ The code can be found here. From Ablowitz and ...
• 289
454 views

### Forcing an ODE solver to preserve the norm

I have an ODE of the form $$\frac{dy}{dt} = -i H y \enspace .$$ where $y$ is a complex vector and $H$ is a time dependent Hermitian matrix. The norm of the solution $y(t)$ at any point in time ...
• 193
6k views

### Solve non-linear set of three equations using scipy

I need to solve a non-linear set of three equations using scipy. However, I do not have any clue on which algorithm is suitable for my problem from a mathematical point of view (stability, convergence ...
• 203
1 vote
553 views

### scipy.integrate.ode ignores boundary conditions [closed]

I am trying to solve the 1-dimensional diffusion problem numerically using method of lines: $$\frac{\partial c}{\partial t} =D \frac{\partial^2 c}{\partial z^2},$$ where the right hand side is ...
2k views

### Can an approximated Jacobian with finite differences cause instability in the Newton method?

I have implemented a backward-Euler solver in python 3 (using numpy). For my own convenience and as an exercise, I also wrote a small function that computes a finite difference approximation of the ...
649 views

### General heuristics for making a choice "dopri5", and "lsoda"?

With scipy, I have the choice of using "lsoda": Real-valued Variable-coefficient Ordinary Differential Equation solver, with fixed-leading-coefficient ...
• 659
3k views

### scipy: what does scipy.integrate.odeint's Repeated convergence failures (perhaps bad Jacobian or tolerances)." error mean?

What does the following scipy.integrate.odeint error mean numerically? ...
• 659
556 views

• 183
1 vote
125 views

### Possible to reduce effort needed to solve non-linear ODEs by taking some coefficients/parameters as constant over small time intervals?

So far, I have been using scipy.integrate.odeint as my "workhorse" ODE solver. My current problem requires that I solve a large system (up to ~5000) ODEs. Here's ...
• 659
1 vote
4k views

### scipy.integrate.odeint: how can odeint access a parameter set that is evolving independently of it?

I might have some non-linear ODEs that are being solved by scipy.integrate.odeint. However, a parameter at each time step might have to be updated by using a non-DE ...
• 659
2k views

### How best to use scipy.integrate's ODE solvers when state is not naturally stored as a vector?

I have a large system of ODEs. For various reasons, it is natural to store the values of the dependent variables in a multidimensional array. For example, these values might represent the solution ...
• 659