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

learn more… | top users | synonyms

2
votes
0answers
47 views

Iterative Cunnigham correction in Millikans oil-drop experiment [on hold]

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 ...
0
votes
0answers
34 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
46 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
77 views

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

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
94 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
43 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
24 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
78 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 ...
0
votes
0answers
82 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 ...
4
votes
2answers
131 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
26 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
15 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
92 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
58 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
54 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
76 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
41 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
86 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
63 views
1
vote
0answers
51 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
29 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: ...
4
votes
2answers
217 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
89 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
78 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
190 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
142 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
45 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
54 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 ...
1
vote
1answer
267 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
67 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
21 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
83 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
439 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
164 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
88 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
37 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
98 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
138 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
79 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
70 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}|} = ...
0
votes
0answers
91 views

Python: Boundary constraint issue with Scipy.optimize

It seems that I have an issue with my boundary conditions when I use the function [fmin_l_bfgs_b][1]. ...
1
vote
0answers
164 views

Stationary 2D/3D Navier-Stokes source code

Trying to solve stationary Navier-Stokes problem for incompressible laminar Newtonian fluid. I've found a couple solutions for instationary Navier-Stokes equations (like FeniCS examples or CFD ...
0
votes
0answers
90 views

Solving 10000, Non-Linear, Simultaneous Equations

Could anyone let me know if there is any optimization solver that I can use to solve about 10,000 simultaneous equations (most of which are non-linear) using Python? Please also advise if it is ...
3
votes
3answers
284 views

Dynamically ending ODE integration in SciPy

I have a light ray moving through space-time, i.e. a curve in R⁴, parametrized by some variable λ. The exact trajectory, i.e. the coordinate functions $x^μ(λ)$ of the curve are given by some ODE ...
1
vote
1answer
185 views

How to write a function-generating code in Python/MATLAB?

I want to write a code that generates a function I(t) that satisfies the following condition: $\frac{\big<I(t)^2\big>}{\big<I(t)\big>^2} > 2$ In other words, $\frac{\lim_{T \to ...
2
votes
0answers
76 views

4th order tensor [closed]

I'm new with FEniCS and Python and I'm stuck with this issue: is there a way to write a 4th order tensor in an easy way to implement? I have to compute the following stiffnes tensor: $A_{ijkl}= ...
5
votes
1answer
314 views

Numerical evaluation of an elliptic integral in python

Goal: I need to evaluate numerically an integral of the following form: $$ \int_0^\infty \frac{dx}{(a^2+x)\sqrt{(a^2+x)(b^2+x)(c^2+x)}} $$ where $a,b,c \in \mathbb{R}$ are in the interval ...