# 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
37 views

### Find peaks method for finding elusive peaks

I'm currently utilizing the find_peaks function to identify peaks within this spectrum. However, despite consulting similar queries on Stack Overflow, my attempts to incorporate features such as ...
42 views

### How to calculate the numerical integration and plot the result in python?

I am trying to solve the question below in McQuarrie Physical-Chemistry book. The first step of the exercise, I solved. However, the second step involves a numerical integration. I can develop a code ...
66 views

### BSplines from scipy not defined on whole range of the knots

I am looking at the construction of BSplines out of curiosity. I created a small code that uses scipy.interpolate.BSpline to create basic splines. I get the following basic splines for order 0, 1 and ...
6k views

### WRL and VRML to Matplotlib/Numpy

I would like to import (or parse ??) a WRL/VRML file format in python in order to work the data with Matplotlib. Is there any way of converting this file format into plottable numpy arrays ? I ...
48 views

### solve_ivp method=ODE23 time step not decreasing in order

My time step with the function scipy.integrate.solve_ivp is not decreasing in t_span fluctuating (reaching values below or ...
120 views

### Different Results for Double Pendulum

In this study, (Hidden Fractals in the Dynamics of the Compound Double Pendulum) the authors provide various fliptime fractals (of a double pendulum) for different length combinations. However, when I ...
59 views

### scipy exp model fitting: prevent coefficients blowup

I'm trying to fit a few X-Y points that look like exponential. I used the following scipy code: ...
65 views

### Hyperbolic integral of the second kind

The elliptic integral of the second kind is given by $$E(t,m) = \int_{0}^t \sqrt{1-m \sin(s)^2} \operatorname{ds}$$ and there is for instance a scipy function ellipeinc that computes it. The ...
121 views

### BFGS Constrained Optimization Failure Due to Precision Loss

I am trying to optimize the following objective function according to some constraints. However, the optimization fails at the first iteration with the message that the desired error was not ...
35 views

### using scipy.sparse.linalg.eigsh for degenerate states in Bose Hubbard model

I am currently writing a code for the Bose-Hubbard model, and I am calculating the ground states and single-particle density matrix for different values of U and J. As U=0, one would see how the ...
1 vote
436 views

### optimizing piecewise linear objective functions (perhaps non convex) with equality constraints

When I do my project, I need to optimize piecewise linear objective functions (perhaps non convex) with equality constraints. The piecewise linear objective function may be not convex like this in the ...
97 views

### How to minimize a numerical integration in python?

I need some help to minimize a numerical integration. It's about a classical problem in physics (hydrogen atom). It can be solved analytically but I need to solve it numerically in Python. We have an ...
69 views

### Singular Matrix Error in Incomplete LU Decomposition

I’m currently working on solving the following PDE: $$$$-(\mu_x \frac{\partial^2 u}{\partial x^2} + \mu_y \frac{\partial^2 u}{\partial y^2}) = f(x, y)$$$$ Where a right hand ...
2k views

### What algorithm(s) do numpy and scipy use to calculate matrix inverses?

I am solving differential equations that require inverting dense square matrices, and I wanted to know what algorithm(s) do numpy and scipy use to calculate matrix inverses?
79 views

### How to use a custom OdeSolver in Scipy's solve_ivp

In Scipy's solve_ivp documentation, we see the method argument can be either a string or a user-defined ...
93 views

### Numerical calculation of Lyapunov exponents using SciPy's built-in solve_ivp

I have previously successfully implemented the QR decomposition method in MATLAB to calculate Lyapunov exponents for Lorenz equations. See here. This method integrates the stacked system, i.e. the ...
28k views

### scipy odeint - Excess work done on this call

I'm newbie both in calculus and Python/Scipy so I apologize if this question is too dumb. I'm trying to model flow between two pressure vessels. Let's say we have two points and a link between them ...
464 views

### Number of function calls and jacobian calls in scipy.root

Just as an exercise, I am numerically solving the following system of equations: $$$$\begin{cases} x^2 + y^2 = 32 \\ 3x + 7y = 15 \end{cases}$$$$ ...
4k views

### Computing numeric derivative via FFT - SciPy

I wrote the following code to compute the approximate derivative of a function using FFT: ...
17k views

### What is the fastest way to compute all eigenvalues of a very big and sparse adjacency matrix in python?

I'm trying to figure out if there is a faster way to compute all the eigenvalues and eigenvectors of a very big and sparse adjacency matrix than using scipy.sparse.linalg.eigsh As far as I know, this ...
139 views

### Solving system of ODEs, where time derivative approaches infinity due top initial condition

I am trying to solve a problem in python using scipy's solve_ivp. The system of ODEs I am trying to solve is for coupled where I am solving for two time-dependent ...
140 views

### Weights for equidistant samples in power law fitting

I am working on fitting analytical curves to experimental data obtained in real viscoelastic tests (in fact, static creep tests). The setting of the problem is: the experimental data I have is a set ...
207 views

### 2D integrals in Python with specified points of interest

Note: This is my first question on stackexchange; please tell me if I'm doing something incorrectly. I am trying to calculate a series of a 2D integrals in Python with an integrand that has several ...
1k views

### Why does scipy.optimize.minimize(...) fail with this toy constrained minimisation case?

I'm learning scipy.optimize.minimize. I thought of a simple function to see how it works: $$f(x) = x$$ With the goal to minimise $f(x)$, subject to the constraint ...
1 vote
250 views

### Using solve_ivp for a PDE: how to handle multiple time-dependent variables?

I am trying to build a Python code that solves a set of coupled differential equations which will be spatially discretized by the method of lines advancing in time. I am planning to use ...
411 views

### Solving IVP backward in time via python

I'm having difficulty solving an initial value problem (IVP) in Python backwards in time. The code is at the end of this post. First, please let me state my simplified problem. The forward IVP is ...
27 views

### Matching the limits of integration with the proper variables in a complicated case when using scipy.integrate.nquad

I need to integrate expressions containing powers of the function: ...
4k views

### Three dimensional irregular grid data interpolation to regular grid

I have three-dimensional radar reflectivity data obtained as voxels (scans, rays, altitudes). The data has been sampled at irregular spacings and I want to convert this into a regular grid. In ...
326 views

### Accelerating the computation of scipy.sparse.linalg.expm_multiply

I have a tridiagonal antiHermitian matrix ($-i*Hami*t$) with nonzero elements only along the upper diagonal and lower diagonal, and the goal is to know the action of exponential of such matrix on a ...
636 views

### Translating the Euler code in scipy's solve_ivp

My code is based on the similarity transformation X=VZ.I simulate the model for transformed equations involving Z by replacing ...
96 views

### Solve 1st order ODE in using scipy
I've been trying to solve the following equation $$y(t)=-A\cdot\frac{\mathrm{d} y}{\mathrm{d} t}+B\cdot\left(\frac{\mathrm{d} y}{\mathrm{d} t}\right)^{2}+C \\ y(t=0)=y_{0}\\$$ where $A$, $B$, and $C$...