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

learn more… | top users | synonyms

0
votes
1answer
24 views

How do you think is it normal behavior for eigenvectors(PCA algorithm)? [on hold]

I have built a simple example to help me understand PCA, but I am unsure about the behaviour shown in eigenvectors' behavior. Can someone help me understand PCA better..
0
votes
0answers
29 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
127 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
105 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
52 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
20 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
90 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
117 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
54 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
74 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 ...
0
votes
1answer
98 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
113 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
49 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
28 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
121 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
155 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
30 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
16 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
98 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
62 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
67 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
94 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
46 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
93 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
76 views
1
vote
0answers
52 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
32 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
326 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
98 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
93 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
200 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
149 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
56 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
55 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 ...
2
votes
1answer
306 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 for construction, single/batch evaluation handling dimensions from 1 to 6 ...
0
votes
1answer
70 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
22 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
53 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
105 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
107 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
441 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
170 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
38 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 ...
0
votes
1answer
105 views

Temperature dependent 1-d conduction in Python?

I'm trying to write a Python code that is a numerical solver for 1-d heat conduction (using FVM) with a temperature dependent thermal conductivity. The solver has three functions I need to iterate ...
2
votes
1answer
152 views

optimization (using python) how to find the most suitable solver?

I have a fitting routine set up. It works, but pretty slow. I was wondering if there is a better method to use. I checked my (forward) code against some literature data and at least I do have no bugs ...
0
votes
1answer
80 views

What Python libraries do I need to do computational physics? [closed]

I need to install Python to do some undergraduate level computational physics (course, not research). What library do I need? Scipy only?
4
votes
2answers
71 views

Computation of multipole expansion of potential not converging

According to Beatson and Greengard's short course on FMM: ( Eq. 5.15 & 5.16 setting k=1, q=1 ) We can approximate a potential $\phi = 1/(r-R)$ using: $$ {1\over |\vec{r}-\vec{R}|} = ...