Questions tagged [scipy]

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

Filter by
Sorted by
Tagged with
-1 votes
1 answer
45 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 ...
user avatar
1 vote
1 answer
88 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 ...
user avatar
1 vote
0 answers
66 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' ...
user avatar
  • 119
1 vote
1 answer
78 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 ...
user avatar
  • 65
1 vote
1 answer
47 views

Easy way to perform solver over pandas dataframe

I'm moving from Excel to Python and I'm trying to solve these equations: $$\begin{align} X_1&=\bigg[\big(3.47-\log(X_2)\big)^2+\big(\log(c)+1.22)^2\bigg]^{0.5}\\ X_2&=\frac{a}{101.32}\bigg(\...
user avatar
2 votes
1 answer
107 views

2nd order differential equation coupled to integro-differential equation in python

I'm trying to solve the following equations numerically in python $$\begin{align} 12\pi\int_0^\infty drf(r)\phi(r)r^4&=E\\ f(r)-\frac{1}{2\mu}\bigg(\frac{d^2\phi(r)}{dr^2}+\frac{2}{r}\frac{d\phi(r)...
user avatar
0 votes
1 answer
72 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. ...
user avatar
0 votes
0 answers
50 views

Help Finding Roots

I need to refine a level curve representing an implicit function that is not numerically solvable in sympy. The initial solution set generated by matplotlib's ...
user avatar
  • 143
2 votes
1 answer
91 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 ...
user avatar
  • 53
2 votes
1 answer
41 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 ...
user avatar
  • 21
2 votes
1 answer
92 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 ...
user avatar
  • 31
0 votes
0 answers
44 views

Global convergence behavior of several Krylov solvers in scipy.opt

In a context of mechanical simulation, where I solve the stationnary action principle directly (i.e. $\nabla S = 0$ for some scalar fonction $S$), I use the wrapper scipy.optimize.newton_krylov to ...
user avatar
3 votes
1 answer
116 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 ...
user avatar
1 vote
0 answers
49 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 ...
user avatar
4 votes
0 answers
50 views

How to troubleshoot numerical instability using finite difference for steady-state non-linear heat conduction equation

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 ...
user avatar
1 vote
1 answer
84 views

solve_ivp doesn't work with toms748

I have the following code ...
user avatar
  • 123
2 votes
1 answer
158 views

SciPy odeint giving different results with matrix multiplication

I've asked this at stackoverflow but maybe this community will have a better idea of the answer. I'm currently trying to develop a function that performs matrix multiplication while expanding a ...
user avatar
  • 123
4 votes
1 answer
3k views

Why is my curve_fit not producing the covariance matrix and the correct values for the unknown variables?

I am trying to fit supernova data into a scipy.curve_fit function. However, when my code runs, the values of the unknown variables given by ...
user avatar
  • 43
2 votes
2 answers
188 views

Calculate determinant of unitary matrices based on SVD implementation

I have a real square matrix $X$ which I need to perform a Singular Value Decomposition on. Now, performing the operation $$ X = USV^T $$ as $U$ and $V$ are orthogonal, we know that $\det(X)=\pm\det(S)$...
user avatar
  • 53
4 votes
0 answers
46 views

Pass forward intermediate results during iterative optimization

To investigate a counter-current flow heat exchanger while considering temperature dependent physical properties (such as specific heat $c_\textrm{p,i}$, heat conductivity $\lambda_\textrm{i}$, ...
user avatar
  • 223
1 vote
0 answers
52 views

How do you correctly implement Scipy's FFT procedures to produce a low-pass filter - image processing

I'm following this low-pass filter example in the text "Image Operators: Image Processing in Python 1st Edition" by Jason M. Kinser, but can't seem to duplicate their results. The text's ...
user avatar
1 vote
1 answer
581 views

solve_ivp from scipy does not integrate the whole range of tspan

I'm trying to use solve_ivp from scipy in Python to solve an IVP. I specified the tspan ...
user avatar
0 votes
1 answer
59 views

Logistic growth curve using scipy is not quite right

I'm trying to fit a simple logistic growth model to dummy data using Python's Scipy package. The code is shown below, along with the output that I get. The correct ...
user avatar
1 vote
2 answers
81 views

scipy odeint: excess work done on this call depending on initial values even with analytically solvable ODE

I am trying to solve a differential equation in the form: dx/dt = funct(x) using scipy odeint. However, for some initial values, I get a "ODEintWarning: Excess work done on this call", even ...
user avatar
  • 23
1 vote
1 answer
203 views

Efficiency of scipy.sparse.linalg.expm_multiply with sparse vs unsparse vectors

From the package scipy.sparse.linalg in Python, calling expm_multiply(X, v) allows you to compute the vector ...
user avatar
-1 votes
1 answer
232 views

Using ODE to plot particle-motion with scipy.integrate.solve_ivp

My Problem: A positively charged particle (mass = 2 * 10-27 kg) is moving along the x-axis. It is travelling in a homogenous magnetic field such that the field axis in z-direction. The energy of the ...
user avatar
-1 votes
1 answer
111 views

Solving ODEs, Rotations, Angular Velocity, Euler Angles

I am implementing a simulation that needs to rotate and object based on known angular velocity (assumed constant for simplicity). I followed the ideas given below, pg. 32) https://graphics.stanford....
user avatar
  • 229
-1 votes
1 answer
571 views

Fitting using curve_fit of scipy in python gives totally different answer for 1/t and t

I was trying to fit some data to a single degree exponential decay function but a*exp(-x*t) and a*exp(-x/t) gives completely ...
user avatar
-2 votes
2 answers
99 views

numerical solution for differential equation

I have these 3 equations and i want to solve them with numerical methods. so I am using scipy library but I don't know how to solve 3 equations together. R, g, sigma and density are constants. \begin{...
user avatar
1 vote
1 answer
118 views

Eigenvalue problem for ordinary differential equation

I am trying to compute the natural frequency of a cantilevered beam. The Euler-Bernoulli equation reduces to the following problem : $$ v''''=\lambda v, \text{with }, v(0)=0, v'(0)=0, v'''(1)=0,v''(1)...
user avatar
  • 33
2 votes
3 answers
236 views

Solving a PDE with 2 variables, with one variable whose derivative with respect to space is only known

I am trying to solve a PDE of the form $$\frac{\partial u}{\partial t} = D \frac{\partial^2u}{\partial x^2} + k\ \ \ (1)$$ where only $k$'s first derivative with respect to $x$ is known $$\frac{\...
user avatar
3 votes
0 answers
72 views

Does shift-invert method has invertibility issue?

Please note that I have nearly zero background on numerical methods. I understand the shift invert method as described in SciPy Tutorial The main argument of the above link is as follows. Suppose we ...
user avatar
4 votes
0 answers
76 views

Check if LinearOperator is symmetric

I have a scipy.sparse.linalg.LinearOperator object. I'd like to check if its associated matrix is symmetric without actually instantiating the matrix in the most ...
user avatar
  • 203
3 votes
1 answer
139 views

Lanczos algorithm for finding top eigenvalues of a matrix sum

I am trying to find the top k leading eigenvalues of a NumPy matrix (using python dot product notation) L@L + a*X@X.T, where $L$ ...
user avatar
  • 203
0 votes
1 answer
347 views

Error using scipy.integrate.solve_ivp: index error: the index 0 is out of bounds for axis 0 with size 0

I am recently working on the code based on the stick-slip phenomenon in Python. It's the stick-slip oscillator (chapter 3.4) in https://www.sciencedirect.com/science/article/pii/S0888327020301205. And ...
user avatar
-1 votes
1 answer
140 views

illegal use of ODEINT

given the following system: $$\frac{dP}{dt} = \alpha P(1-\frac{P}{K}) - \beta P I$$ $$\frac{dI}{dt} = \beta P I - \rho I$$ how do I solve the system numerically. as when I attempt to solve this is the ...
user avatar
3 votes
0 answers
70 views

Difference between wave vector and density matrix in numerical calculation of Schrödinger equation

I solved Schrödinger equation for a following tow-level time-dependent Hamiltonian numerically in two ways: ...
user avatar
  • 31
2 votes
0 answers
129 views

Providing Jacobian as LinearOperator in scipy.optimize.root

I asked this question a few days ago on stackoverflow, but I figure scicomp.stackexchange is probably a better place. Sorry for the double post. I want to solve a system of nonlinear equations using ...
user avatar
0 votes
0 answers
84 views

L2 norm optimization problem

I have an optimization problem where i need to find an image x, that is very close to x' such that: monitor(x') is valid but monitor(x) is invalid. (output is valid when the neural network output is ...
user avatar
  • 1
0 votes
2 answers
129 views

bin 2d array such that each bin contains equal number of samples?

I'm trying to bin a 2d array of points such that each bin has an equal number of samples contained in it. This would mean having bins of differing ranges and possibly shapes. I have seen this ...
user avatar
3 votes
0 answers
104 views

Python routine to calculate shape resonances of H2

I am currently doing a project in which my aim is to write a program that can be used to calculate single and multi-channel shape resonances. So I'm looking at bound states and quasi-bound states. ...
user avatar
-1 votes
1 answer
392 views

Integrate function with cumulative distibution function inside

I'm trying to integrate a function which is defined as func in my code below, a cumulative distribution function is inside: ...
user avatar
-1 votes
1 answer
98 views

Solve integral $ \int_{-\infty}^{\infty} e^{-x^2}dx$

i trying to solve this integral $$\int_{-\infty}^{\infty} e^{-x^2}dx$$ I'm using this CODE ...
user avatar
1 vote
1 answer
205 views

nquad Integration in SciPy

I am trying to self-learn SciPy and evaluate the following quadruple integral using scipy.integrate.nquad: $$\int_{0}^{1} \int_{0}^{1} \int_{0}^{1} \int_{0}^{1-x} (...
user avatar
  • 15
-1 votes
1 answer
2k views

ODEintWarning: Excess work done on this call (perhaps wrong Dfun type)

I was messing around with some numerical integration functions. I wrote an arbitrary differential equation to test my understanding, the code is as follows: ...
user avatar
0 votes
1 answer
204 views

How to compare 2D vector fields and minimize the difference?

I want to compare the field of two electrical currents and compare the resulting field to a magnetic dipol field and find magnetic momentum that minimizes the difference of the two fields. My current ...
user avatar
1 vote
1 answer
538 views

Trouble with backwards time integration in Python

I am struggling with a rather basic numerical integration task: Using Python's scipy.integrate.solve_ivp module to integrate an ODE sytem backwards in time. As a test, I am using the following ODE ...
user avatar
  • 143
14 votes
3 answers
6k views

How are scientific computing workflows faring on Apple's M1 hardware

The initial wave of reviews for Apple's M1 hardware are out, and there's lots of generic benchmarks and data on workflows on professional programs for creative users, but I haven't seen anyone talking ...
user avatar
  • 2,353
1 vote
1 answer
225 views

Help with modified bessel functions

I'm trying to parse the following expression (Eq. 35 in The Magnetic Field in the Vicinity of Parallel and Twisted Three-Wire Cable Carrying Balanced Three-Phased Current) in Python and calculate its ...
user avatar
3 votes
1 answer
298 views

Good languages/packages for interior point optimization with non-linear constraints?

I'm currently using Python's scipy.optimize package to perform parameter estimation for a system of 10 ODEs. I have some observed data, and I'm trying to find the set of parameters which makes the ODE ...
user avatar
  • 143

1
2 3 4 5