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

learn more… | top users | synonyms

0
votes
1answer
15 views

Tanh-sinh quadrature numerical integration method converging to wrong value

I'm trying to write a Python program to use Tanh-sinh quadrature to compute the value of \begin{equation} \int_{-1}^1 \frac{dx}{\sqrt{1-x^2}} \end{equation} but although the program converges to a ...
0
votes
1answer
41 views

Calculating periodicity of a pseudo random number generator (Middle-square method) [on hold]

Below is a Python code that calculates the periodicity of the middle-square method for a given 4 digit-numbers: ...
1
vote
0answers
72 views

Python - calculation time derivative and laplacien by finite differences

I would like to determine a temporal derivitive and a Laplacian by the finite differences method to solve the heat equation in a 1-dimensional case. My aim is to get the sources term that is why I ...
1
vote
1answer
50 views

How can a quadratic positive definite minimization be unbounded

I am minimising a diagonal quadratic matrix using CPLEX. All off diagonal elements are zero. It has 500 variables and 20 linear constraints plus each variable is constrained to be within 0 and 1 All ...
0
votes
0answers
15 views

F2Py with allocatable and assumed shape arrays as callback arguments

I would like to use f2py to overload some fortran subroutines in my main fortran program by python methods. Some of these subroutines receive an assumed shape array. I have found here how to make ...
0
votes
1answer
19 views

Border Mapping of Scatter plot

I have scatter plot and I want to trace the border of that. for example: Plot: and I wanted it traced: Or at least wanted to know the border points? Also, is it possible to detect if any ...
2
votes
1answer
74 views

Organizing a CFD program written in python

I've spent some time writing a spectral element solver aimed at solving fluid flow problems concerning the motion of self-propelled bodies. I've gotten to the point where the code has grown long ...
3
votes
0answers
58 views

Sparse matrix ordering in Python

I would like to implement custom, domain-specific algorithms for sparse matrix orderings. I am looking for Python packages for ordering sparse matrices. It would be nice to have: The underlying ...
4
votes
1answer
89 views

Python: Multistart optimization using parallel programming

[I previously asked my question on StackOverflow but this site may be more appropriate] In Matlab, I am currently using the MultiStart as an optimization algo in a parallel setup for a computer ...
2
votes
2answers
56 views

Python package for (adaptive) function plotting

Are there any mature Python packages that can plot functions, and possibly use adaptive sampling? I am looking to pass only a function (can be a numerical black box) and a range, and expect a plot as ...
3
votes
3answers
103 views

scipy.sparse: Set row/column in sparse matrix to the identity without changing sparsity

I'm using the SciPy sparse.csr_matrix format for a finite element code. In applying the essential boundary conditions, I'm setting the desired value in the right ...
2
votes
1answer
39 views

Using numpy arrays in Paraview programmable filter

How can I access a field in Paraview's programmable filter as a numpy array? I want to: Import an existing field as a numpy array Create a similar array for output Register it as a new field for ...
3
votes
2answers
79 views

scipy odeint: sum of conservative ode equations does not remain zero as it is being solved — is this normal?

Let us say we have the following equations: dy1/dt = f(y1, t) [1] dy2/dt = g(y2, t) [2] The equations are such that they are "conservative", i.e. the ...
0
votes
1answer
61 views

PyOpenGL/OpenGL Generating Cosmic NBodys

I am working on a Universe Simulator. I'm stuck on creating the dark matters webs of the universe that look like this: http://www.mpa-garching.mpg.de/galform/data_vis/sim3dnew-highres.png I am ...
1
vote
0answers
144 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 ...
2
votes
0answers
85 views

Polynomial Fitting with Least Squares using Numpy and Scipy

I am trying to fit data to a polynomial using Python - Numpy. The points, with lines sketched above them are as in the picture. I am trying to fit those points to a polynomial of 4. or 5. degree. ...
1
vote
0answers
40 views

learning Gurobi for MIP calculation [closed]

I am a new learner of Unix, python and Gurobi for MIP calculation. I basically finish reading the quick start guide in Gurobi website but still feel that I need more training to use this combination ...
1
vote
1answer
211 views

How do I integrate this function in python?

Essentially this is the problem: $\hat{F}(\omega) = \int_0^{\infty} f(s)e^{-i\omega s}ds$ The function $f$ is in general complex valued. I know this looks like the fourier transform but I don't want ...
1
vote
2answers
101 views

How to get ODE solution at specified time points?

The code below basically illustrates my problem. It is a test code for a pendulum. I solve it using a method suggested on ...
1
vote
3answers
166 views

Scripting for High Performance Computing

I would like links to resources which provide codes for scripting (preferably in python) for high performance computing. I'm looking for sample codes and examples which can, (1) automatically create ...
2
votes
3answers
72 views

importing PARI libraries ( in C++) with Python

I noticed that Python does not have a good datatype for rational numbers, certainly not for algebraic numbers like $\tfrac{1 + \sqrt{2}}{3}$ or the real root of $x^3 - 5x + 7$. They have the ...
1
vote
0answers
60 views

PageRank computation as the left principal eigenvector

I'm following the book here to compute PageRank: http://nlp.stanford.edu/IR-book/html/htmledition/markov-chains-1.html I built the transition matrix P as indicated in the book. Then I computed the ...
0
votes
1answer
61 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 ...
3
votes
6answers
926 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 ...
5
votes
3answers
127 views

plotting discontinuous functions

I need help plotting the Heaviside function: Real analysis often involves constructing bizarre functions which are intuitively correct, but ultimately wrong. See the great book Counterexamples in ...
1
vote
1answer
97 views

Time array from frequency array in FFT using Python

I have done a Fourier transformation of two signals (in time) $S_1(t),S_2(t)$ using numpy's fft which will give me $S_1(f),S_2(f)$. The corresponding frequency grid ...
0
votes
0answers
104 views

Free HFSS alternative to create geometry using python

I am using a python script to create wirebond interfaces in Ansys HFSS. Variables define the board, wirebond, and package geometry. To simulate a new wirebond, I just edit the geometry variables and ...
3
votes
1answer
121 views

High frequency noise at solving diffusion equation

I'm trying to simulate a simple diffusion based on Fick's 2nd law. ...
3
votes
2answers
85 views

Finding the minimum hamming distance between a bit vector and any pairwise intersection of multiple bit vectors

I'm looking for a way to optimize this procedure. This is the problem: I have a list of bit vectors $\mathbf{A} = [ a_1, a_2, a_3, ..., a_n ]$ I have a list of bit vectors $\mathbf{B} = [ b_1, b_2, ...
2
votes
1answer
96 views

Adaptive ODE algorithm in Python

I want to integrate a particle path in 2D using the integrate.ode module. Things that are a bit different in my case are that, I only want to integrate up to a ...
2
votes
1answer
61 views

Installing GPAW (Python DFT package) on a computing cluster

I'm in the middle of installing GPAW on a cluster but I'm running into problems building the "gpaw-python" interpreter, its job is to allow users to execute parallelised GPAW calculations. Following ...
3
votes
2answers
175 views

Finding eigenvalues of a complex symmetric tridiagonal matrix

I am trying to find specific eigenvalues and -vectors of a large complex symmetric tridiagonal matrix (at least 10000x10000, and ideally larger). I know roughly which eigenvalues I am looking for, so ...
3
votes
1answer
100 views

spectral decomposition in Numpy, sign difference

I am trying to follow along with an example from a book, but I get seemingly different answers depending on which spectral decomposition function I use in Numpy. I am trying to transform the Matrix G, ...
0
votes
0answers
53 views

Solving a non linear equation and iterating for various values in python

problem:Unable to solve a unknown for multiple known values in a non-linear equation ...
7
votes
3answers
775 views

Computational Physics: Python VS C/C++

Going to teach students of undergraduate level a course titled Introduction to Computer Programming. I am confused a bit. In Computational Physics scientists use C/C++ or Python or Fortran,CUDA ...
1
vote
0answers
87 views

BFGS Fails to Converge

The model I'm working on is a multinomial logit choice model. It's a very specific dataset so other existing MNLogit libraries don't fit with my data. So basically, it's a very complex function ...
5
votes
2answers
219 views

Pandas limitations and its alternatives in Python

I read somewhere that Pandas was first developed for the financial world, at least not especially for natural sciences (physics, biology and so on), so is there any similar data analysis Python ...
2
votes
2answers
232 views

Implement the Huffman code in Python or Numpy?

The Huffman code is a way of compressing data streams by encoding the more frequent items with shorter words. Here is a distribution on the letters A thru J and the code I obtained: ...
2
votes
1answer
125 views

Tikhonov regularization in the non-negative least square [duplicate]

I am working on a project that I need to add a regularization into the NNLS algorithm. Is there a way to add the Tikhonov regularization into the NNLS implementation of scipy [1]? [2] talks about it, ...
2
votes
1answer
190 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 ...
1
vote
2answers
166 views

How to plot orbit of binary star and calculate its orbital elements?

I have a set of dates, position angles ($\theta$) and angular separations ($\rho$) for visual binary star. For example: ...
10
votes
1answer
371 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 ...
0
votes
1answer
162 views

Successive over-relaxation not converging (when not done in-place)

I'm trying to find the potential given some boundary conditions using the successive over-relaxation method. I have 2 solutions: -One iterates over all elements and applies the formula ...
0
votes
0answers
38 views

bivariate spline class

Ken, Thanks for the answer on bivariate spline class at stackexchange, it helped me. I am newly in python, currently need to do a 2D interpolation. I used interpolate.interp2d from scipy, but I think ...
2
votes
3answers
178 views

Caculating the mean of vector accurately

I am having trouble with calculating a mean of vector with sufficient accuracy. My current solution which works but it quite slow and has unpredictable performance: mean_sum = mean = ...
1
vote
1answer
180 views

Using multiprocessing to assign values to a numpy array [closed]

I have a code similar to this: ...
6
votes
2answers
277 views

How to compute the wavelet approximation of a function?

For the function $f(x)=x$, how to compute the wavelet approximation using Haar basis? I'm new to wavelet, I'm looking for a package which will do something like this ...
1
vote
1answer
225 views

Newton's method in interpolation

I've seen that in Newton's method for interpolating polynomials, the coefficients can be found algorithmically using (in Python-ish): ...
4
votes
2answers
269 views

Big matrix multiplication on single machine

For example I have 2 matrices that can't fit in RAM. I need algorithm or library which can handle this.Preferably Matlab or Python. I think it can be some block matrix multiplication? Also I think ...
5
votes
0answers
151 views

Negative viscosity stabilized by fourth order terms

I am trying to solve a "Navier-Stokes"-type problem where the viscosity is negative. Of course this renders the equation unstable and thus I add a fourth order term, so the entire equation becomes: ...