All Questions
Tagged with numpy numerical-methods
23 questions
5
votes
1
answer
413
views
Implementing a joint differential equation and eigenvalue solver
I've written a Python script to solve a system of coupled differential equations and then use the results to solve an eigenvalue problem. The full problem is:
\$\frac{d^2}{dr^2} K(r) = \frac{K(r)}{r^2}...
2
votes
1
answer
241
views
Integration loop over multiple doping and temperature levels
I want to perform some calculations on a large dataset. The code can be found below, where I want to calculate the values for 'results_nr' over a large loop (1000 x 910) values. Can you help me out ...
2
votes
1
answer
220
views
Generating a matrix with each row having normalized weights
I just asked this question over Stack Over Flow on how to improve my code and reposting it here as someone on Stack Overflow recommended this platform.
I have written two python functions and they are ...
8
votes
1
answer
1k
views
Genetic algorithm to guess coefficient of a polynomial
I have tried to code a genetic algorithm to guess the coefficients of a degree 4 polynomial. The information initially provided is values of y = f(x) for different x using the original polynomial. I ...
5
votes
3
answers
268
views
Optimizing an implementation of the RKF method
This is an algorithm regarding the RKF method:
...
3
votes
2
answers
3k
views
Implementing a Steepest Descent Algorithm
I am teaching myself some coding, and as my first "big" project I tried implementing a Steepest Descent algorithm to minimize the Rosenbrock function:
$$f(x, y) = 100 (y - x^2)^2 + (1 - x)^2$$
The ...
1
vote
1
answer
1k
views
What would be the computationally faster way to implement this 2D numerical integration?
I am interested in doing a 2D numerical integration. Right now I am using the scipy.integrate.dblquad but it is very slow. Please see the code below. My need is to ...
4
votes
2
answers
2k
views
Trapezoidal rule for set of data
Here is the question from the book of Mark Newman-Computational Physics Exc 5.1
a) Read in the data and, using the trapezoidal rule, calculate from them the approximate distance traveled by the ...
7
votes
0
answers
330
views
Numerical integration in cython
I have a set of nested functions that I need to call multiple times. I know scipy.quad is pretty fast, but I will need to call the integrator recursively and want ...
6
votes
1
answer
203
views
Monte Carlo errors estimation routine
I would value your opinion on the following piece of code. I am rather new to both Python and Monte Carlo analysis, so I was wondering whether the routine makes sense to more experienced and ...
7
votes
1
answer
236
views
Implementing numerical integration in Python
I have this Python code that implements a rectangular numerical integration. It evaluates the (K-1)-dimensional integral for arbitrary integer \$K \geq 1\$
$$\int_{u_K = 0}^{\gamma}\int_{u_{K-1} = 0}^...
7
votes
1
answer
692
views
2d linear Partial Differential Equation Solver using finite differences
This is code that solves partial differential equations on a rectangular domain using partial differences. fd_solve takes an equation, a partially filled in output, ...
6
votes
2
answers
8k
views
Compute a numerical derivative
Since I could not get numpy.gradient() to compute a derivative successfully, I wrote a script to compute it manually. Running the script below will output a plot of ...
5
votes
3
answers
9k
views
Numeric double integration
I've made a simple program for numerically aproximating double integral, which accepts that the bounds of the inner integral are functions:
...
4
votes
1
answer
338
views
Numerical differentiation on sphere with Python
I have ported from Fortran to Python an algorithm that calculates the numerical derivative along the x direction (longitudinal) of a scalar function s on a ...