Tag Info

How to solve a second order differential equation (diffusion) with boundary conditions using Python

I have found that I must keep the value of dt near dx or the results become unstable This behavior you have noticed is known as the Courant–Friedrichs–Lewy (CFL) condition. Indeed, there are ...
Accepted

Python: Underflow vs. exp of large negative numbers

If your final result is of the order of magnitude of exp(-1000) $\approx 5 \cdot 10^{-435}$, then you are out of luck; no matter how you compute it, it will always ...
• 9,065

Why Is This Python Code Faster Than Fortran Wrapper with F2PY?

Shoutout to Kyle Mandli and Endulum who each contributed to this answer in the comments. First, I took Endulum's suggestion and removed the redundant reshapes. ...
Accepted

Why is my curve_fit not producing the covariance matrix and the correct values for the unknown variables?

The problem seems to be one of scaling. When I added the jacobian of the function an overflow warning appeared. Thus, I divided the data by their maximum values and it worked. Following is the code. <...
• 8,110

Going to try to move some of my scipy/numpy calculation to a new GPU, how to avoid disappointing results?

I buy the wrong CUDA GPU and the speed up is minimal or nonexistent. It is highly unlikely that your choice of GPU will have a significant impact on your speed-up unless your model is very big. To a ...
• 3,131
Accepted

Calculate determinant of unitary matrices based on SVD implementation

If you are prepared to go digging around in the fortran code: The SVD algorithm consists of a few parts: Bidiagonalization (usually using Householder reflectors) Use QR shifts to reduce the ...
• 1,189

Is there any way/any python function to calculate the condition number of the roots of a polynomial directly?

The condition number of a root $r$ of a polynomial $p$ is $$\kappa := \frac{\left\| p \right\|}{|rp'(r)|}$$ There is some arbitrariness in the choice of norm which affects the definition of the ...
• 2,021
Accepted

Is there something unique you can get out of a set of numbers?

One simple way to do this is with a product of powers of primes. Let the hash function be $f(x_{1},x_{2},\ldots,x_{n})=2^{x_{1}}3^{x_{2}}\cdot p_{n}^{x_{n}}$ where $p_{n}$ is the $n$th prime number. ...
• 17.7k

Why do problems arise in FFT for smaller value of df in Python?

The discrete Fourier transform for a signal of period $T$ with $N$ samples reads in its inverse or reconstruction form as $$y(t)=\frac1{N}\sum_{k=-N/2}^{N/2}c_k e^{i2\pi k\frac{t}{T}}$$ with ...
• 3,651
Accepted

How to solve the integral-like energy equation with Sagdeev potential numerically in Python?

A simple approach here would be to use the shooting method, by integrating from $\xi$=0 to infinity (some large value) the ODE written as $\frac{d}{d\xi} \phi = \sqrt{-2 S(\phi)}$ Due to the ...
• 2,088
Accepted

• 9,065
Accepted

Single hexahedral element stiffness matrix problem, help me find the mistake

Your intuition is right, the stiffness matrix should be singular. Actually, as pointed by @BillGreene, it has an eigenvalue that is zero. Ordering the nodes as follows (-1, -1, -1,), (1, -1, -1), (1, ...
• 8,110