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

learn more… | top users | synonyms

0
votes
0answers
15 views

Laplace Operator with PyNFFT

I am learning to use PyNFFT for nonuniform FFT. I try to apply the laplace operator to functions. As a test, I want to take $f(x) = \cos( 2\pi i k \cdot x)$, calcualte (using the package) $\Delta f$ ...
4
votes
1answer
92 views

Test of 3rd-order vs 4th-order symplectic integrator with strange result

In my answer to a question on MSE regarding a 2D Hamiltonian physics simulation, I have suggested using a higher-order symplectic integrator. Then I thought it might be a good idea to demonstrate the ...
1
vote
0answers
40 views

Computation of plane wave scattering on semi infinite plane

I have attempted to code up the simple math required to plot the total field set up by an incident plane wave on a semi-infinite flat plate which can be found here. To summarise: $$\phi_s(r,\theta ) ...
1
vote
0answers
37 views

How to adjust scikit-learn FactorAnalysis() settings to get scores output similar to one from factanal() in R?

I'm new to factor analysis and I need to compute factor scores using Python. I have R code to compute scores and I want to ...
3
votes
1answer
147 views

Alternatives to numpy.einsum

Given an $n_1 \times \cdots \times n_k \times g \times g$ tensor $A$ (i.e. a collection of $g \times g$ matrices) and an $n_1 \times \cdots \times n_k \times g$ tensor $b$ (i.e. a collection of ...
1
vote
0answers
38 views

How to convert MPIAIJ to SEQAIJ matrix in petsc/petsc4py?

I am curious, if there is a function to convert MPIAIJ (distributed matrices in AIJ format) to a SEQAIJ matrix that lie on a single processor. It is possible to do such an operation for PETSc vectors ...
2
votes
1answer
143 views

How can I solve wave equation for circular membrabe in polar coordinates?

The original equation is $$\frac{1}{c^2} \frac{\partial^2 u}{\partial t^2} = \frac{\partial^2 u}{\partial r^2} + \frac{1}{r}\frac{\partial u}{\partial r} + \frac{1}{r^2}\frac{\partial^2 u}{\partial ...
1
vote
0answers
113 views

Differences in answers between Python and Fortran

I am translating a piece of Fortran code into Python and am testing my code with a certain test case. All the results differ with 0.04% compared to the Fortran results. This is a very small ...
2
votes
2answers
63 views

Scipy OdeInt solver with Neumann boundary conditions

I'm using scipy.odeint to solve Fisher-Kolmogorov equation: \begin{equation} u_t = u_{xx}+u(1-u) \end{equation} The code can be found here. From Ablowitz and ...
2
votes
0answers
23 views

Return derivative vector from odeint scipy function

I have the following function that I want to implement in scipy.integrate.odeint ...
3
votes
1answer
95 views

Simple Runge-Kutta Scheme for nonlinear PDE

I am new to this community as well as to scientific programming. I programmed a simple 4th order Runge-Kutta for the 1-D Cahn-Hilliard Equation for some first simple calculations on pattern forming ...
5
votes
1answer
119 views

Iterative Cunnigham correction in Millikans oil-drop experiment

I tried to write an analysis program in python for the Millikan experiment based on a paper from Jones "The Millikan oil‐drop experiment: Making it worthwhile" However, I cannot reproduce the ...
1
vote
0answers
59 views

Solving a system of 4 coupled PDEs representing variable diffusivity

I have four partial differential equations representing mass conservation of two compressible fluid phases (marked by subscripts $p1$ and $p2$) in two different continuum media (marked by subscripts ...
1
vote
0answers
75 views

My calculated laser pulse duration is too large. Where am I wrong?

I am currently writing a small Python script to estimate the pulse duration from the optical spectrum. At the end, the idea is to observe the effects of the spectral phase on the pulse duration and ...
1
vote
1answer
114 views

Implementation of 1D Advection in Python using WENO and ENO schemes [closed]

I'm trying to implement 1D advection solver using WENO and ENO schemes. \begin{equation} \frac{\partial u}{\partial t} + \frac{\partial f(u)}{\partial x} =0 \end{equation} where: ...
2
votes
2answers
130 views

Solve non-linear set of three equations using scipy

I need to solve a non-linear set of three equations using scipy. However, I do not have any clue on which algorithm is suitable for my problem from a mathematical point of view (stability, ...
1
vote
1answer
56 views

Convert Image of Map to 2D Grid in Python

I have this map showing the geography of Europe (below), and I wish to convert it to a matrix in python that would be a 2D approximation of this image where 0's would represent the ocean and 1's would ...
0
votes
0answers
31 views

Cyclic Coordinate Descent Optimization for Bayes Logistic Regression (Code Problem?)

I am trying to reproduce the CLG algorithm for the Laplace prior given in Genkin et al to find the MAP estimates for a logistic regression model. I am using Python (Anaconda 2.2) with Numpy to ...
1
vote
1answer
83 views

Improper Numerical integral

I am self teaching myself python and computational physics via Mark Newmans book Computational Physics the exercise is 5.17 of Computational Physics. I have to shift the limits of integration for an ...
1
vote
1answer
153 views

Solving nonlinear differential first order equations using Python

I would like to solve a nonlinear first order differential equation using Python. For instance, $$\dfrac{df}{dt} = f^4$$ I wrote the following program, but I have an issue with matplotlib, so I ...
5
votes
2answers
163 views

Python solvers for mixed-integer nonlinear constrained optimization

I want to minimize a black box function $f(x)$, which takes a 8$\times$3 matrix of non-negative integers as input. Each row specifies a variable, whereas each column specifies a certain time period so ...
3
votes
0answers
34 views

Python trust region optimization code that allows ellipsoid-shaped trust regions

Are there any high quality trust region optimization implementations that allow nonspherical ellipsoid trust regions, and are written in Python, or are easy to call from python? By nonspherical ...
1
vote
0answers
20 views

Execute commands when starting ipdb [closed]

I usually debug a python script by putting the following line into the source code: import ipdb; ipdb.set_trace() Then when I run the script, ipdb starts. Very ...
2
votes
0answers
107 views

Precession of Mercury Python simulation

I was trying to simulate the precession of Mercury based on the perturbed solution: $$\frac{1}{r}=\frac{m}{B^{2}}(1+e\cos\phi+3\frac{m^{2}}{B^{2}}(1+e\phi \sin\phi ...
0
votes
2answers
77 views

Computing the Madelung constant

I am self teaching myself python and computational physics via Mark Newmans book Computational Physics the exercise is 2.9 of Computational Physics I have to compute the Madelung constant. . I have ...
4
votes
0answers
82 views

Large meshing with tetgen

So I have a point cloud that I am creating a 3D flat rectangular surface from. I'm then turning it into a hollow box and connecting the corners by just dropping this surface mesh down. I need it to ...
1
vote
2answers
110 views

How to use the basic Sparse matrix operations (multiplication, .etc) in PyCUDA

I try to use sparse matrix operations in GPU in Python and now try to use PyCUDA with theano. But I can't find how to do sparse matrix and vector multiplication. I only got an example showing how to ...
1
vote
0answers
48 views

scipy.integrate.ode ignores boundary conditions

I am trying to solve the 1-dimensional diffusion problem numerically using method of lines: $$ \frac{\partial c}{\partial t} =D \frac{\partial^2 c}{\partial z^2},$$ where the right hand side is ...
0
votes
1answer
99 views

How do I correctly multiply vectors and matrices in Python and MATLAB?

I have been trying for 2-3 days now to get L2 regularized logistric regression to work in Matlab (CVX) and Python(CVXPY) but no success. I am fairly new to convex optimization so I am quite ...
0
votes
1answer
91 views
1
vote
0answers
53 views

Is this problem statement good for a GPU?

I am used to using GPU hardware for large scale matrix operations and vectorizing mathematical operations on a continuous space which has been discretized for numerical computation, but this is a ...
3
votes
1answer
33 views

divide an array using a changing length sequence of boolean var as index

i have an array of boolean variables. The array has a sort of structure, it's formed of many sequences of zeros and ones, sequences of different length. such as: ...
5
votes
2answers
464 views

Parallelizing a for-loop in Python

Are there any tools in Python that are like Matlab's parfor? I found this thread, but it's four years old. I thought maybe someone here might have more recent experience. Here's an example of the ...
2
votes
1answer
69 views

RK4 giving wrong result [closed]

I am trying to numerically solve a simple second order differential equation $x'' = -x$. I used a new variable $x'=v$, so I have two equations. While it seems simple, it somehow produces a result ...
3
votes
1answer
100 views

2D Poisson Solver for Taylor Green Vortex Problem

I am trying to write a 2D Navier Stokes solver using an RK3 for time advancement in python. For debugging, I have converted the RK3 to an Euler step for simplicity. Checking my divergence for my ...
1
vote
1answer
107 views

interactive mode vs animation - python [closed]

Is it better matplotlib interactive mode or matplotlib animation in terms of performance? I have a continous flow of data coming from the serial port. I get 2 measures let's say var1 and var2. I ...
1
vote
2answers
208 views

Python, numpy and complex functions (PDE's)

Update 4 I have almost given up on getting this right. This is the solution to the time-independent Schrodinger's equation, so the analytical solution is: $\psi(x,t) = \psi(x,0)e^{\frac{-iE ...
3
votes
1answer
161 views

Software for triangulating a point set (with restrictions)

I want to triangulate a point-set like the one below. I would like the triangulation of the point-set to have the following properties The triangles must have as vertices the black and orange ...
2
votes
0answers
62 views

Iteratively finding both left and right eigenvectors for non-symmetric complex matrix

I have a complex, non-Hermitian matrix $\mathbf{A}$, for which I need to find a few eigenvalues and eigenvectors in the generalised eigenvalue problem: $$\mathbf{A}\cdot \mathbf{x} = \lambda ...
0
votes
1answer
56 views

Scipy min warning meanings?

What does "Desired error not necessarily achieved due to precision loss" mean in the context of the scipy_fmin methods? I can't ...
4
votes
1answer
396 views

What is the preferred and efficient approach for interpolating multidimensional data?

What is the preferred and efficient approach for interpolating multidimensional data? Things I'm worried about: performance and memory for construction, single/batch evaluation handling dimensions ...
0
votes
1answer
73 views

Python plotting a function [closed]

Hi I am new to Python and I am using version 2.7. I came across a problem which requires me to plot a function: $$f(z) =\frac{z^3}{(1-z)^5 ...
1
vote
0answers
23 views

Using HMM for speech synthesis [closed]

I am trying to make a speech synthesizer using a Hidden Markov Model. I read the wikipedia page and several whitepapers and presentations (such as this one) but I am still not sure how this algorithm ...
0
votes
1answer
54 views

Mathematical error when attempting to represent step function using fourier series

I am attempting to work through a very simple problem. Determine the Fourier series expansion for the following heat PDE problem with ICS and BCS: $$ u_{t} = \alpha^2u_{xx}$$ $$ u(0, t) = u(L, t) ...
0
votes
1answer
108 views

Gonzalez algorithm

I'm getting confused about implementing the Gonzalez algorithm for k-center clustering. The algorithm is : let $S$ be a data set Choose $z_1 \in S$ arbitrarily. Number $z$ is center. (In general ...
0
votes
0answers
135 views

Extrapolating a function with increasing slope

I want to extrapolate data for a set of function values on a regular grid. To test different extrapolation routines, I decided sample data from a function, which I believe is the closest known ...
3
votes
2answers
450 views

literature on scientific computing

Maybe, this is a dump question. But anyway. I developed a finite difference code for a class of problems in dynamo theory. I used GNU Octave (MATLAB) which is good for testing. The problem size ...
0
votes
2answers
171 views

How to obtain a convergent solution iteratively for a linear system of equations? [closed]

I am working on a problem that requires an iterative procedure to solve a linear system of equations, the system of equations in matrix form is: $$\underbrace{\begin{bmatrix} r_{11} & r_{12} ...
4
votes
1answer
89 views

How to evaluate a series of derivatives?

Consider the function $$f(\mathbf{x}) = \sum_{n=0}^{N} a_n \left( (\mathbf{b}-\mathbf{x})\cdot \nabla \right)^n \frac{1}{r}$$ where $r = |\mathbf{x}| = \sqrt{(x-x_0)^2 + (y-y_0)^2}$ and $a_n$ and ...
0
votes
0answers
39 views

Phylogenetics in Python 3

I'm looking for a package supported in python 3, which would perform well in visualizing, manipulating and analyzing phylogenetic trees. Since Bio.Phylo isn't very good at this, I looked into ETE2 and ...