# Questions tagged [scipy]

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

253 questions
Filter by
Sorted by
Tagged with
54 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 ...
79 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 ...
52 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 ...
1 vote
67 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 ...
170 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 ...
21 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: ...
148 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 ...
1 vote
52 views

### Possible bug with scipy.optimize SHGO sobol: TypeError: <lambda>() takes 1 positional argument but 3 were given

I have been trying to perform some global optimization with SciPy optimizer SHGO and I've had issues with the sampling method 'sobol'. Specifically, I get an error ...
88 views

257 views

582 views

### ValueError: array must not contain infs or NaNs; When using solve_ivp in the scipy library

I am solving an initial value problem using solve_ivp. The problem consists of computing the concentration profile of a set of reactions over time, given the initial concentrations and some of the ...
116 views

### Interpolating 2D data on a hemisphere in order to have $C^2$ function but no overshoot

I am interpolating a 2D dataset on a hemisphere, and I am currently using scipy.Rbf that I like for its simplicity. I am defining the norm of the interpolator with ...
1 vote
404 views

1 vote
85 views

### Using absolute error as the cost function

This is related to my previous post Minimize distance between curves. I have a dataset with values of multiple curves. An example plot is shown below. I want to scale the curves (move up/down) so that ...
152 views

### Solving differential equations with fast oscillations using odeint

I have wrote this code to solve an equation , I know the behavior of this function has very rapid oscillations, when I RUN it gives bogus values for some "m[x]" and some "t"'s, ...
1 vote
261 views

### How to perform FFT from plane-wave basis function coefficients to real space?

I have a 3D grid in real space of grid spacing $L$ and say 21 grid points in each direction, containing e.g. a charge distribution. This is stored as a numpy array of shape ...
123 views

### Fitting gauss-hermite-parametrization to data?

I want to fit this data. I have the following model functions. Classic gaussian: def gauss_model(x, mu, sigma): return np.exp(-0.5*((x-mu)/sigma)**2) And ...
1 vote
357 views

### Huygens Fresnel Diffraction integral using dblquad in python

I am attempting to create a python function to assist in calculating the following numerical integration of the Huygens Fresnel integral in the form of ...
1 vote
2k views

### scipy.optimize.minimize fails to converge but result is OK

I am trying to optimize a non-linear least squares problem with scipy.optimize.minimize. I have simplified my actual problem down to the case where I am just computing the top 'principal components' ...
1 vote
99 views

### Parameter estimation simple theory question related to scipy.optimize.curve_fit

It has been a while since I have done some stats, and I have tried to fit a curve using optimize.curve_fit of parameter estimation. I am also interested in the standard deviation of the fitted ...
1 vote
1k views

2k views

### Optimal value of parameter/s from a set by scipy.optimize.minimize() method

I have this function $y = \exp(-x)$. I have a list of $x$ values and corresponding $y$ values. ...
103 views

### Finding the correct order of eigenvectors of a parameter-dependent Hermitian matrix

so, I have a symmetric, analytic matrix $\mathbf{H}(x)$ ($x$ is real). Because $\mathbf{H}(x)$ is analytic and $x$ is real, it is possible to find analytic functions for the eigenvectors and the ...
115 views

### SciPy ODR "Ordinary" Least Squares?

Scipy.odr has a setting for "fit types", including one for ordinary least-squares. This matches with the documentation of ODRPACK (see p. 31, Computational method). However, the package ...
312 views

### Can't solve second order differential equation with scipy

Most of my knowledge about numerically solving differential equations is long forgotten. Unfortunately I stumbled upon a physics problem where I need to do exactly that. I'm trying to describe the ...
199 views

### Global convergence behavior of several Krylov solvers in scipy.opt

In the context of mechanical simulation, where I solve the stationary action principle directly (i.e. $\nabla S = 0$ for some scalar function $S$), I use the wrapper ...
602 views

### How to solve a BVP with known parameters?

I need to solve a boundary value problem (BVP) of second order, where the equation depends on several know parameters, which are geometric parameters and material constants. I would like to solve this ...
1 vote
247 views

### Trouble inverting complex matrix with numpy and scipy

I have some matrix-valued, complex data $Z(f)$ with $f\in\{f_0,f_1,\dots\}$ and $Z(f_i)$ being a 3x3 matrix. I require the inverse $Z^{-1}(f)$ in my workflow. After encountering some problems with my ...
I have a problem which I believe is numerical instability when trying to solve a heat conduction equation using finite difference. The short version is that when the parameter $I=80.3$ I get the blue ...