instruction
stringlengths
43
28.1k
In the mathematical field of linear algebra and convex analysis, the numerical range or field of values of a complex $n\times n$ matrix $A$ is the set $$W(A)=\left\{{\frac {{\mathbf {x}}^{*}A{\mathbf {x}}}{{\mathbf {x}}^{*}{\mathbf {x}}}}\mid {\mathbf {x}}\in {\mathbb {C}}^{n},\ x\not =0\right\}$$ where $\mathbf...
I have a system of non linear differential equations in the form : $$\frac{dy_i}{dt}=\sum_j a_{ij} y_i y_j $$. I first tried to solve it with Python suing scipy.integrate.odeint but it is very slow. I'd like to solve it with an Euler method : $$y_i(t+\delta t)=y_i(t)+\frac{dy_i}{dt}\delta t $$. How should I chose the v...
I am working on a non-linear least squares problem with standard form, in which I need to calibrate a parameter vector $\Theta$ to a set of inputs $\mathbf{x}$ and outputs $\mathbf{y}$: $$\begin{align} & \min_\Theta ||R(\mathbf{x},\mathbf{y};\Theta)||_2^2 \\[4pt] &\quad \text{st: } R(\mathbf{x},\mathbf{y};\Theta):=\mat...
I'm trying to plot the solution of a numerical method using a vtk file in paraview. The structure is very simple, and I going to explain with an example. I have a mesh of the unit square [0,1]x[0,1] consisting on 4 squares (CELLS) of equal dimensions, and then this mesh has 9 POINTS. I have a constant solution on each ...
I have the velocity (vector) and pressure (scalar). This solution is constant in each CELL (square) of the mesh. I don't know why does not appear the pressure information when I open the file in paraview. I write an example of a mesh of the unit square [0,1]x[0,1] consisting on 4 squares (CELLS) of equal dimensions, an...
The idea of the method is to decompose the Navier-Stokes equation into the solenoidal and irrotational parts. $$\frac{\partial u}{\partial t}+u(\nabla \cdot u)=-\frac{1}{\rho}\nabla p+\nabla ^2 u$$ Discretizing the transient term and initializing the intermediate velocity $u^*$. $$\frac{(u^{n+1}-u^*) + (u^*-u^n)}{\Delt...
I've seen two different optimizers being used, but both with a different solver. One uses PULP_CBC_CMD and the other uses GLPKSolverMIP() can someone explain to me the difference in these two optimization strategies? Both of these optimizers are using to optimize daily fantasy sports lineups. It's basically a knapsack ...
I need to simulate a network of nodes. The weights of the edges are being given in a matrix . Due to the non-zero distances between the nodes, we consider time-delays, which are computed given the distances and an arbitrary velocity. The delay values have already been calculated. Given that $A$ is symmetric, for a $n$...
I was reasoning about the behaviour of the methods I'm using for my simulation and I noticed that, considering $h_s$ as the timestep over which I have unstable solutions and $h_a$ as the timestep where I start to have the expected accuracy, there's an interval of timesteps $h_a < h < h_s$ for which I don't have the exp...
Two random variables $X$ and $Y$ are distributed according to \begin{align} f_{XY}(x,y)= \begin{cases} x+y & 0\leq x \leq 1, 0\leq y \leq 1 \\ 0 & otherwise \end{cases} \end{align} I want to generate rvs of the given function using python. Is there any way to do it ?
Apologies if this is a trivial question. If that is the case I imagine I would benefit from someone explaining where my understanding is lacking. I am having some trouble interpreting the (putatively optimal) spherical codes listed on the website of N. Sloane here. For example, the first coordinate for the best known s...
I am trying to write an if statement that checks if 2 numbers are divisible before running some commands. The problem is, the rem function is giving some wrong results for certain number (2 is definitely divisible by 0.5, 0.4, 0.2 and 0.1 but the function says otherwise). A reproduction of the error is posted below t=2...
I am trying to get the structured mesh as shown in the figure. I have used the transfinite surface and curve to achieve the same. Though I get the structured mesh but I do not know how to do for body-of-revolution elements. May I ask, How to generate structured mesh for body-of-revolution elements using gmsh?
I have written a Matlab code to solve the equation $-u'' = f$ with conditions $u(0) = u'(1) = 0$ on the domain $x \in [0,1]$. I tested the code with $f(x) = -2, \forall x\in [0,1]$. I check the plot with one of element $n=8$, and the result $u = u^{h}$ agrees: However, I am testing the convergence error $L_{2}$ for th...
A spherical code, specified by the parameters $(n,N,t)$, is a set of $N$ coordinates on the $n$-dimensional unit hypersphere such that the set of dot products between any two unit vectors from the origin is larger than or equal to $t$. What algorithms can be used to generate candidate spherical codes? So far my google ...
Im working in comsol and needed help figuring out the objective function for the following situation (Comsol does have multiple objective function option as min max or sum of) I have 7 batteries connected in parallel all at the same voltage discharging. I need the current from each as uniform as possible with the maxim...
I was looking for the fastest converging method to integrate a family of functions. After some tries, an old-school colleague suggested me a method that he used to use in excel to perform such task. It relies on a simple procedure: sample the function at log-spaced sample such that $x_i = x_0 \alpha^i$ for $i=0...N$ c...
I wrote a program which iteratively transforms data using matrix multiplications. To minimize the number of large memory allocations, I use two roughly equal-sized std::vector<double>'s data and temp_data to store the current data and the new data respectively. For the matrix operations, I wrap each buffer into an Eige...
I am working on 1-D mass transient diffusion in a radial domain (spherical object) using finite volume method. My equation reads $$\frac{\partial C}{\partial t} = D\left[\frac{\partial^2 C}{\partial r^2} + \frac{2}{r}\frac{\partial C}{\partial r}\right]\, .$$ In a sense of conservative mass within the the radial domain...
I am playing with Galerkin Least-Squares stabilization to solve advection diffusion problem in the context of the finite element method. This works very well for steady-state advection-diffusion equation, even in the High Péclet limit, when the problems are solved in the steady state. The equation we solve is : $$\frac...
There are many rows of data in a database table, each of which contains many columns. ID (numeric - 12345, 12378, etc) Name 1 - AAA,BBB,CCC Name 2 - dd, ee, ff Name 3 - Ggg, Hhh, Iii The objective is to come up with rules based on a combination of these values to map to a set of groups. Group ID 1 - 1,000 There ...
I am trying to find the top k leading eigenvalues of a NumPy matrix (using python dot product notation) L@L + a*X@X.T, where $L$ and $X$ are a symmetric $n \times n$ and an $n \times d$ matrix, respectively, and $a$ is a scalar. According to the below text from this paper, I should be able to calculate these leading ei...
In this article: https://www.geometrictools.com/Documentation/IntersectionOfCylinders.pdf the writer says: "If you plan on using cylinders for bounding volumes in a real-time graphics engine—think twice. A better alternative to a cylinder is a capsule." Well, I am planning on bounding surfaces with cylinders (actaully ...
Normally, this boards sees a lot of traffic about the most efficient and most powerful solvers for huge linear equation systems. But this time, I have the opposite problem: I need to implement a solver for a linear equation system in a very limited programming system that offers only basic array functionality and no li...
Im trying to solve the Poisson equation in 1D: $$-u_{xx} = f(x), \hspace{6mm} u(a) = d1, \hspace{2mm} u(b) = d2$$Assuming a uniform partition such that $x_n = a + nh$, where $h = (b-a)/N$ and $n \in [0,N]$, and then discretising the problem with linear finite elements to obtain a linear equation system $\mathbf{A u} =...
I am analyzing the stability of 1D convection (advection) equation as shown in the picture. When I derive the equations as shown I want to get rid of the complex number. I`m asking if those stability plots make sense or not I want to get rid of a complex number
I have a scipy.sparse.linalg.LinearOperator object. I'd like to check if its associated matrix is symmetric without actually instantiating the matrix in the most computationally efficient way possible. Does anybody know a good way to do this?
I'm studying the dealii tutorial number 4,5 and I understand the workflow. I've also been able to find the EOC by using manufactured solution where $f$ is a smooth r.h.s. and $\alpha(x)$ smooth too. Now I'm interested in checking the EOC when $\alpha(x)$ is discontinuous (link to Doxygen docs of dealii) Let's say I hav...
I want an element as the one shown following. Nodes 6 and 8 are in the quarter position. Whether eight node quadrilateral element or six node triangle function can be used directly? If not, how to build a new shape function?
Can you please suggest a tool (software or online tool) that can analyze a submarine hull shape and give the total drag at a specific velocity. A simplified tool would work too, where I select a general geometry, then input the dimensions and speed, and get the drag force. I'm reading Submarine Hydrodynamics by Martin ...
Are there iterative methods for the solution of nonsymmetric linear systems $Ax=b$ that can take (theoretical or practical) advantage from knowing that $A+A^T$ is positive definite? These matrices are always nonsingular, but does this help the solution process, at least for some methods?
Question Is there any estimate for the scaling of the number of function calls in BFGS-optimization with the dimensionality of the search space? Specifically I am assuming a (free) expression for the gradient is supplied by the user so that no function calls are made in its evaluation. Note the gradient is only availab...
Consider the problem $$ \left\{\begin{array} {rcl} -\Delta u & = 0 & \text{ in } \Omega \\ u & = 0 & \text{ on } \Gamma_D \\ \frac{\partial u}{\partial n} &= g &\text{ on } \Gamma_R \\ \frac{\partial u}{\partial n} &= 0 &\text{ on } \Gamma_N \end{array}\right. $$ Where $g$ is a trace of a $H^{1+\varepsilon}(\Omega)...
We are currently in the process of implementing ports in our EM FEM simulation SW. We have come across the definition of boundary conditions for the ports, and we do not understand the equation for the boundary. In the book “The Finite Element Method in Electromagnetics” they start from the understandable idea of it be...
We know in Strang splitting that the splitting error in the steady state solution is proportional to $h^2$. I want ask 2 things: If this error in the steady state solution is the global error? If we are in in a previous step before the steady state solution for example $t=0.3$ sec (with $t_{total}=1$ sec) will be the s...
Suppose I know a function $f(t)$ and all its derivatives in $t$ in closed form. Given $a(0)$ and some $t_0>0$, I'm looking for an explicit integrator that can estimate $a(t_0)$, where $a(\cdot)$ satisfies the ODE: $$\frac{da(t)}{dt}=e^{-a(t)}f(t).$$ I'm willing to compute (in closed-form) any derivatives $f^{(k)}(t)$ ...
Are there any optimization algorithms aimed at finding a coinciding root and a (local) minimum of a multi-variable function f. Say it is known analytically that these should coincide for the function. I am interested in any such algorithm but more specifically for the case where f is continuous, at least twice differe...
$\frac{\partial C}{\partial t} + u \frac{\partial C}{\partial x} + w \frac{\partial C}{\partial x} = D \left(\frac{\partial^2C}{\partial x^2}+\frac{\partial^2C}{\partial y^2}\right)-C \cdot \left(\frac{\partial u}{\partial x}+\frac{\partial w}{\partial z}\right)$ How to avoid the negative concentration using FDM scheme...
I write to you all today in order to clarify if I implemented my model correctly into MATLAB. I will outline the following: analytical governing equations, my discretization for the equations and boundary conditions, and outline the implementation into ode15s. Ultimately, my problem with implementation is that steady-s...
I've noticed that some heuristics for it on my problem which work surprisingly well. I guess it ought to be systematically studied although I cannot find guides or overviews for it.
I have a bunch of ODEs I am trying to solve using ode45 in MATLAB. I have hidden the details of the equations to keep it simple (so as to build a general algorithm)! \[\frac{dR}{dt}= F_{1}(R,N) \quad\text{........................(Eq.1)}\] \[\frac{dN_{1}}{dt}= F_{2}(t) \quad\text{.............................(Eq.2)}\] ...
Crank Nicholson is a time discretization method (see 4th equation here). From what I see around, you can use different space discretization, such as Finite elements. But for the linear advection-diffusion equation, I see on books the von Neumann stability proof only when second-order centered spatial finite differences...
The Eigen::Map documentation here (https://eigen.tuxfamily.org/dox/classEigen_1_1Map.html) mentions the following: This class represents a matrix or vector expression mapping an existing array of data. It can be used to let Eigen interface without any overhead with non-Eigen data structures, such as plain C arrays or s...
I`m Analyzing the 1D convection equation (PDE) for stability, consistency, and accuracy. I know Both upwind schemes (explicit and implicit) show better stability with a higher number of waves for courant number less than one. The upwind scheme, in general, overcomes the problem of stability in the centered difference s...
When calling a kernel function, the number of threads per block should ideally be a multiple of the warp size. This yields more efficient use of resources and lower processing times. However, there seems to be another factor that periodically decreases the processing time. Shown below, the processing time gets offset e...
The Numerical Recipes Forum http://numerical.recipes/forum/ is closed, so I will record a tiny typo here for the benefit of others who may wonder about this. (This typo is not in the software, but only in the text, and is currently in the online version of the textbook at http://numerical.recipes/book): In Eq. 9.4.6 (...
I have implemented the heat method for geodesics: https://www.cs.cmu.edu/~kmcrane/Projects/HeatMethod/paperCACM.pdf When I run it I am getting a solution that, visually, seems correct: In this image, the arrows are the negated gradient, and the color is the distance, meaning that as a point's color goes towards white ...
The following question is about the implementation of molecular dynamics simulations with neighbor lists. In cases where the paths of individual particles are (i) stochastic and (ii) somewhat rough, without well-defined velocities, it seems reasonable (for performance' sake) to maintain neighbor lists in a way that ma...
In my C++ code, I need to evaluate the confluent hypergeometric function ${}_1F_1(a,b;z)$ with complex arguments in a special case. More precisely, I have to compute $$ e^{-i\phi}{}_1F_1(\ell+1+iZ,2(\ell+1),2i\phi)\, , $$ where $Z,\phi$ are real parameters and $\ell\geq 0$ is an integer. I know that this expression is ...
I have a rectangular matrix $A \in \mathbb{R}^{m \times n}$ import numpy as np import matplotlib.pyplot as plt from scipy.linalg import svdvals ,schur A = np.array([[0, 2, 2,4], [0, 1, 2,4], [1, 0, 1,4], [0, 2, 2,4], [0, 1, 2,4], [1, 0, 1,4], ...
I noticed that in most theoretic literature (Braess, Ciarlet, ...) for Finite Elements, the method is only described in a detailed way for simplex triangulations, while other forms of hexahedral methods are often omitted or only briefly mentioned. Is there any theoretical differerence between FEM theory of simplices an...
I am trying to model a 1-d advection-convection numerically, using an upwind scheme. I'm using the following equation to calculate the value of internal cells: $$C_x^{t+1} = C_x^{t} + D\frac{\Delta t}{\Delta x^2} ( C_{x-1}^t-2 C_{x}^t+C_{x+1}^t) + u\frac{\Delta t}{\Delta x}(C_{x+1}^t-C_{x}^t)$$ and I'm using the Robin ...
For the first-order explicit upwind scheme, it can be easily shown that, if one keeps the same grid size and progressively decreases the time step below the max allowed one (i.e. below CFL~1) the numerical diffusion increases with $(1-CFL$), see eq. 11.11 here). If I recall correctly, the same is also true for centered...
I have tried to solve the driven cavity problem with incompressible Stokes flow using the standard Crouzeix-Raviart non-conforming P1/P0 element (linear velocity, constant pressure, velocity-nodes at the midpoint of the edges). The velocity $u = (u_1 \; u_2) = (1 \; 0)$ on the top side of the domain and zero on the oth...
This is a belated follow up to my question here, because I didn't want to tack questions onto questions. According to the Mosek documentation here, one possibility for expressing $t \leq log(det(X))$, where $X$ is a symmetric positive semidefinite matrix variable to be optimized, as a semidefinite programming constrain...
I have two black boxes (representing some multi-physics but that does not matter), where box #1 takes some quantity T as input and produces some quantity P as output; and box #2 takes P as input and produces T as output. Suppose there is a steady-state equilibrium point $P_0,T_0$, and I can study the linear response fo...
When we work in numerical analysis, when the matrix is too big the computer runs out of memory (i guess it's ram memory). But how much space does a matrix of numbers (integer, single, double) use? I would like to know this to be able to determine how large the matrices can I compute in my laptop.
I am trying to do eigenvalue decomposition for a huge matrix larger than 788000×788000 for medical image analysis. The matrix is not sparse and every element in the matrix has a real value. And, for example, I want to obtain the first 20 largest eigenvalues and their 20 corresponding eigenvectors. The computer is not a...
I have to solve the equality between 2 matrixes 12x12 containing a lot of symbolic variables and with which I perform inversion of matrix. There is only one unknown called "SIGMA_O". My system is solved fastly when I take for example 2 matrices 2x2, the inversion is pretty direct. Now, with the case of 2 matrixes 12x12...
I am new to computational science and I am trying to wrap my head around how MMS works. I am solving the time independent Helmholtz equation as a simple test of the technique so my starting equation is following with homogeneous boundary conditions on a line segment $\Delta u +k^2u = F $ So I am supposed to take someth...
Following the representation used in [1, pag. 11] the solution of the Dirac equation in polar coordinates for energy $E$ is of the type: $$ \psi_{E\kappa m}(\bf{r})= \dfrac{1}{r} \Bigg( \begin{matrix} P_{E\kappa} (r) \chi_{\kappa}^m(\theta,\phi)\\ iQ_{E\kappa} (r) \chi_{-\kappa}^m(\theta,\phi)\\ \end{matrix}\Bigg)\ ,$...
Please note that I have nearly zero background on numerical methods. I understand the shift invert method as described in SciPy Tutorial The main argument of the above link is as follows. Suppose we want to solve a generalized eigenvalue problem $A\mathbf x = \lambda M \mathbf x$. Then, the shift invert method transfor...
I am trying to find the possible modes of a 2d rectangular waveguide by solving the equation, $$\Big(\frac{\partial^2}{\partial x^2} + \frac{\partial^2}{\partial y^2} + \gamma^2 \Big)\psi = 0$$ where $\psi$ would be $H_z$ or $E_z$ depending upon whether the mode to be solved for is TE or TM. My approach has been to use...
In the Numerical Recipes in section 5.7.- Numerical derivatives it's introduced de roundoff error of: $$ f^{\prime}(x) \approx \frac{f(x+h)-f(x)}{h} $$ as (with $h$ an "exact" number): $$ \tag{1} e_{r} \sim \epsilon_{f} \mid f(x) / h| $$ With the fractional accuracy comparable to the machine accuracy $\epsilon_{f} \app...
In the Numerical Recipes in section 5.7.- Numerical derivatives the choice of the step size $h$ in the numerical derivative should lead to a difference between $x$ and $x+h$ representable by an exact number. In C, the program steps are: temp = x + h h = temp - x Question: What is the meaning of these steps? Question:...
For a project I am doing, I have to solve the following system of differential equations numerically using my own code: $$ x^2K'' = KH^2 + K(K^2-1) $$ and, $$ x^2H'' = 2K^2H + \alpha H(H^2-x^2) $$ Here, $K$ and $H$ are the dependent variables, and $\alpha$ is a parameter which I have to vary from 0 to infinity. An anal...
I have this Mathematica problem that solves numerically the time-dependent Schrödinger equation in a box: sig = 1; bsize = 655; s = NDSolve[{D[u[t, x], t] == I/2*D[u[t, x], x, x], u[0, x] == (1/(2*Pi*sig^2))^(1/4)*Exp[-x^2/(2*sig)^2], u[t, -bsize] == u[t, bsize]}, u, {t, 0, 10}, {x, -bsize, bsize}]; wx[...
I am trying to solve a PDE of the form $$\frac{\partial u}{\partial t} = D \frac{\partial^2u}{\partial x^2} + k\ \ \ (1)$$ where only $k$'s first derivative with respect to $x$ is known $$\frac{\partial k}{\partial x}=-5u\ \ \ \ (2)$$ The boundary conditions are: $$\frac{\partial u}{\partial x}\left(t,x=0\right)=0\ \ \...
Consider the Poisson's equation in 1D with homogeneous b.c.'s $\mathrm{d} \phi/\mathrm{d} x=0$ with the seven point Laplacian (1 -54 783 -1460 783 -54 1 / 576 on a uniform grid). The resulting system is underdetermined because the solution is known only up to an additive constant. It only exists if the compatibility co...
I'm working with large scale constrained optimization problem. Some of my constraints can be non linear. Currently i'm using IPOPT. Quality is good by my Hessian computation too slow. It seems that i can implement hessian-vector problem much more effective. Unfortunately i cannot find how to use matrix free solver with...
Pseudorandom numbers are used massively in Monte Carlo methods, e.g. in physics simulations. The fastest random number generators, such as the xoroshiro or xorshiro families by Vigna (see eg here) are extremely fast, taking approximately three CPU cycles for generating a 64-bit random integer. Using parallel instances ...
I am currently using the HLLC solver to solve a 1-D system of Euler equations with very satisfactory results. However, there are cases where my solution produces low-density, high velocity states, which lead to strange heating at the origin. The heating is strange, as I am running with a $\gamma_{adiabatic}$ close to 1...
consider the Purely hyperbolic model problem $$u_t+au_x=0$$ $$u(-1,t)=u(1,t) \text{ (periodic boundary)}$$ $$u(x,0)=f(x)$$ with $f(y)=\sin(2\pi y)$. Furthermore the exact solution is given by $u(x,t)=f(x-at)$. I have implemented Forward–time backward–space (see page 1: http://www.etakl.net/notes_etc/numerical/schemes.p...
In many resources/videos I see comments being made along the lines of "and we can see here that we have a logarithm/exponential so this will be an expensive computation to make." (such as with the sigmoid activation function for a NN). What is behind these statements? A more specific example would be: what makes $e^{-x...
I have a first-order ODE $$ \dot{x} = a(t) \times x, \quad x(0) \in\mathbb{R}^3. $$ with $\|a(t)\| = 1 \;\forall t$. Consequently, $\|x(t)\|=\|x(0)\|$ for all $t>0$. I would like this to be reflected in the numerical solution of the ODE, so for time-stepping I'm looking at geometric integrators like Crank-Nicolson. Wha...
Spectral methods for pulse propagation usually require at least one FFT and one iFFT for each step. In my case I have a two-dimensional radially symmetric electric field (one dimension in space, one in time) describing a strongly focused light pulse (i.e. NA > 0.5) while being relatively long in time (> 1 ps). Due to t...
I've to perform a multi-fluid internal flow simulation with a code which intrinsically assumes periodicity on a given direction (say z) on a cartesian grid. Nonetheless, the problem I'm trying to solve does not involve this kind of condition, in fact the fluids are running out from the computed domain through the two z...
I am building a program to numerically solve the euler fluid equations based on finite volume discretization and am having trouble on a step where the eigenvalues of a cell need to be calculated according to the picture below. The eigenvalues for each cell are calculated by dotting the velocity vector with the normal o...
The $\rho u^2 + p$ term corresponds to the flux of $x$-momentum through some surface. According to this equation it would give a positive momentum flux if $u$ was positive or negative. This does not make sense to me as if the velocity was reversed the momentum flux should be negative. Why is this term positive?
Lately, I've been trying to solve numerically the 1D Kuramoto-Sivashinsky Equation using spectral methods. Let $\nu$ be the viscosity and $[0,L]$ the domain. The 1D equation is, $$ u_t + uu_x + u_{xx} + \nu u_{xxxx} = 0 \iff u_t = - uu_x - (u_{xx} + \nu u_{xxxx}) $$ Introducing the linear operator $$ \mathcal{L}u = - ...
I understand that you must reflect the velocity of the cell across the wall and store that reflected velocity in the ghost cell (which will then be used for flux/residual calculations), but that is the extent of my understanding. I have tried implementing this in my euler flow solver but I am still seeming to get issue...
Consider this non linear PDE: $$u_t + c(u^2)_x =\alpha u_{xx} \text{ , } -1<x<1 , t>0 $$ with $$u(-1,t) = g_L(t) \text{ , } u(1,t) = g_R(t) \text{ and } u(x,0)=f(x) $$ where the 3 functions(gl,gr,f) are known. What is a (explicit) numerical scheme to solve this problem numerically? c and $\alpha$ are known constant. L...
I am trying to figure out the questions from Multigrid Tutorial by Briggs. However I am stuck on these two questions. https://www.researchgate.net/publication/220690328_A_Multigrid_Tutorial_2nd_Edition (a) Show that the eigenvalue problem for the Gauss-Seidel iteration matrix, $R_{G} \mathbf{w}=\lambda \mathbf{w}$, may...
Suppose we want to minimize some convex functional $J(u)$ where $u$ lives in some Banach space $V$. The classical Newton method $$\mathrm d^2J(u_n)(u_{n + 1} - u_n) = -\mathrm dJ(u_n)$$ can be viewed as an explicit Euler discretization of the dynamical system $$\tau\;\mathrm d^2J(u)\frac{\mathrm du}{\mathrm dt} = -\mat...
I am reading section 9.3 in Leveque about stability. The explanations are very short and brief so I am asking for some help to understand and elaborations. The result of the section is that for FTCS method stability occures when $$dt/dx^2=k/h^2\leq1/2$$ Can someone please provide a more thorough explaination for his "p...
In my humble understanding MD simulations of systems with short-range(like LJ interactions) and long-range(electrostatic) has a computational complexity $O(N . log(N))$. What will be the computational complexity of a MC(monte-carlo) for the same system? Also what will be the complexities for both cases if electrostatic...
While studying mesh quality metrics in literature and software documentation, I've seen discussions about mesh orthogonality in Finite Volume Method (FVM) contexts, but not for Finite Element Method (FEM). For FEM, the metrics generally discussed and evaluated are skewness, smoothness and aspect ratio, for example. Thi...
I have a complex analytic function of which I want to take the numerical derivative. \begin{align} f(z) &\equiv f(x,y) = u(x,y) + i v(x,y) \\ \frac{d f(z)}{d z} & = \lim_{h \to 0} \frac{f(z + h) - f(h)}{h} = \frac{\partial u(x,y)}{\partial x} + i\frac{\partial v(x,y)}{\partial x} \end{align} Now, I can do the partial d...
For the simplest atom, its wave function is described by the PDE of Schrodinger equation: $$ -i h \frac{\partial u}{\partial t }=\frac{h^{2}}{2m} \Delta u + \frac{e^{2}}{r}u$$ The potential $\frac{e^{2}}{r}$ is a function of radial distance $r$. So, as a simple warm-up problem,let’s take the free Schrodinger equation w...
there is one thing I don’t understand. Is the tolerance to compute the step size updated at each timestep or fixed at all timestep. Also, when we look at the documentation and how the tolerance is computed (see picture) then we compute abs(y). Is y in this case the y value at the current timestep or the whole solution...
\begin{equation} \begin{aligned} \frac{\partial N}{\partial t} &+ \frac{\partial J}{\partial r} = 0, \\ \frac{\partial N}{\partial t} &+ \frac{\partial }{\partial r}(N \upsilon )= 0, \end{aligned} \end{equation} where $v$ is varying across the $r$ axis. For solving this equation, do I need the ...
I think the answer is probably no in the linear algebra community, but I'd say anything above $10^8$ and you're starting to lose too much precision, making the situation problematic. In some statistics settings, where they use OLS, I've seen it stated that even values over $20$ are problematic, but that seems pretty ex...
I have a two dimensional multi modal spatial signal generated from a MATLAB code using sinusoidal functions of different wave numbers, amplitudes and phases. What I want to know is that if I have the amplitude vs wave number plot of that signal, how can I extract the wavelength of the different spatial structures. For ...
I am building a neural network to approximate a data set which takes 3 inputs and gives 1 output. After testing the network using a few different iterations of hidden layers and adjusting optimizers and activation functions, there seems to be no significant improvement to the solution. This suggests to me there is some...
In the standard literature topics like numerical differentiation and numerical integration are usually discussed in detail. However, numerical integration is not the same as calculating the (true) antiderivative numerically. What is the reason nobody is discussing this topic? Is there simply no application for this? No...
Say I have a set of $n \times n$ matrices $A_1, ..., A_m$ as numpy arrays. I'd like to create the block matrix defined below. I'm looking for a clean, elegant, and easy-to-interpret way of doing this in numpy. I tried this with np.block: a1, a2 = np.full((2, 2), 1), np.full((2, 2), 2) out = np.block([[a1, (a1+a2)/2], ...
I have this simple question but I am trying to figure out why: Are matrices stored column-wise in MATLAB? If so then why? I theorize that they are stored column-wise because the memory does not have a rectangular structure but rather stores data as bits. I can't find any details on MATLAB's forum regarding this matte...
I am following this example from documentation of scikit-fuzzy library, but cannot figure out the math behind fuzzy rules there. Here is a short version of the example. Food quality was 6.5 (medium) Service was 9.8 (great) Food quality and service can have range [0, 10] Tip amount can have a range of [0, 25] Rules: I...
The question I need to solve is to maximize the satisfied constraints in linear programming. To be more specific, Suppose I have an infeasible LP problem, my goal now, is to find the maximum number of the constraints which I can satisfy. Put in a formulation way: $$ \max \sum_{i=1}^K x_i,\\ \text{s.t.}\ \mathrm{diag...
So I'm simulating a 1-dimensional random walk, with 1000 walks that each take 1000 steps. How do I calculate the average number of times that a walker returns to the origin and then the standard deviation of the number of times that a walker returns to the origin? I feel like I'm not understanding the logic of how to m...