# Questions tagged [python]

A general purpose high-level programming language that emphasizes ease of code syntax and readability.

69 questions
Filter by
Sorted by
Tagged with
9k views

### Understanding how Numpy does SVD

I have been using different methods to calculate both the rank of a matrix and the solution of a matrix system of equations. I came across the function linalg.svd. Comparing this to my own effort of ...
• 519
566 views

### Eigenvectors of a small norm adjustment

I have a dataset that is slowly changing, and I need to keep track of eigenvectors/eigenvalues of its covariance matrix. I've been using scipy.linalg.eigh, but it'...
• 1,529
10k views

### Python Finite Difference Schemes for 1D Heat Equation: How to express for loop using numpy expression

Hello all, I've recently been introduced to Python and Numpy, and am still a beginner in applying it for numerical methods. I've been performing simple 1D diffusion computations. I suppose my ...
51k views

### Python vs FORTRAN

Which one is better: FORTRAN or Python? And I guess that in both cases you need Gnuplot, am I right? I'm working on a Windows machine at the moment. I'd like to use it to get numerical solutions for ...
• 413
5k views

### When is Newton-Krylov not an appropriate solver?

Recently I have been comparing different non-linear solvers from scipy and was particularly impressed with the Newton-Krylov example in the Scipy Cookbook in which they solve a second order ...
• 5,299
5k views

### Poisson equation with Neumann boundary conditions

I'm trying to solve the Poisson equation with pure Neumann boundary conditions, $$\nabla^2\phi = \rho \quad in \quad \Omega\\ \mathbf{\nabla}\phi \cdot \mathbf{n} = 0 \quad on \quad \partial \Omega$$...
• 241
10k views

### Solving coupled differential equations in Python, 2nd order

I have a system of coupled differential equations, one of which is second-order. I am looking for a way to solve them in Python. I would be extremely grateful for any advice on how can I do that! $k$...
• 173
2k views

• 207
986 views

### Compute lengths of the longest edge of each cell

Having mesh = UnitSquareMesh(2, 2) Q = FunctionSpace(mesh, 'DG', 0) this works as expected ...
• 917
2k views

### Python: Grid with step control ODE solver

I have a problem in physics formulated via an ODE. Now I like to solve it numerically using Pythons scipy.integrate and the therein complex_ode. I figured out how and it works but now I like to ...
• 267
231 views

### Going to try to move some of my scipy/numpy calculation to a new GPU, how to avoid disappointing results?

update: I've refactored the question based on helpful advice in the linked meta. I'm a heavy user of Python's NumPy and SciPy (and not much else) and for years I could run anything I need on my laptop....
• 872
224 views

### Evaluate 3D Shape Descriptor

I'm trying to create my own 3d shape descriptor, the idea is that how I may evaluate how much my descriptor is well and good? What I checked is that they evaluate descriptors through shape matching, ...
• 43
441 views

### Convolute a gaussian kernel with a large array of off-grid centroids without looping? (how to make "A Thousand (Gaussian) Points of Light" )

For a finite object size diffraction simulator, I need to generate arrays which are the sum of thousands of instances of a Gaussian (or other) 2D kernel at centroids that will not fall in any ...
• 872
1 vote
440 views

### vtk python visualizing scalar data on quad mesh

I'd like to visualize scalar data located on the nodes of a quad mesh (2D) using VTK in Python3. The closest example I've found is vtk quad mesh, but it only seems to visualize the mesh, not data on ...
• 448
1 vote
13k views

### Using scipy.quad to calculate difficult integral

When evaluating the integral below in python using scipy.quad I get the following warning: UserWarning: The maximum number of subdivisions (50) has been achieved. If increasing the limit yields no ...
• 873
1 vote
228 views

### How to generate the convolution of f(x, y) with a parametric function g(t), x(t), y(t) in Python? (Something better than this brute-force sum)

The answer to Convolute a gaussian kernel with a large array of off-grid centroids without looping? (how to make "A Thousand (Gaussian) Points of Light" ) involves summing a 3D array over ...
• 872
1 vote
4k views

### Python implementation for Frechet Distance

I am working on a trajectory analysis project using python and its data science related libraries. I am planning to implement Frechet Distance algorithm for trajectory analysis, each trajectory has ...
• 121
442 views

### Is it possible to partition 2D data into bins such that each bin contains the same number of samples?

I am trying to sort data following a bivariate distribution into a numpy histogramdd, where each bin should contain the same number of data points (to the nearest whole sample). I expect that some ...
• 117
2k views

### How to express this complicated expression using numpy slices

I wish to implement the following expression in Python: $$x_i = \sum_{j=1}^{i-1}k_{i-j,j}a_{i-j}a_j,$$ where $x$ and $y$ are numpy arrays of size $n$, and $k$ is a numpy array of size $n\times n$. ...
• 1,183