# Questions tagged [scipy]

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

137 questions
Filter by
Sorted by
Tagged with
52 views

### Solving differential equation in Python with discretized variable coefficients

I am trying to solve a differential equation with discretized variable coefficients which are calculated from a time serie. In this case the Runge-Kutta step size is fixed by the frequency in the time ...
48 views

63 views

### Scipy Spline Interpolation Parameter

Documentation in scipy.interpolate (found at https://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html) states: "The parameter variable is given with the keyword argument, u, which ...
48 views

### Conjugate Gradient for singular 2D poisson finite element with Neumann Boundary Conditions

Heavily edited question after I realised partly what the problem was I have programmed a simple 2D square finite element solution to the Poisson equation $-\Delta u = f$ The source function ...
97 views

### Maximize a function of an orthogonal matrix

I'm trying to write up a small code that, given a set of normal vibrational modes for a molecule, will convert them to localized vibrational modes. To do this I'm following the procedure from J. Chem. ...
165 views

68 views

### identifying peaks in data

I have data with peaks on some background, for example: The two prominent peaks at ~390 and ~450, as well as the much smaller peak at ~840. What are some options to programmatically find the position ...
167 views

### Plug-and-go Clebsch-Gordan computation in python?

I started a little project in python, under the assumption that it would be easy to find a routine for numerically computing Clebsch-Gordan coefficients in some library such as scipy. When it came ...
261 views

31 views

### ILUTP in sparse.linalg.spilu?

In Matlab, an ILU with threshold and pivoting (ILUTP) can be passed by default as: setup.type = 'ilutp'; [L, U] = ilu(A, setup); Looking for an equivalent in ...
40 views

### Time sampling changes solution

I'm currently trying to solve a problem using numerical methods. The set-up is rather long, so I apologize in advance... TL;DR: My solutions change depending on how big my steps are and I don't know ...
246 views

### Numerical integration in Python with unknown constant

I’d like to solve the below equation for the unknown $T$: $$\int_0^\infty \frac{x^2}{\exp\left(\frac{x}{T}\right)-1}\kappa_x \mathrm{d}x = C,$$ where $C$ is a known constant and $\kappa_x$ is some ...
83 views

### Scipy basinhopping custom step update and constrained looping

I am searching for the global minimum of a certain function and trying to use its gradient (here same as Jacobin) to guide the step counter. However, my x is fix ...
61 views

### Creating an Interpolation of a w = f(x,y,z) function

I am trying to finish a series of interpolation functions. The problem is more related with organizing the data than how to do the interpolations. Using the RegularGridInterpolator, I created this ...
193 views

### Problems with python's interp 2D

I am writing some functions to interpolate data. While using interp2D, somehow, a sample matrix works but when I change the size of the matrix, it returns an error. ...
72 views

### Solve multi-dimensional optimization problem using basinhopping

I am searching for an optimization solution, which is a 8d vector representing 4 complex elements, where each element is within the complex circle with maximal radius 1.2. The objective function is: ...
246 views

### Memory and time requirements of the scipy sparse spsolve

I have a system of fairly large set of linear equations (approximately 30K equations). I am using scipy.sparse.spsolve to solve these equations. Initially, I tried ...
789 views

### Solve system of polynomial equations with Python

I have 5 at most 4th order polynomials in 5 variables, $$p_i(x_1,x_2,x_3,x_4,x_5) \qquad i = 1, \ldots, 5$$ where all coefficients are either rational or floating point. I'd would like to get the ...
415 views

### Scipy Two-point Boundary value Problem

Nonlinear ODE Statement I would like to use scipy to solve the following: u'' + (u')^2 = sin(x) u(0)=0, u(1)=1 where u = u(x). Approach I am looking at the ...
121 views

### Minimize cost with Levenberg-Marquart method

I want to minimize a cost function of the form, $$\min_{q,t}\left(q^T\left(\mathcal A + \mathcal B\right)q + t^T\mathcal C t+\delta t+\varepsilon Q(q)^TW(q)t+\lambda\left(1-q^Tq\right)^2\right)$$ ...
75 views

### SciPy 3d plotting Integral of $\int x^y dx$ for $y$ in $[-4,4]$

Ideally, I would like to get the symbolic/algebraic integral of the function and plot the resulting surface in 3d. I am not sufficiently versed in SciPy to know if this is even really possible.
75 views

701 views

### Integration of the Fermi distribution using Python

I want to calculate the carrier concentration of my semiconductor using this equation: $$n(x) = \frac{m^*}{\pi\hbar^2}\int_{E_k}^{\infty}\frac{1}{1+\exp\left(\frac{E-E_f}{k_BT}\right)} \mathrm{d}E$$...
84 views

### Inconsistency in optimize.minimize

I am trying to fit a time-dependent curve at each time step. I do so in minimizing along $x_c$ the quadratic error between the curve and a reference solution $1/(1 + \exp\left(\sqrt{S}(x-x_c)\right)$...
133 views

107 views

### Left eigenvectors using ARPACK

I'm trying to find both the dominant $k$ left and right eigenvectors, that is, $$V_L\mathcal{A} = \Lambda V_L\\ \mathcal{A}V_R = V_R\Lambda\\ V_LV_R = I_{k\times k}$$ $V_L$ being the $k\times N$ ...
802 views

### How to define the derivative for Scipy.Optimize.Minimize

I am trying to use scipy.optimize.minimize to minimise a quadratic objective function: $f(x) =x^\top Q x$. As a start, I have successfully implemented this using the built-in Nelder-Mead Simplex ...
1k views

### Solving a system of quadratic equations in Python

I'd like to solve numerically a system of quadratic equations: $A_{11}x_1+A_{12}x_2+A_{13}x_3+B_{12}x_1x_2+B_{13}x_1x_3=C_1$ $A_{21}x_1+A_{22}x_2+A_{23}x_3+B_{21}x_2x_1+B_{23}x_2x_3=C_2$ \$A_{31}x_1+...
171 views

### Rank filter on an nXm array using python

I would like to apply a rank filter on an nXm numpy array. Let's say I have this array: ...
39 views

### Inverting a transition matrix with small grid size

Time is continuous time. I have a 3D state space, and transition rates across all of these. Using the transition rates, I can compute a generator matrix A ...
### scipy.odeint giving different answer than analytical
I was using scipy.integrate.odeint function , the ode is $$\frac{y\ dx - x\ dy}{(x+y)^2} + dy = dx$$ with solution $$y^2 - x^2 - y = c (x + y)\ .$$ Solving it ...