instruction
stringlengths
43
28.1k
I at the moment try to fully understand the Bareiss algorithm for calculating determinants. One question that came to my mind is the following: Why is LU-decomposition much more often used than the Bareiss algorithm? I mean, they both have a complexity of $\mathcal{O}{(n^3)}$, so what's the problem with Bareiss?
I have the following expression to be numerically integrated in a vector-based library (e.g. numpy, MATLAB, etc), $$ F(r_2) = \frac{1}{r_2^n} \int_0^{r_2} r_1^n f(r_1)\ \mathrm{d}r_1, $$ where $n$ is an integer that can have value up to $40$ and $r_1$ and $r_2$ can have values of many orders of magnitude (e.g. $r_2 \in...
I am numerically solving the Schrodinger Equation in 1D first and in higher dimension later, but I want to know the convergence rate of my numerical solver in different grid size and numerical methods. To calculate the error (or convergence rate), I will need an analytical solution to compare with, but I don't seem to...
From the given point cloud (Fig. 1), I use Scipy-TDA to extract persistence diagram (Fig. 2). What I'm interested in is to extract 3 circles. For example, I'd like to know 3 center points and labels for each point. I'm quite newbie to topological data analysis. Anyone to help me or guide the process? Edit: To show a ...
How to solve for $f(A)x=b$? For GMRES, an answer is given in this book chapter: http://link.springer.com/chapter/10.1007%2F978-3-642-58333-9_2. Ungated version: https://www.researchgate.net/profile/Henk_Van_der_Vorst/publication/226001699_Linear_Systems_Eigenvalues_and_Projection/links/02e7e5301220731a71000000/Linear-S...
In different books and on Wikipedia, you can see mentions of Cholesky decomposition and only sometimes of LDL decomposition. As far as I understand, LDL decomposition can be applied to a broader range of matrices (we don't need a matrix to be positive-definite). I am specially looking to solve hundreds of thousands la...
I am new here and this is my very first question: I hope I respect all the criteria and rules. I am just getting started with partitioned approaches for solving FSI problems. I am interested in a Chorin-Temam projection scheme for the fluid, with semi implicit coupling. This is the paper I am referring to: https://arxi...
I encountered the split operator method to solve the time dependent Schrödinger equation during a lecture. I understand the method on a theoretical basis (I think at least), but I'm struggling to understand one specific aspect of the implementation. Take a look at the following Pseudo-code (taken from arxiv:1306.3247,...
I am slightly confused regarding the meaning of the $i-th$ gradient-jump term $[\nabla \phi_i]$ in the context of finite element methods, used in the assembly of the stiffness matrix (an example with deal.ii). On face $F$ with unit normal $\nu$, the jump term is defined as $$ [\nabla \phi ] = \nu \cdot (\nabla\phi^+-\n...
This is related to a question I answered on Stack Overflow regarding calculating the square root of a number. I was thinking about it and realized that the formula is just the first in a family of algorithms to calculate the $p$th root of a number (ie solve $y=x^p$ for $x$). $$ x_n = \left( \frac{p}{2} \right) \frac{\d...
I am trying to calculate and visualize the electric field inside and outside of a parallel plate capacitor by assuming a uniform distribution of point charges on each plate and by adding up the Coulomb-fields directly (I want this approach for educational purposes) with the following Python program. Mathematically spe...
I found after some research that the most numerically stable way to solve the least squares problem is through QR factorization. For $n$ number of observations and $p$ number of parameters it takes the following form: $$Q_{n,p}R_{p,p} = X_{n, p} $$ Where $R$ is a square upper-triangular and $Q$ is orthogonal. And the ...
I have a set of points in 2D obtained from a pendular movement with some noise. I want to determine where is equilibrium point ($x_0$, $y_0$) from which the rope is fixed. There are at least two approaches to solve this using linear regression. I'm not sure which one to choose and why the first method gave me no accept...
I am trying to understand the notion of reduction of a problem to another problem. As it is known this has huge impact on classifying the complexity of a problem. The definition of reduction involves the notion of instances. From wiki we read that a computational problem can be viewed as an infinite collection of insta...
I am looking for a detailed reference on the implementation of the Morley element for FEM, specifically for the biharmonic equation. By detailed, I mean that it should discuss the problems associated with transforming the reference element, as well as handling different boundary conditions.
I have written a SOR algorithm to solve the Laplace equation on a 2d grid. The outside of the grid is fixed at 0 and the central square is fixed at 10. I can obtain the fully converged solution for some values of the relaxation parameter $\beta$ but not others. In the other cases the convergence condition is never m...
I need to compute the equivalent thermal resistance and thermal capacitance of a structure used for heat transfer. For illustration purpose let’s say it’s the 2D problem of the following figure. In the top surface (nodes 1 to 4) I have a constant heat generation boundary condition (BC) and in the bottom surface (nodes ...
I want to integrate programming into my learning in math and science in a very specific way. I want to create visualizations and simulations of concepts I am learning. When I learn a numerical method of graphing differential equations I want write a program that can do it for me, when I learn about tunnelling in QM I w...
I am trying to implement an algorithm to find the Jacobian ratio for each triangle in mesh as a part of mesh quality check. Let's say that I have vertices of the triangle: $P_1(x_1, y_1, z_1)$, $P_2(x_2, y_2, z_2)$, $P_3(x_3, y_3, z_3)$. Having this data how to determine the Jacobian ratio of the triangle?
Does someone have a reference for the minimum number of elements (or maximum mesh size) for electromagnetic simulations where a mathematical or numerical explanation is given? I have found several recommendations but alas no justification: For instance, here at least 5 second-order elements per wavelength are recommen...
I have solved numerically the following system: \begin{cases} \partial_t{u} + \partial_x{v} = 0 \\ \partial_t{v} + \frac{1}{\varepsilon^2}\partial_x{u} = -\frac{1}{\varepsilon^2}(v-f(u)) \end{cases} with periodic boundary conditions by finite volume method (IMEX-Runge Kutta). I was wondering if, as it happens in a lot ...
I am new to octave and still learning what I can and cannot do with it. I am asked to write a following function ('trigmin'): [a, b, c, info]=tigmin(x,y) Where x, y are vectors of the same length (let's say n) and the function output is the triple [a, b, c] where the triple minimizes the following expression $$\sum_{i...
The four-noded bi-linear rectangle element, which sometimes goes under the name Melosh element, is non-conforming unless the element sides are aligned. Out of curiosity I have implemented this element for two-dimensional elasticity problems. The figure shows a mesh with three such elements. The element sides are not al...
I have been solving problems of the form $$max \ log(det(A)) \\ s.t. \ A = A^{T} \succeq 0, \\ p_{i}^{T}Ap_{i} \leq b_{i}$$ where $b_{i}$ and $p_{i}$ are input vectors (to be clear there is more than one vector $b_{i}$ and $p_{i}$), using CVXPY and SCS. What I am finding is that the transformation into canonical form ...
I recently found the following article where it was stated that using 16 bit numbers can be used to increase the computational performance of AI applications. According to the article numbers above 16 bit must be scaled to fit into the 16 bits. Could this technique also be applied to solutions of linear system using i...
I want to optimize a function w.r.t. $n$ circles parametrized by centers and radii: $$\min_{C, R} f(C,R)$$ where $C\in\mathbb R^{n \times 2}$ and $R\in\mathbb R^n$. For example, C[1,1]: x-coordinate of the first circle C[1,2]: y-coordinate of the first circle R[1] : radius of the first circle While optimizing, I wan...
We can numerically integrate first order differential equations using Euler method like this: $$y_{n+1} = y_n + hf(t_n, y_n)$$ And with Implicit Euler like this: $$y_{n+1} = y_n + hf(t_{n+1},y _{n+1})$$ If I have a differential equation $y' - ky = 0$, I can integrate $y$ numerically using Implicit Euler: $$y_{n+1} =...
I am trying to optimise a function, but the function can be noisy and give varying results for the same parameters. Furthermore, it needs to be online, as the data from each new iteration happens slowly (and begins with no data). I have used gradient descent, which works sometimes, but even then not very well due to no...
What numerical methods are used to model deformations in elastic physics? For example, here's an example of a hyperelastic deformation in Ansys: Perhaps more simply than hyperelasticity, for linear elasticity, we have the equations: $$ \nabla\cdot\sigma + {F} = \rho\ddot{{u}}\\ {\varepsilon} =\tfrac{1}{2} \left[{\nab...
I have to use the leapfrog method to solve the simple harmonic oscillator and I having trouble writing it in code. This is what we were given in class $$ \frac{v_{n+1/2}-v_{n-1/2}}{\Delta t}=-\omega_0^2x_n\\ \frac{x_{n+1}-x_n}{\Delta t}=v_{n+1/2} $$ This is what I have written for the code import numpy as np import mat...
I really have a problem here. I have not found a solution yet. The system I need to solve similar to this:(Basic idea) $$c_1 = \dfrac{dx}{dr}+y$$ $$c_2 = \dfrac{dy}{dr}+x$$ Both $c_1/ c_2$ are equal to 0 meaning the desired system is: $$\dfrac{dy}{dr} = -x$$ and $$\dfrac{dx}{dr} = -y$$ The ODE system I wanna solve is t...
I've got a question about a good way to find the quickest algorithm for my problem: problem: I've got a 3D cubical grid containing voxels that are either 1 or 0. It is stored as a flattened array. If multiple 1-voxels are neighboring each other, they form a cluster together. I want to detect clusters smaller than a giv...
In solving nonlinear hyperelastic solid mechanics problems, to converge to the correct solution we need to do step-by-step loading which makes the deformation at each step very small (for my particular problem $\mathcal{O}(e^{-11})$). Moreover, due to the material properties, the nonlinear weak form and consequently th...
I have numerical issues with a poorly scaled one-dimensional non-linear diffusion equation in physical co-ordinates $$ \frac{\partial{u}}{\partial{t}}(x,t) = \frac{\partial}{\partial{x}}\left(D(u) \frac{\partial{u}(x,t)}{\partial{x}}\right)$$ $$x \in (0,L),\ t \in (0,t_\text{f}) $$ with initial conditions $$u(x,0) ...
I know there is efficient way to construct chebyshev differentiation matrix $D_N$. The idea is to fit the function $f(x)$ with a polynomial of $p_N(x)$ of order $N$, and use the derivative $p_N'(x)$ to approxiate $f'(x)$ at chebyshev points $x_0,..,x_N$. I wonder if we know f(x) is an even function on $[-1,1]$, and we...
I wrote some FEM code and found some strange results when using a very small time step. So, I decided to analyze the discrete equations. Consider the following linear diffusion problem in 1 dimension: \begin{equation} \frac{\partial u}{\partial t} = k \frac{\partial^2 u}{\partial x^2} \end{equation} where k is a positi...
I am reviewing stability of finite difference methods. I am using the von Neumann method to study a linear PDE and an explicit finite difference scheme. The goal is to develop an expression for an amplification factor $G$. I've read that if $G$ is a complex function it can be plotted in the complex plane to more easily...
I would like to use full approximation scheme(FAS) for solving nonlinear PDE. I am looking into practical implementation of FAS in parallel(MPI) settings. I noticed the most common/effective smoother choice is GaussSeidel-Newton iteration. Are there any other possibilities? Are there any parallel variants of GaussSeide...
I've the following system of equations for studying information flow in the below graph, $$ \frac{d \phi}{dt} = -M^TDM\phi + \text{noise effects} \hspace{1cm} (1)$$ Here, M is the incidence matrix of the graph $\phi$ is a vector with variables [ A B C D E F]. I've solved the above ode's to obtain the time series d...
Given the following code, how can I perform a mesh generation around the line, to make a 2D form in GMSH API? Extrude or Mirror functions? I want to add a mesh around the line, for example, 1cm to left and 1cm to right. #include <gmsh.h> int main(int argc, char **argv) { gmsh::option::setNumber("General.Terminal", ...
I'd like to simulate the propagation of a pulse, and have different options for solving that. On the one hand, I can use the non-linear schrödinger equation $$\partial_zE=\frac{i}{2k_0}\nabla^2_\perp E$$ with $k_0$ the propagation constant. I can solve it either in the cartesian coordinate system (using a fourier trans...
(I previously asked this question on Sage's dedicated Q&A site, but got no response, so I figured it would be worth trying here.) I have a way of constructing hyperplane arrangements in Sage, which involves taking the restriction of a larger arrangement to one of the hyperplanes in it. I want to output a list of the si...
I have a little trouble formulating my question since I am not really sure what conclusions I am supposed to draw from the results I have obtained. I am sorry for the long problem formulation below, but I will keep it as short as possible. I was given a general scheme, $$ U^{n+1} = Q(t_{n})U^{n} + \Delta t F^{n},\\[3mm...
I am simulating the behaviour of a single bar composed of two node points by fixing one point and applying a force on the oder node with $F_x = 1$ and fixing $u_y=0$. I am assuming the material to behave elasto plastic with isotropic hardening. My loading simulation for $F_x = 0$ to $F_x = 1$ with increment $1/10$ see...
In my research department we plan a small seminar on the new c++20 language standard. There are exhaustive lists online presenting the new features of the language standard, some of which will be of interest to this community, some will be inconsequential. I think I understand the advantages of: concepts (wiki) - c...
I have $$S = QLQ^T$$ I know $Q$, $L$, $Q^T$. How can I get the $R$ and $R^T$ for the Cholesky decomposition $S=R^TR$?
I am attempting to numerically solve the following system of ODEs: $$\begin{gather}\frac{dT_1}{dt} = f_1(T_1,T_2), \quad T_1(t=0)=T_{1,0} \\[3pt] \frac{dT_2}{dt} = f_2(T_1,T_2), \quad T_2(t=0)=T_{2,0}\end{gather}$$ The functions $f_1$ and $f_2$ have $T$ and $T^4$ terms and therefore are non-linear. I tried the forward ...
For context, I'm creating a linear algebra library from scratch for learning purposes in C. Right now I'm working on calculating eigenvalues but my implementation of the QR Algorithm is diverging. Below is my understanding of the QR Algorithm, and after the first block of code is (what I believe to be) the meat of the ...
How do I get an .inp file from Gmsh? I need to create a simple geometry and mesh it and define the boundary conditions in Gmsh and export it as an .inp file at the end (because I need to use it in a third party solver). I couldn't find much help from the documentation of Gmsh it seems there exists a mesh file format in...
This is a follow-up to my previous question here I've the following system of equations for studying information flow in the below graph, $$ \frac{d \phi}{dt} = -M^TDM\phi + \text{noise effects} \hspace{1cm} (1)$$ Here, M is the incidence matrix of the graph $\phi$ is a vector with variables [ A B C D E F]. I'...
import cvxpy as cp import numpy as np n = 3 PP = cp.Variable((n,n),"PP") KK = [[2,1,3],[1,2,1],[3,1,2]] s = np.array([[.1, .4, .5]]).T t = np.array([[.4, .2, .4]]).T e = np.ones((n,1)) x = PP.T@e - s y = PP@e - t for b in range(1,21): obj = (1/4/b) * (cp.quad_form(x,KK) + cp.quad_form(y,KK)) - cp.trace(KK@PP) ...
Take a Fredholm integral equation $$ u(x) - \lambda \int_{-1}^{1} K(x,y)u(y) \, \mathrm{d} y = f(x) $$ and discretize it via (say) Gaussian quadrature with nodes $\{x_j\}$ and weights $\{w_j\}$ to get $$ u(x) - \lambda \sum_{j} w_j K(x,x_j)u(x_j) = f(x) $$ It feels natural to use the same set of quadrature nodes over $...
I am working on 2D Ising model, when I plot "specific heat vs temperature", I can't see any discontinuity at critical temperature around Tc ~ 2.7K. I am enclosing results of all other thermodynamic quantities, which are correct except the specific heat. Edit 1: As asked by @Daniel Shapero, I ran the simulation for 64 x...
Consider the PDE $$u_t = b_{11}u_{xx} + 2b_{12}u_{xy} + b_{22}u_{yy},$$ where $b_{11}, b_{22} > 0$, and $b_{12}^2 < b_1b_2$. In Strikwerda's book, the ADI scehme \begin{align*} \left( 1 - \frac{k}{2} b_{11} \delta_x^2\right)v^{n+1/2} &= \left( 1 + \frac{k}{2} b_{22} \delta_y^2\right)v^{n} + kb_{12} \delta_{0x} \delta...
I am working with the Shallow Water equations that is a system of non-linear PDEs that simulate water waves propagation on some domain, in my cases the $x$-axis. I have here a GIF showing the results (is it possible to insert the GIF into the post? Because I have not figured out how). I will try to keep it short and wh...
This is a follow up to my previous post here I'm interested in performing trajectory optimization from the problem mentioned in abov link. I want to supply the following as dynamical constraints to MATLAB's fmincon. $$ \frac{d \phi}{dt} = -M^TDM\phi + W \hspace{1cm}(1)$$ $\phi$ is a vector with variables [ A B C D ...
I have to compute the mass matrix of a Hexahedral mesh. There are 3 methods to compute mass matrix. I'm interested in one method which consists of dividing the mass of the element by the number of nodes and attributes this mass at each node for each degree of freedoms. My problems is that: I don't know how to compute t...
I am trying to solve the time-independent Schrodinger equation in two dimensions via discrete matrix diagonalization. I want the energy eigenvalues and the corresponding eigenfunctions for a given potential. Eventually I want the solutions for the following potential (although as shown later I can't seem to get it wor...
I am trying to implement the algorithm contained in this article here. It is about solving a 2 and 2.5D Fredholm integral, focused on bidimensional NMR experiments. I've made significant progress, despite this being my very first time doing any computational science. The output I get is clearly wrong, but seems shifted...
My goal is to find all eigenvalues (and eigenvectors) in a given range of magnitudes of a complex symmetric matrix with real off-diagonal elements (only diagonal elements are complex). Currently I'm using PARPACK for non-hermitian matrices and discard eigenvalues outside of the window of interest, but this method is mo...
I am trying to simulate a 3D Ising spin system (+1 & -1) using Monte Carlo Metropolis Algorithm. I want to get different physical quantities from this simulation like magnetization, Average Energy, Susceptibility, Specific Heat. I have used exactly similar code for 2 dimension that gives perfect result but for 3D it fa...
i am working on an assignment problem: Consider a two-dimensional rectangular plate of dimension L = 1 m in the x direction and H = 2 m in the y direction. The plate material has constant thermal conductivity. The steady-state temperature distribution within this plate is to be determined for the following imposed boun...
I'm trying to solve an ODE problem. Let's say $\mathbf{x}(t)$ represents the position of a particle at time $t$, and $\mathbf{u}(\mathbf{x},t)$ is a velocity field defined in Cartesian coordinates on some manifold $\mathbb{M} \subset \mathbb{R}^3$ represented as a level set of the form $F(\mathbf{x}) = 0$. Then, the pa...
I am doing a Monte Carlo Simulation of the properties of a 3D Ising Spin system. I want to get the free energy surface of the spin system from the simulation. It is a magnetization vs free energy curve. Free energy is defined as F(m)=-kT ln(P(m)) where m is magnetization and P is the probability of occupying the corres...
I am simulating a Lennard-Jones fluid using MC simulation. The code always uses a reduced unit. I want to find the potential energy of the system. Periodic boundary condition implemented. I have simulated with 2 particles to find out if the simulation gives correct result. For 2 particles the equilibrium separation is ...
I want to estimated the parameters $\ \hat{\theta} $ of a model using an iterative search for the minimum of a cost function. The cost function is defined as follows: $$ V_N(\hat{\theta}) = \frac{1}{N}\sum_{i=1}^N(y(t_k)-\hat{y}(t_k|\theta))^2 $$ where $\ y $ is the output of the system and $\ \hat{y} $ is the estimate...
I am using LeVeque's book: https://faculty.washington.edu/rjl/fdmbook/ Suppose I want to compute $u''$ using FDM with $\alpha=\beta=2$ (centered) so the FDM is $$ u''=\sum_{m = - \alpha}^\beta a_mu(x_i+mh) $$ Before acutally determining the coeficients ($a_m$'s) can we say anthying about how what the maximum attainabl...
Suppose I have a long, possibly infinite, sequence $x := [x_1, x_2, ...]$, and I want to use it to compute another sequence $y:=[y_1, y_2, ...]$ where each element is the sum of the last K elements of the input sequence. i.e. $y_i = \sum_{j=max(1, i-K)}^i x_j$ The naive, inefficient way to do (in Python) this would be:...
I'm recently studying for the spectral solver to implement EM-PIC code. I read an article and have some questions. Many PIC codes uses spectral solver to overcome numerical artifacts on FDTD. In the high-order approximation of spatial derivative in PSTD and PSATD scheme, $$ \partial_{x}E_{x}|^{n}_{i,j,k} = \Sigma_{l=0}...
Suppose to calculate the continued fraction expansion of $\pi$, the common-sense algorithm would be to take the decimal part, perform inversion, which will give the next term as integer part, and the process is repeated for the decimal part. However, this algorithm has the complexity of order $\mathcal O(n^2\log(n))$ a...
Suppose there are two arrays (They have the same length), I want to give a quantitative description about the similarity between them. I define a formula like this, which means we can shuffle them arbitrarily. If we use the stupidest method, i.e. calculate every possible result, we need to keep array B unchanged and ke...
I am trying to implement the algorithm in this article. I have already asked a question before about it here, and I am trying to figure out what I am doing wrong. This time, it's this section of the article that I am struggling with (bold part is mine). [...] it can be shown that the vector $c_r$ that satisfied (29) c...
A decade ago I saw a ~20 coupled state + random number problem that was used as a benchmark for meteorological CFD tools. It had a fractal dimension (of the chaotic attractor) around 2.3, I think. I saw matlab code for it. I'm looking for the method now, and can't remember what it was called. To be clear it was enti...
I am solving an optimal control problem of the form $$ \min_u \qquad\int_0^T \langle u(t), u(t) \rangle \, \mathrm{d}t \\ s.t. \quad \dot{x} = \tilde{f}(x) + u, \quad x(0)=x_0 \\ \qquad \tilde{\Phi}(x(T)) = 0\} $$ reformulated as $$ \min_{\xi(T)} \qquad \xi(T) \\ s.t. \quad \dot{z} = f(z,u), \quad z(0) = z_0 \\ \qquad...
I have two sparse general matrices stored in CSR format I need to multiply. Is there any chance to gain performance using AVX2? In general the matrices are big (hundreds of millions of non-zeros and sizes by about 3million x 3million). The number of non-zeros per matrix line should be sufficient but I am not sure if th...
I'm looking to learn C++ primarily from a scientific computation perspective. The approach of the textbook seems ideal to me as it covers C++ from first principles with an emphasis on numerical computation. However, the textbook was published in 2001. Will studying from this textbook teach me methods which are now not ...
I've encountered a program where np.tensordot was used, so I tried looking it up but I can't really understand what this function is doing... I feel rather confident in my understanding of tensors in a abstract context (i.e. in pure maths/physics), but I don't really understand what this tensordot is supposed to do. I'...
I'm looking for an open-source library for the generation of random n-dimensional orthogonal matrices in C++. In python, it looks like such a function is available in the NumPy package. But I was not able to find yet a solution in C++. Any suggestions?
I tried to generate 3 very simple cylinders, each other connected to it end, however the cylinder get connected to an unexistent point in space as the image shows: It was supposed to each segment be 45º, 90º and 60º of inclination. The code: #include <gmsh.h> int main(int argc, char **argv) { gmsh::initialize()...
Between the two ears in the following bunny images, there are some degenerate triangles I want to detect. It looks like a volume-less thin slits. If the question is not clear, please let me know.
How long should the hyperelastic equations be solved before updating the mesh? To be specific, I'm interested in the hyperelastic model with a neo-Hookean solid: $$ \nabla\cdot\sigma + f = \rho\ddot{{u}}\\ \sigma = \mu F + (\lambda\log\det F - \mu)F^{-T}\\ F = I + \nabla u $$ where $\sigma$ - Stress tensor $F$ - Defo...
I am doing a molecular dynamics simulation of Leonard Jones 6-12 potential. But instead of converging to a particular value. It always stays between -5.58 to -5.62. The standard value is -5.517. The problem is that however long it runs (I have tested up to 30000 steps) it does not converge to even 1 digit after the dec...
I am using the XMDS library for solving the stochastic (projected) Gross-Pitaevskii equation $$i \hbar \partial \Phi\left(\mathbf{r},t\right)_t=\hat{\mathcal{P}}\left\{(1-i \gamma)\left(\hat{H}_{\mathrm{GP}}-\mu\right) \Phi+\eta\left(\mathbf{r},t\right)\right\}$$ where $\eta\left(\mathbf{r},t\right)$ is a stochastic no...
I'm trying to solve the following equation with FVM $$u_t + f(u)_x = g(u)$$ where $g$ is some smooth function of $u$ and $f(u) = \frac{u^2}{2}$. This is really similar to Burger's equation, except for the source term. My main problem is that I don't know how to derive correctly the numerical scheme since I have a sourc...
I am trying to solve an ODE with solve_ivp, but I am getting strange errors. Documentation: https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.solve_ivp.html from scipy.integrate import solve_ivp as solve import numpy as np import matplotlib.pyplot as plt def fun(t, y, beta, eps): u = 1/eps * (-1...
The classical Clenshaw recurrence (see Algorithm 3.1 here) is less accurate as $x\to \pm 1$. So Reich proposed a modification to it, which is discussed as Algorithm 3.2 as well as by Oliver. While trying to derive a point of transition between the two algorithms I generated ULP plots for these two algorithms, and was s...
I have been learning petsc recently and made a simple solver for stokes equation on 3D staggered grid. My code is running on server with 200GB ram, but if I run a solver on 256^3 grid, memory used by the solver is over 200GB. Checking with the -log_view flag, I've figured out most of the memories were used by the matr...
I've successfully implemented a 1D DG code with non-normalized Legendre basis and I've now moved onto developing a 2D code using tensor products. For my 2D code I've chosen to have normalized Legendre polynomials,i.e. $$ L_{0}(x) = \sqrt{\frac{1}{2}}\\ L_{1}(x) = \sqrt{\frac{3}{2}} x. $$ My question is: If we normali...
I recently read the paper "On Spectral Clustering: Analysis and an Algorithm" by Ng et al. Much of the paper centers on Theorem 2 and equation 8. To me, it appears there is no given or referenced proof of this Theorem. I am hoping that someone can point me in the right direction to understanding the derivation of this ...
We have a 3-dimensional grid of voxels (or cells), with individual voxels being of volume $dx\,dy\,dz$ where $dx=dy=dz=1$. A cone-like surface is defined by some function, $z = f(x, y)$, which in this case is specifically (where $\epsilon$, $w_0$ and $r_0$ are constants): $$z=\left(\frac{x^2+y^2}{w_0^2r_0^{-2\epsilon}...
For sure, there has been many highly optimized library on this. But I am working on a matrix-free context since the problem size does not allow explicit storage of sparse matrix elements. I'd love have a general knowledge on how people handle this sort of problem, especially on how to alleviate the memory bottleneck. ...
I'm a master's student in Math interested in Numerical Analysis. I know there are lots of questions like that on this site, but I think this is the best place to ask. So, I'm looking for an introductory book to C++ with a focus on scientific computing. Let me clarify my situation: I've been an intensive Matlab user an...
In the BFGS method we perform iterations by calculating an approximation $\boldsymbol{H}_k$ to the inverse Hessian $\boldsymbol{H}$ of the objective function. This method belongs to a family of methods in which $\boldsymbol{H}_k$ is guaranteed to preserve the positive definite nature of $\boldsymbol{H}$ for all $k$, pr...
For a scalar quantity $u = u(x, t)$, I'm considering the transport equation \begin{align} u_t + au_x &= 0, \qquad{x\in[0, L], \ t\in[0, T]} \\ u(0, t) &= u_{\text{in}}, \\ u(x, 0) &= f(x). \end{align} When $a$ is a constant, the Lax-Friedrichs scheme is the FTCS approximation given by \begin{equation}\label{PDE} u_j^{n...
I have an integral of a convolution between two functions. How can I calculate this in Python? It is a continuum convolution.
I wasn't sure if this is a Computational Science SE question or a Stack Overflow question but I think it's more of this one. I wanted to make a graph where I can rotate a hyperbola (not parabola or ellipse) about any point, not just the origin on a Cartesian Plane. This is the equation: $$\left(\frac{(y-k)\sin\theta-(x...
I have the following dynamical system, $\frac{d \phi}{dt} = -M^TDM\phi \tag{1}\label{1}$ $\frac{d \hat\phi}{dt} = -M^T\tilde{D}M\hat \phi \tag{2} \label{2}$ $\eqref{1}$ represents the exact dynamics of a system and $\eqref{2}$ is the approximate dynamics that should give the same time course profiles as $\eqref{1}$, a...
I am studying about the 1D EM-PIC (Electro Magnetics using particle-in-cell) simulation. I want to have a simultaneous time-integration of the electric/magnetic fields plus the motion of free charges due to electrostatic/Lorentz forces. I studied PIC simulation algorithms and I want to practice by making my own code fo...
Let $D$ be a sparse matrix. I want to compute $D\times D^T$. As $D$ is fairly large, so I am row-slicing $D$. That means for a range $(i,j)$, I am computing $C = D(i:j,:) \times D^T$ and performing some post-processing on $C$. I am choosing the index according to my available memory. I want to know whether there is any...
I'm trying to plot the cross section with respect to the photon energy $h\nu$ but for $\gamma = 1.0, 1.2, 2.0 $ in the same axes $\sigma = \left[\left(\frac{\xi_{eff}}{\xi_{0}}\right)^2 \frac{n_r}{\varepsilon}\right]\frac{4\pi}{3}\alpha_{fs}h\nu|\frac{1}{2}\frac{R}{2^\beta \Gamma(\beta + 1)}\int_{0}^\infty \left(\gamm...