instruction
stringlengths
43
28.1k
My question is: how come that certain formulations of the wave equation can be time integrated more efficiently then others? Le me expand a bit on that. Consider the wave equation: $$ \frac{d^2 p(t,x)}{dt^2} -c^2 \frac{d p(t,x)}{dx^2} = 0 $$ with boundary conditions $ p(t,0) = \sin(\omega t) $ and initial conditions $ ...
I wanted to multiply two simple (big and sparse) matrix with numpy. And I saw that the calculation fails when matrices are too big. If i take $X$ a random vector (size $n$). With pandas, I transformed this vector with get_dummies and I obtain a matrix $M$. One can verify that $M^\top \cdot M$ is a diagonal matrix and ...
I am trying to implement Poisson image blending as in the paper Poisson Image Editing. This is the task of filling in a masked region of an image by minimizing $$\min_f\int_\Omega \left | \nabla f - \mathbf v\right |^2$$ with $$f|_{\partial\Omega} = f^*_{\partial\Omega}$$ which is equivalent to the Poisson problem $$\D...
I have started investigating in mostly Runge Kutta and Runge Kutta Nyström methods and there one of the only differences between the methods of the same type is their Butcher tableu. For the most common ones (RK4, RKF45, DOPRI54) they can be found on Wikipedia but otherwise I find it hard to find them. I could always g...
I find myself in the position of having to solve $-\Delta u = f$ on a subset of Cartesian grid points that don't necessarily form a cuboid domain subject to a homogenious Dirichlet boundary condition ($u = 0$). The Laplacian filter I require is the standard 7-point stencil for 3D. Now, for a cuboid domain, I know this ...
Is it necessary to reorder nodes (using Reverse Cuthill-Mckee algorithm, for example) if I am already using a CSR or CSC storing technique? Because since CSR/CSC stores only non-zero elements I guess reorder wouldn't be much advantageous.
For a given integer $n\in\mathbb{N}^*$, I want to find a pair $(x,y)\in{\mathbb{N}^*}^2$ such that $x*y=n$ and $|y-x|$ is as small as possible. A naive algorithm I found is : for k = floor(sqrt(n)) to 1 step -1 if n/k is integer then return (k, n/k) end if end for Although I am almost certain there is a mo...
I am supposed to do black-box modeling, I need the input and output data for training, however, the authors didn't agree to share the raw data with me, I can only use their publication where these attached images are given below. Of course, I do understand the curve, however, I don't know how to create raw data from fi...
I have a set of $n$-dimensional vectors, and would like to choose $m$ of them to become the columns of an $n\times m$ matrix. I would like to choose the subset that maximizes $|A^T A|$, where $A^T$ is the transpose of $A$ and $||$ is notation for the determinant. Can this be done faster than trying out each of $n \choo...
This is part of the code in matlab for a random-walk simulation. To test the code, I'm using steps=[30]; there will be more values, but I want to run it for 1 trial to decrease code processing. log_steps = log(1:steps); <--- corresponds to the log (steps vector) for the x axis of the plot log_AVG = log(d_AVG); <----...
I'd like to use the syms package to do some algebra for me, but the baseline assumption seems to be that variables are scalars. I would like to denote some variables as matrices. This will change the symbolic output/calculations. For example: inverse is not division, operations are not all commutative, and things can b...
Why not just Lagrange polynomials basis functions
https://en.wikipedia.org/wiki/Dormand–Prince_method I want to implement the Dormand-Prince 4(5) version to solve Initial Value problems. Using regular notation I have $A$ matrix and the $c,b,\hat{b}$ vectors. I also have the error tolerence of $ETOL$ absolute error tolerence $ATOL$ and relative error tolerance $RTOL$ A...
I have a object which is static, the camera is static and light source is moving. How can the depth mask be calculated ? Concept is to use - calculate height from shadow length Lets imagine a have more images likes this. And light source is moving, which is sun, and from time it's position, distance, orientation can b...
We have $X=[\mathbf{x}_1,\mathbf{x}_2...,\mathbf{x}_n]\in\mathbb{R}^{d\times n}$, $H=[\mathbf{h}_1,\mathbf{h}_2...,\mathbf{h}_n] \in\mathbb{R}^{d\times n}$, and $d<n$. $H$ has rank $r\leq d$ and $X$ has rank $d$. Assume we have $\|H\|_F\leq C$ and $\|\mathbf{x}_i\|_2\leq R$, where $\|\cdot\|_F$ and $\|\cdot\|_2$ are t...
After reading the matrix stability chapter (10) of Hirsch [1], I decided to dive in the reference list of the chapter. One of the papers [2], which is cited as reference shows an very interesting approach to stability analysis. The paper shows an stability evaluation of a real world flow solution of a NACA0012 airfoil ...
I'm trying to solve a Schrodinger equation of the form $i\frac{\partial}{\partial t}\psi=-\frac{\partial^2}{\partial x^2}\psi + (V(x)+\alpha|\psi|^2)\psi$ using the split-step Fourier method implemented via MatLab code. In order to make sure it works, I'm testing my code with $V(x)=x^2,\alpha=0$ and $\psi=Ce^{-x^2/2}$ ...
If I have a real positive definite matrix $A\in\mathbb{R}^{n\times n}$, and denote its eigenvalues as $\lambda_1\leq \lambda_2 \leq ... \leq \lambda_n $. Define the function as $f(A)=\sum_{i=1}^{k} \lambda_i$ for a constant $k<n$. What do we know about the convexity of $f(A)$? Is it convex or concave?
I have a function $F(\vec x)$ of many variables (let's say in the order of hundreds of thousands). I need to compute the determinant of the Hessian matrix at the point $x_0$. Is there a way to compute some approximation of it without explicitly computing the determinant? I want to compute this value because it appears ...
I need you to help me understand the Singular Spectrum Analysis algorithm. I already read a lot of articles about the subject but they never answered my questions like what is the mathematical reason for embedding the time series into a trajectory matrix and why applying the SVD gives us access to such trend and period...
I am running into a strange problem when solving the 2D compressible Euler equations on a inclined wedge. To elaborate, my top boundary condition seems to emitting some type of instability. I have tried using Neumann BCs for the u,v velocities, but the issue still persists. I am using a 2nd-order finite volume method ...
I have this non-linear partial differential equation. $$ \frac{\partial C}{\partial t}=\left(\frac{\partial C}{\partial x}\right)^2+C\frac{\partial^2 C}{\partial x^2} $$ I want to use the finite difference method to solve it either with the implicit method or the Crank-Nicolson method, witch I have done with linear PDE...
Hoping I'm not misunderstanding the concept here, but it is my understanding that Voronoi Diagrams and Delaunay Tesselations are 'dual' to one another, owing to the fact that each' solution makes computational of the other's solution trivial. What I'm looking to understand is, why? I mean, it obviously happens, but is ...
In Higham's Accuracy and Stability of Numerical Algorithms, Chapter 15, algorithm 15.3 and 15.4: The topic is ostensibly condition number estimation, but these algorithms show how to compute $\gamma$ such that $\gamma < \left\|A\right\|_{1}$. But if I have a matrix $A$, I already know how to compute $\left\|A \right\|_...
I have a matrix $A\in\{0,1\}^{d\times n}$ and $rank(A)=d,d<n$, and another matrix $X\in \mathbb{R}^{d\times n}$, but I do not know the rank of $X$. What can we say about the rank of their Hadamard product $rank(A\odot X)$? And what if $rank(A)=k, k<d$?
When gmsh uses higher-order tetrahedral elements, there is an underlying Lagrange basis used to specify the map from reference space to the element. I'm trying to load a gmsh mesh of 3rd degree tetrahedral elements, but I can't seem to find any precise documentation on the location of the nodes that define the Lagrange...
Is the theory of 3d finite element method just an assembly of 2d finite element analysis by putting planes on top of each other, or, a much more comple and different theory applies for 3d, with respect to 2d? For example I am reading a dam design manual from 1970s, where computers were low power and FEM was gaining new...
I'm using BFGS to optimize a smooth but non-convex function $f$ that is computed by a simulation. The simulation also gives me a semi-analytical gradient $g$, which is verified by the numerical gradient. As $f$ is non-convex and I am using a penalty function to enforce bound constraints, I do not expect to find a globa...
I am using PETSc and libmesh to solve a simple linear elastic problem with quite complicated geometry, using linear tetrahedral elements. I am always using the KSP CG as the solver. I noticed that for certain meshes, the block-Jacobi (PCBJACOBI) preconditioner would fail to converge (DIVERGED_INDEFINITE_PC) but Jacobi ...
I am trying to animate a plot of two distinct points (blue and green points) moving about the complex unit circle using Python's Matplotlib library. The problem I am having is that the animation does not remove and update the previous data points but rather sequentially smears it on the unit sphere as in the accompanyi...
I am trying to solve a non-convex optimization problem using fmincon(). At each iteration, I am iteratively looking for the optimum value and when the termination criterion is satisfied, I keep this value as an initial value for fmincon() and run the code for the second iteration. The problem is the code is running fin...
I would like to solve the following equations simultaneously and numerically for all $X, Y, Z, W$ where i = 1:Nw, j = 1:Nl, k = 1:K. $W_\text{net1}$, $W_\text{net2}$, $m_\text{net1}$, and $m_\text{net2}$ are given. How can I apply solve() or any other function to numerically find the values of $X, Y, Z, W$? Here is th...
I am trying to find the solution of linear advection equation of the form: $\frac {\partial c}{\partial t}+u\frac {\partial c}{\partial x}=0$ $c(x,0)=0$ $c(0,t)=\{c_0 \ \text{for}\ t \leq t_1 \text{and}\ 0 \ \text{for}\ t>t_1 $ Can anybody help me?
Let's assume, that we have damped harmonic oscillation of a body in the form of a cone, immersed in a liquid. Equilibrium condition of the body is: $$m\overrightarrow{a} = \overrightarrow{F_\text{res}} + m\overrightarrow{g} + \overrightarrow{F_{a}}$$ We can describe oscillations with the following differential equat...
Please consider the assignment I have uploaded on the picture. I am confused about the functions $g_L(t)$, $g_R(t)$ and $\eta(x)$. What are they and how do I find them... My question: Is it possbile to find out how $g_L(t)$, $g_R(t)$ and $\eta(x)$ look like purely based on this formulation? In order to solve this prob...
I'm creating too much throw away code for interfacing with the scipy optimize package in a user friendly way. (See code below for example of interruptible optimization that keeps last optimization value after a KeyBoard interrupt) def monitoring_callback(x): global callback_dict callback_dict['cached_results']...
I have proposed an algorithm for a scheduling problem in a submitting paper. In the revision, the reviewer asked us to compare with another algorithm from the literature. Our algorithm is in MATLAB, and the comparing one is in C++, and the code is publicly available. We did not re-implement the C++ code, to avoid any d...
Background: I have an equation which looks like as follows: $W \times P = R$ $$\left[\begin{array} &{1}&{0}&{0}&-\frac{w_{1}}{w_{o1}} &\dots &{0} &-\frac{w_{1}}{w_{0} } \\{0}&{-\frac{w_{2}}{w_{o2}}}&{1}&{0}&\dots &{0} &-\frac{w_{2}}{w_{o2}} \\ &&&& {\vdots} \\ {1} & {c-1} & {0} & {0} &{\cdots} & {0} & {0} \\ {0} & ...
I have proposed an optimisation algorithm which I claim has improved upon the previous algorithm in a number of ways. One of these claims is that my proposed solution requires no explicit SVD and psuedoinverse calculation which I claim is good, since in my case perturbations are important, and I believe these routines...
I'm trying to find the capacitance matrix for a small array of metal boxes in air using Comsol 5.4. The geometry presented here is a simple geometry that recreates the problem I'm experiencing. Simulation Settings: What Works For now I set my geometry length unit to "um". To create my block array I first created a 40 x...
I'm a beginner user of FEniCS and still struggling with some of the basics. Specifically, I have some issues doing the tutorials in the Langtangen-Logg book Solving PDEs in Python - The FEniCS Tutorial Volume I. I think some of the problems are due to the different versions of the book and my installation (2019.1.0). O...
Based on the Navier-Stokes equations and a few parameterizations, the horizontal steady-state wind $u(z)$ within a forest of height H satisfies: $$ a\left(\frac{du}{dz}\right)^2 + b\frac{du}{dz} \frac{d^2u}{dz^2} + cu +d\frac{du}{dz} + eu^2 + f= 0,\quad\text{for}\quad 0<z<H. $$ The coefficients $a,b,c,d,e,f$ vary with ...
EDIT: I am trying to specify my Question. Also I am not going to clearify which spaces I use, because I am only interested in the basic idea. I am looking at a standard elliptic second order PDE: \begin{cases} Lu & = f & \text{in} &\Omega \\ \quad u & = g & \text{on} & \Gamma \subset \partial\Omega \end{cases} where ...
This question is originally posted in Quant.StackExchange but has been unanswered for some time so I ask in here. To make this simple let us consider the Geometric Brownian Motions (GBM). My questions: 1. How can I show that the Euler-Maruyama Method is convergent using GBM? 2. How can I determine the order of converg...
I want to know the time complexity of following code Say I have a list unique_element[] There is an array which contain elements {4,5,2,4,7,8,1,5,9,8,1} Now as per my code I want to find out the unique element from this array and store this element into the unique_element[] list for(int i=0;i<arr.length.i++){ loo...
I recently encountered a formulation of the meta-phenomenon: "two is easy, three is hard" (phrased this way by Federico Poloni), which can be described, as follows: When a certain problem is formulated for two entities, it is relatively easy to solve; however, an algorithm for a three-entities-formulation increases in ...
I need to solve capacitated asymmetrical vehicle routing problem with time windows on ~30k points. Time limits for calculations are 2 hours. I've tried using Clarke and Wright savings algorithm, it is very fast but too inaccurate, and I've tried using LKH-3 util for solving my task. It finds almost optimal solution, bu...
I'm describing some work on my website, and I'm wondering if my math modeling and computer simulation work is described ok: I say math modeling and numerical simulation. Should I say "simulation" and leave out the "numerical" part since it's understood? What about "math modeling"? I see some people use the term ...
I have built an ANN model with 5 hidden layers and 100 nodes in each layer to solve a multilabel classification problem. After the first run, I get a training accuracy of ~66% and a test set accuracy of ~55%. When I ran the code with 1000 nodes in each hidden layer,the training accuracy improves to ~98% but the test se...
After long hours of searching for an answer I thought it might be better to ask the community. The problem I have is that I need to convert STL files to mesh files. I know that I therefore need to add a volume to the surfaces from the STL file. When I do it manually in gmsh Modules->Geometry->Elementary entities->Add-...
In DFT, forces are calculated using the Hellman-Feynman theorem, such that: $$\frac{\text{d} E_\lambda}{\text{d} \lambda} = \left \langle \psi_\lambda \left|\frac{\text{d} \hat{H_\lambda}}{\text{d}\lambda} \right |\psi_\lambda\right \rangle$$ The primary question I have is: Assuming planewave DFT using the PAW method (...
I am trying to study the stability of numerical discretization schemes using the Jacobian matrix of the residues with respect to the vector of conserved variables. For a simple diffusion equation discretized with central difference scheme, the RHS can be written as: $RHS=\nu\frac{u_{i+1}^{n}-2u_{i}^{n}+u_{i-1}^{n}}{\De...
Are there well-established approaches to single-variable multimodal optimization? Given $f:\mathbb{R}\rightarrow\mathbb{R}$ that: has several local minima within a given range of interest $[a,b]$ is quadratic in the neighborhood of local minima and furthermore given that: $f$ is expensive to evaluate $f'$ is not ava...
Consider a system of PDEs $$ \begin{cases} u_t = \nabla \cdot (D(u)\nabla u) + \frac{c}{K_U+c}u-ku\\ c_t = d_c\Delta c -\frac{\nu_U c}{K_U + c}u \end{cases} $$ with some boundary conditions. Here, $D(u)$ is a diffusion coefficient which depends on $u$; $K_U$, $\nu_U$ and $k$ are some constants. $D(u)$ can be defined as...
Hello fellows and folks. I have been looking to do this for 1 month and still cannot find the way to do it. Here’s what’s going on: I have a csv file called ratings.csv with the following structure: userID, movieID, rating 3, 12, 5 2, 7, 4 The rating scale goes from 0 to 5 stars. I want to be able to plot the spar...
I have some discrete data, non-equispaced in $x$, $y=f(x)$. I want to use a numerical finite difference method to calculate the second derivatives of $y$, at some point. I am using the Fornberg method, which is well described here and here, and working in Fortran. Program fornberg implicit none integer, parameter ...
I am new to METIS and trying to use it in my fortran code. I read the manual online. But still, I am not sure about how to implement it my code. I tried the test cases in the graphs directory. For example, I partitioned the 2d mesh metis.mesh by using mpmetis -gtype=nodal metis.mesh 4. And it gave me two output files:m...
What I wanna solve it the problem following ( by quadrature method ) I want to get two arrays of data ( z & tau ) from z[0], tau[0] to z[2249], tau[2249]. Since the integrand diverges at z=0.9, 1.125, I need to tame the divergence, but firstly, I want to make simple scheme of my program. Following is my C language cod...
I have a first order system which is described by the following differential equation: dx/dt = -a*x + b*u where u is the input u = 5*sin(3*t). In order to get the states x(t) of the system we are given that a = 2 & b = 1. I have written the following matlab code in order to estimate the parameters but results are not a...
I am aiming at keeping my scientific studies and analyses reproducible: I am automating them as much as possible, I am sharing them, and I sharing them together with the execution environment(s) I've used to run the analyses. This is to make it possible, and easily possible, to rerun the analyses. I create execution en...
I want to calculate the stray magnetic field from a ferromagnet using the scalar potential method (1). The problem consists of a ferromagnetic cuboid divided into small cuboidal cells in which the magnetization $\mathbf{M}$ is assumed to be constant. To do this, I have to evaluate a convolution integral, discretized to...
Based on this, pp 245, we go through these steps to discretize a gradient statement, namely $\nabla\phi$: 1- Gauss theorem reads, $$ \int_V\nabla \phi dV = \oint_{\partial V}\phi dS $$ 2- Integral mean value theorem, applying on one cell (i.e. $c$) results, $$ {\bar{\nabla\phi}}_c =\frac 1 {V_c} \oint_{\partial V_c}\p...
I am facing the following problem, formulated in practical terms: I have a region $\Omega$ in two or three dimensions, represented as a binary mask, and an initial density $u_0$ within that region that I'd like to evolve following a diffusion equation: $$\partial_t u(\vec{x},t)=\nabla(D\nabla u)+f(u)$$ where D can be a...
I need to solve the following 4th order nonnegative LASSO problem: $$ \min_{x \geq 0} \quad || |Ax|^2 - b ||^2 + \lambda ||x||_1 $$ where $|\cdot|^2$ denotes element-wise squared. $A$ is small size (e.g., $A \in \mathbb{R}^{100\times100}$). This problem is non-convex and I worry about the convergence and stucking at sa...
I tried to implement the spectral element method1 as proposed in [1]. I simulated an aluminum plate and a vertical concentrated force was applied at the middle of the top left quarter of the plate2. I should get a wave with circular crest, coming from the point where I exerted the force. But apparently the wavefront go...
I am writting a c++ program in which I define a function $$\displaystyle F(t) = \sum_{i}r_i\,H(t-t_i)$$ where $H$ is the heaviside function, $t_i$ are optimal parameters which are mutable. The program is derived by automatic differentiation using ADOL-C. I am wondering whether I should be careful when I am implementin...
I'm looking for a way to efficiently invert $$K \otimes M+I_T\otimes \Sigma$$ where the inverses for $M,K$ exist. $I_T$ is the identity matrix of dimension $T$, and $\Sigma$ is a diagonal matrix, with positive only elements along the main diagonal. If I had only $K \otimes M$, I would just do $K^{-1}\otimes M^{-1}$. Ho...
As far as I know, all the symplectic Runge-Kutta methods are implicit which need to solve non-linear equations during the calculation. Is there any explicit method? If not, why?
I am interested in solving numerically the following mathematical problem Consider an ode of the form $$ \dot q(t) = f(q(t),t_1,\ldots, t_N),\qquad t\in [0,T], $$ where $q\in \mathbb{R}^n$ is the state and $t_i,\, i=1,\ldots N$ are real parameters such that $0\le t_1 \le \ldots \le t_N\le T$. Moreover $f$ is defined fr...
I’m stuck trying to solve part (b) and (c) of the below problem, but part (b) is the one of main concern here as I think (c) should follow easily once (b) is completed. I don’t know where to start with part (b). My first idea was to try to plug in $y’=-\lambda y$ in K1 instead of $f(t_n,y_n)$. I didn’t get far with tha...
I write a test program to integrate foward on $[0,T_f]$ and then backward on $[T_f,0]$ from the endpoint of the forward integration an Hamiltonian system: $$ \dot q(t) = \frac{\partial H}{\partial p}(q(t),p(t)), \qquad \dot p(t) = -\frac{\partial H}{\partial q}(q(t),p(t)) $$ and the expression of $H$ (given in the prog...
I have developed my own 3D Finite Volume Navier-Stokes solver based on projection method for nonuniform grid. I am looking to incorporate automatic timestep adjustment at each time step based on velocity. Is there any simple technique or procedure to calculate the size of timestep at each step for this problem?
I am trying to check the agreement of a dataset against a theoretical curve, specifically a bandstop filter in an RLC circuit. I have generated a function which describes the curve we expect from the filter, and a set of datapoints (amplitude and phase) by experiment. The two agree qualitatively by inspection of the pl...
I am solving a system of coupled nonlinear equations using Newton's method, similar to $$\begin{split} c_A(A, B)\partial_tA&=\nabla\left(k_A(A, B)\nabla A\right) + f_A(A, B, t)\\ c_B(A, B)\partial_tB&=\nabla\left(k_B(A, B)\nabla B\right) + f_B(A, B, t) \end{split}$$ with $f_x(), k_x()\text{ and }c_x()$ nonlinear funct...
I am currently applying the finite difference method to the solution of the diffusion equation. I think that a problem has occurred, and is as follows, my explicit method is the most accurate when analyzing the error to the analytic solution, and the Crank-Nicolson method is the least accurate, the implicit method is s...
I started a little project in python, under the assumption that it would be easy to find a routine for numerically computing Clebsch-Gordan coefficients in some library such as scipy. When it came time to do it, I actually found that it was difficult to locate an appropriate library. Scipy doesn't seem to have it. I'm ...
I have data with peaks on some background, for example: The two prominent peaks at ~390 and ~450, as well as the much smaller peak at ~840. What are some options to programmatically find the position (i. e. the x-coordinate) of such peaks using Python/SciPy?
This might be because of the mesh, but the following code blows up for all values of b not 1. Does anybody have any experience working with the ellipse mesh in Fenics? import matplotlib matplotlib.use('Agg') from matplotlib import ticker import matplotlib.pyplot as plt from dolfin import * from mshr import * def epsil...
I calculated the stress $\sigma$ and strain $\varepsilon$ for a solid plate with dirichlet boundary conditions $u = g$, where $u$ is the displacement. With these I want to calculate $\nabla_n u = t$ on the boundary where $\nabla_n$ describes the normal derivative. Is there any easy way to do this? I have the displaceme...
I am solving nonlinear least squares problems with the normal equations approach, so on each iteration, I need to solve: $$ J^T J \delta = -J^T f $$ for the step $\delta$, where $J$ is a large (millions of rows and about $15,000$ columns), dense, Jacobian matrix, and $f$ is the residual vector. In my problem, $J$ is of...
The CHOLMOD library provides a CHOLMOD_rcond function that estimates the reciprocal condition number (in the one norm) of a symmetric positive definite matrix from its cholesky decomposition. This is defined as the ratio between the smallest and largest entries in the diagonal of the L factor. Why is this a true fact?
An engineer has n supposedly identical integrated-circuit chips that in principle are capable of testing each other. The engineer test jig accommodates two chips at a time. When the jig is loaded, each chip tests the other and reports whether it is good or bad. A good chip always reports accurately whether the other ch...
I want to numerically solve the trajectory equations of a Kerr geodesic given by wikipedia in Matlab. The trajectories look like: I implemented the equations and solved it with the standard Runge-Kutta method. Here it is my code: % Initial parameter (r, theta, phi, t) r = x(1); theta = x(2); phi = x(3); t...
I am still rather new on here and I hope question is suitable for this forum otherwise please help me migrate it to greener pastures. I am an electrical engineer specializing in applying mathematics for building cool algorithms. Sometimes in my work I try to write code that helps compiler generate code that would run ...
I am a novice in FEM. I have some experience with FDM which was pretty straight forward. Since I have a confusion with a number of concepts, I will try to break them down by writing down what I have understood and what the confusion. Sorry if the question is too long. Firstly, all the FEM textbooks start off by saying...
What is the most accurate algorithm to get the square root inverse of a positive definite symmetric matrix? I am not looking as much for efficiency, though using quadruple precision computation is out of the question. By square root inverse I mean, given my matrix $J$, its square root inverse $J^{-1/2}$ is such that $...
I work on modelling high intensity discharge xenon-filled lamps. The model governing the discharge is quite complex and sadly includes fluid dynamics. After some time, I managed to implement a finite-difference particle-tracking lagrangian fluid dynamics for axisymmetric 1D discharge: $$ \frac{\partial}{\partial t} \le...
I want to change from real-space representation to momentum-space representation I have a Hamilton-operator (Anderson-model), and I calculated some kind of entropy of its eigenstates (this is working, I see what I want). Next I want to change to momentum repr. using FFT and now my eigenstates in momentum space are not ...
I'm working with a numerical algorithm whose output $y$ asymptotically approaches a certain unknown value $a$. I expect an exponential convergence, i.e. the data $y$ given by my algorithm should be distributed as $$ y=a+b e^{-c x} $$ where $x$ represents the number of iterations of the algorithm. For computational...
I have a diagonalization problem. I have the eigenstates correctly, and I want to do a Gaussian-smearing (Weierstrass-transform) on them. So I have the wave functions ($\Psi$), and the continuous equation: $$\zeta(x)=\int \mathrm{d} x' g_{\sigma_x}\left(x-x'\right)\left|\Psi(x')\right|^2,$$ where $g_{\sigma_x}$ is a no...
The script below tries to implement a Jacobi iterative relaxation of a potential field for an electrostatic lens. In order to plot electric field lines and calculate trajectories for charged particles, I need to write a function that calculates an interpolated gradient at a specified point between grid points. I can fi...
Often when numerically solving nonlinear PDE's using method of lines approach with an implicit integrator a system of nonlinear equations have to be solved. To be more specific, let's say we have simple backward Euler method: \begin{align} y^{n}=y^{n+1}-h f(y^{n+1},t)= G(y^{n+1},t) \end{align} From the available liter...
In this advanced course on applications of complex function theory at one point in an exercise the highly oscillatory integral $$I(\lambda)=\int_{-\infty}^{\infty} \cos (\lambda \cos x) \frac{\sin x}{x} d x$$ has to be approximated for large values of $\lambda$ using the saddle point method in the complex plane. Due ...
I am reviewing Numerical Recipes method on solving ODEs via relaxation (Chapter 18.3 in the 3rd edition) and they chose a finite difference method I am unfamiliar with (Equation 18.3.2): \begin{equation} \frac{\textrm{d}y}{\textrm{d}x} = g(x,y),\\ \longrightarrow \frac{y_k - y_{k-1}}{x_k-x_{k-1}} = g\left(\frac{1}{2}(...
I frequently see the equation $$ \sigma_t = E\alpha \Delta T $$ as the equation for thermal stress. Where $E$ is Young's modulus, $\alpha$ is the CTE, and $\Delta T$ is the change in temperature. If we were to write out, for an isotropic material, the stiffness tensor we get the expression below For thermal stress, t...
I'm doing a gravitational n-body simulator and I'm thinking of implementing linear multistep methods like Adam-Bashforth. But is there any symplectic multistep methods?
So, I would love to make at least some use of my preexisting data, no matter how small, and just out of ideas. Maybe I am just a prisoner of a Kahneman-like theatre-ticket paradox, and don't know whether I should accept the losses and move on. Consider a system of linear equations (in a very simplified form): $$ \beg...
I am trying to reconstruct the surface for a fluid simulation based on a list of particles using the Marching Cubes algorithm. From different resources, such as http://paulbourke.net/geometry/polygonise/, or https://cseweb.ucsd.edu/classes/sp16/cse169-a/slides/CSE169_15.pdf I see that I have to compute an isosurface ba...
I know that people often replace consistent mass matrices with lumped diagonal matrices. In the past, I've also implemented a code where the load vector is assembled in a lumped fashion rather than an FEM-consistent fashion. But I've never looked into why we are allowed to do this in the first place. What is the ...
Using linear elasticity formulation, I am attempting to numerically compute the displacement due to thermal expansion. This is done for a 3-D isotropic material. The governing equations are simply: $$ \nabla \cdot \sigma = 0 \\ \sigma = \sigma_{\text{thermal}} - \sigma_{\text{mechanical}} \\ \sigma_{\text{thermal}} = ...