FFT returns a complex array that has the same dimensions as the input array. The output array is ordered as follows: Element 0 contains the zero frequency component, F0. The array element F1 ...

Note the identity for the modified Bessel functions of the first kind, $e^z = I_0(z) + 2 \sum_{k=1}^{\infty} I_k(z)$ (Abramowitz and Stegun, Eq. 9.6.34, https://personal.math.ubc.ca/~cbm/aands/...

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 ...

If you have a single vector equation $\vec{F}(\vec{x})=0$ then you solve it by representing that state vector $\vec{x}$ as a set of amplitudes $[x_0,x_1,...,x_{n-1}]$ after discretization by your ...

Let's do it for the left boundary point $x=a$, and for simplicity assume $a=0$. To implement $u_x$=0 at $x$=0, assume the function $u(x)$ is even in the vicinity of $x$=0, and let the grid points be $... View answer 4 votes There is no finite limit for this series sum. Note that for each$n$the function$f_n$is positive definite,$f_n(x) > 0$within the semi-open interval$(0,\pi]$, and we can construct the lower ... View answer Accepted answer 4 votes Here is a corrected and slightly improved code, set up here for calculation of the full torus volume to verify the result. import numpy as np from scipy import random def func(x,y,z): return x**... View answer Accepted answer 4 votes The correct dynamic equations in the polar coordinates should be$ \dot{v_r} = \omega^2 r - \alpha/r^2 \\ \dot{\omega} = - 2 v_r \omega /r\\ \dot{\theta} = \omega \\ \dot{r} = v_r $Here is the ... View answer 4 votes You are almost there, just put$t$under the square root, and it will become$ \displaystyle\int_0^{1/1095} {\frac{dt}{\sqrt{(1+644.153t)(4.17 \cdot 10^{-5} + 0.145 t)}}}, $which eliminates the ... View answer 4 votes An elegant approach to avoid singularities of this type was proposed in Journal of Computational Physics, Volume 124, Issue 1, 1 March 1996, Pages 93–114 'The “Cubed Sphere”: A New Method for the ... View answer 4 votes Well, you can use Crank-Nicolson here but then you'll have to construct and solve a linear system for each time-step. That's easy to do but it would be much easier to use an ODE integrator that is ... View answer 3 votes Let's use the polar coordinates ($\rho,\theta$), then for the six vertices of the regular hexagon defined by$\rho$=1 and polar angles$\theta_i$there are the following equations$ f(\theta_i) = a_0 ...

We consider two thin infinite straight parallel wires at distance $2 a$ apart and carrying equal currents $I$ in opposite directions. We need to find an approximate ...

Just take the log of your function, and then take the derivative of it. If the actual function is indeed positive definite as in the example then it is identically the same as the quotient that we ...

For debugging the code, there is a set of analytic solutions here for several reduced models corresponding to subsets of terms on the right-hand side. These analytic solutions have to be reproduced by ...

The Numpy function $roll$ performs periodic shift of an array. Using it, the explicit time step for your PDE in a periodic domain can be simply implemented like this: u = u - (1/2)*(c*dt/dx)*(np.roll(...

The equation is $\partial_{t} \psi = \partial_{x} F(\phi)$ where $\psi = \partial_x \phi$ The time-integration can be done, e.g., by explicit time-stepping: $\psi^{j+1}_i = \psi^j_i + \frac{\tau}{2 ... View answer 3 votes A good way to approach this is by using existing powerful numerical packages such as PETSc. Look for PETSc examples of solving the Poisson equation, and that will be a good starting point. View answer 3 votes For this type of problem, the leapfrog time-integration method is a good choice, see details here. View answer Accepted answer 2 votes The cause of the numerical glitch has probably something to do with poor convergence of some series involved in the conformal map calculation for a particular location. However, here is how to use one ... View answer Accepted answer 2 votes Let's consider a 2D case, with two coordinates$X_1, X_2$and two derived quantities$Q_1, Q_2$. Using index 0 for a point where the partial derivatives are sought, and indices i={1,2,...} for some ... View answer Accepted answer 2 votes Assuming it is the$w$variable that has the range$[0,1-x]$from scipy.integrate import nquad def func(w,x,y,z): return w+y def range_z(): return [0,1] def range_y(z): return [0,1] ... View answer 2 votes Here is not exactly a tool but a convenient way to compare logical expressions graphically. Use electric circuits to represent your Boolean expressions: each resistor can be open gate (F) or closed ... View answer 2 votes This formula is correct on uniform grid (even for$\omega \neq $1 although convergence depends on$\omega$):$T[1:-1,1:-1] = \\ (1-w)*Tn[1:-1, 1:-1] \\ + \\ w*0.25*(Tn[1:-1, 2:] + Tn[1:-1, :-2] + Tn[2:...

If a certain velocity component is periodic with period $\tau$ that means that the corresponding coordinate, as a function of time, is a sum of a linear function and a periodic function with the same ...

The BOUT++ project http://boutproject.github.io offers a set of tools for finite-difference solution of systems of PDEs, primarily targeting fluid dynamics and plasma physics but not limited to those ...

Here is a brute force solution that would work no matter what is the discontinuity and nonlinearity in $c(x,t)$. Write your PDE as a system of two: $\dot{y}=z\\ \dot{z}=c^2(x,t) y_{xx}$ Now, ...

Let's consider the integral in 2D. Note that the domain where $f(x_1,x_2) = x_1 + x_2 - K$ is positive lies to the right of the dashed line $x_1+x_2=K$ in the sketch, so to account for the positive ...

We can rewrite the equation as $\frac{-2 f f'}{(1+f^2)^2} = \frac{f}{1+f^2}$ which reduces to $f' = - \frac{1+f^2}{2}$ The latter does not have $1+f^2$ in the denominator, so it should not have ...
Assume the equations are discretized on the $\tau$ grid, and introduce several column-vectors, using the notation where the superscript stands for the grid point index i $\in$ [1,...,n]. \$\vec{\tau}=\...