instruction
stringlengths
43
28.1k
We have a large sparse symmetric positive-definite matrix $A \in \mathbb R^{N \times N}$ and a vector $x \in \mathbb R^N$. How do I practically compute the inner product $x^T A x$ when the matrix $A$ is ill-conditioned? In my applications, this is a stiffness or mass matrix of a finite element code. There is an obvious...
Cross-posted in CrossValidated.SE and MMSE I am experimenting with a new MCMC protocol and new research. In the context of Monte Carlo simulation, a "state of equilibrium" refers to a condition where the system being simulated has reached a stable configuration or distribution of properties that does not significantly ...
""we aim for a consistent variational-monolithic coupling scheme in which we need all equations defined in the same domain; therefore, $\mathrm{ALE}_{f x}$ was introduced. In variational monolithic coupling, Neumann-like interface conditions, like the continuity of normal stresses are fulfilled exactly in a weak sense ...
I want to simulate how a Gaussian beam would look like at the receiver plane when propagated through an atmospheric turbulence. For this I am using AO package. Since I didn't see any function for multipropagation i.e. choosing multiple phase screens between the distance and propagating partially. Taking reference from ...
The Debye functions are defined like so: ${D_n\left(x\right)} = {\frac{n}{x^n} \cdot {\int_0^x{\frac{t^n}{e^t - 1}dt}}}$. I'm trying to evaluate the functions for $n$ from one to four and for $\left\lvert x \right\rvert < 10$. The required number of evaluations is great, and I require hundreds of bits of accuracy. Usin...
Problem I am using finite difference method to solve classic problem of flow around cylinder, for validation of my group's immersive boundary method. The common way to validate numerical method is calculating drag and lift coefficient. But my result is far form other's results. So it must be error in my force calculati...
Recently I am reading a paper. In it, after they achieve eq(15), which is $$ \operatorname{Tr}(\boldsymbol{Q})-\sqrt{2 \ln (1 / \rho)} \sqrt{\|\boldsymbol{Q}\|_F^2+2\|\boldsymbol{r}\|^2}+\ln (\rho) \cdot \lambda^{+}(\boldsymbol{Q})+s \geq 0 $$ Then they said "By introducing suitable slack variables, one can easily show...
Let us say I want to solve a large sparse linear system. It is said that iterative solvers should be better than direct solvers in this case. But how large is large? What is the exact threshold beyond which I must use iterative solvers? A thousand by thousand matrix? A million by million matrix? I understand this might...
I'm currently facing the problem of efficiently detecting (special) ellipses in edge images. These images are given (i.e. previous image processing is impossible) and contain quite some noise. I need to detect those ellipses which are completely contained in another ellipsis. The following images gives a reduced exampl...
I was solving the dimensionless wave equation: $$ u_{xx} = u_{tt} \tag 1$$ with the initial conditions: $$ u(x,0) = 0 \tag 2 $$ $$ u_t(x=0,0) = v_0 \tag 2 $$ $$ u_t(x>0,0) = 0 \tag 3 $$ and the boundary conditions: $$ u(1,t) = 0 \tag 4 $$ $$ mu_{tt}(0, t) + u_x(0, t) = 0 \Leftrightarrow mu_{xx}(0, t) + u_x(0, t) = 0 \t...
I would like to report an issue which may be interesting in computational physics. Sometimes, to save time and memory, we use eigs() to calculate the first several eigenvalues of a sparse matrix. However, I find that the eigenvectors calculated in this way is not always accurate, especially only few eigenvalues are cal...
Is it true that ENO/WENO schemes are the "goat" and they completely supplanted the older methods such as Godunov, approximate Riemann solvers, flux limiters etc? Are these old methods only important in classrooms to motivate and pave the way for the ultimate "boss" ENO/WENO?
I am trying to understand how the relationship between Butcher tables for Runge-Kutta methods and their generalization to general linear methods matrices (by Butcher also). Runge-Kutta methods can be specified by the nodes $c_i$, the weights $b_j$ and the coefficients $a_{ij}$ under the form of Butcher tables (see Wik...
I'm interested in sampling from a Gaussian with zero-mean and covariance given by: $$ \Sigma = \begin{bmatrix} \Sigma_{11} & \Sigma_{12} & \cdots &\Sigma_{1,100}\\ \Sigma_{21} & \Sigma_{22} & \cdots &\Sigma_{2,100}\\ \vdots & \vdots & \cdots &\vdots \\ \Sigma_{100,1} & \Sigma_{100,2} & \cdots &\Sigma_{100,100} \end{bma...
For a matrix $Y(t) \in \mathbb{R}^{m \times n}$, its rank-r approximation could be represented in a factorized SVD-like form. $$ Y(t) = U(t) S(t) V^T(t), $$ where $U^{T}U = I_m$, $V^{T}V = I_n$ and $S \in \mathbb{R}^{r \times r}$. I want to integrate the matrix $Y$ and have obtained the following iterative format: $$ U...
abaqus documentation only shows generalized models and their formulae. What are the prony series in abaqus for the simplest maxwell and kelvin models?
The Wikipedia article on Runge-Kutta Methods lists several examples of each order. My question is, are there any particular advantages using one particular scheme over another of the same order? I wanted to complete a convergence test of the Advection Equation, which is as follows: $$ \frac{\partial \theta}{\partial t}...
I would really appreciate if you could recommend me some textbooks that explain FEM process well and have many exercises to solidify the knowledge. So far, Brenner and Zienkiewicz seem to be a bit hard, although, I would like to switch to Zienkiewicz, once I get the grasp of the basics. Any input would be greatly appre...
As exercise I am implementing few fundamental networks. Specifically right now I am implementing VGG The code I've got at the moment is the following: class MyVGG(nn.Module): def __init__(self): super(MyVGG, self).__init__() self.arch = nn.Sequential( nn.Conv2d(3, 64, 3,padding=1), nn.MaxPool2d(...
I would like to calculate the surface area of a 6-noded triangle element, i.e., the face of a 10-noded tetrahedral element in 3D space. A typical solution is to calculate the surface integral of the Jacobian of such an element, however I can only find derivations of the shape functions and thus the Jacobian for the 2D ...
I am attempting to solve the differential equation $\ddot\phi + 3H\dot\phi + \dfrac{dV}{d\phi} = 0.$ For $V(\phi) = V_{0}e^{-\lambda\phi}$, where $V_{0} = 0.7$, $\lambda = 0.1$ and $V'(\phi) = \dfrac{dV}{d\phi}$ Attempt to solve second-order ODE. def DSDX(S,T): phi,deri_phi = S Declaring some important constants r...
Say I have a mixed integer linear program in variables $x \in \mathbb{Z}^a, y \in \mathbb{Z}^b, z \in \mathbb{R}^c$ together with linear constraints on $(x,y,z)$. I want to count the number of values of $x \in \mathbb{Z}^a$ s.t. a solution $(x,y,z)$ exists. Is there existing software to solve problems of this type? T...
I have a 3D Laplace problem on quite a complicated geometry where I am using Discontinuous Galerkin method. My mesh is composed by hexas, hence I am employing classical tensor product basis functions $\mathcal{Q}^p$. The mesh is not very fine, it is made by $1600$ elements. For every polynomial degree I am solving the ...
I have been looking in detail into one of the many "meta-heuristic" optimization algorithms and became suspicious at how well it appeared to perform (compared to other methods like Nelder-Mead, Multi-Directional search, and Spiral optimization) on a "pathological" test function, Rastrigin. If any of you good people are...
I am currently working on my bachelor thesis, which aims to enhance the multigrid preconditioned conjugate gradient algorithm proposed by Tatebe in 1993 using Deep Learning. Currently, I am implementing it on a 2D lid-driven cavity problem. However, I have encountered an issue where the algorithm from Tatebe is produci...
If we want to use variable preconditioning in Conjugate Gradient, we can replace the Fletcher–Reeves by the Polak–Ribière formula (https://en.wikipedia.org/wiki/Conjugate_gradient_method#The_flexible_preconditioned_conjugate_gradient_method). Is there a similar formulation when the update is performed as in the Conjug...
I solved the 2D heat equation using the finite element method. It all went well first with the adiabatic case, however problems occured when I introduced cooling with the enviroment. I modeled the process with newton's law of cooling: $$ q = h (T - T_{\infty}) $$ Using the term $$ q = k \nabla T $$ Assuming that $k=1$...
I've seen references to the "unit torus" in papers such as this (Start of Sec 3.3, page 5). So, what exactly is a unit torus? Is it just a square or cube in d-dimensions with periodic boundary conditions? I've seen this picture and this mathematical definition but neither seem to provide much clarity.
I want to generate a triangular mesh over a rectangle domain in order to solve Euler equations. Most mesh generator generate a mesh while providing node connectivity for each element. This is convenient for finite element codes. Whereas finite volume codes for unstructured grids requires the center of each element, the...
I have a sparse, undirected and unweighted graph $G$ of size $n$, with $n$ on the order of say several million. I would like to compute the Fiedler vector $f$ of $G$, which is the eigenvector associated to the smallest nonzero eigenvalue of the associated Laplacian matrix $W$. My current method is to compute the larges...
I have a computational graph (DAG) consisting of element-wise operations (potentially with broadcasting) and reshape/reduce operations (reshaping/sum/max). I'm trying to understand how vertical kernel fusion is performed and whether it's something that can be done without developing/using external tools like a linear a...
I am exploring Higham's excellent Accuracy and Stability of Numerical Algorithms and chapter 4 is dedicated to summation. So I decided to test the most basic thing. Summing positive random numbers uniformly distributed between $0$ and $1$ (exactly $2^{20}$ of them). I was expecting that first sorting (increasing order ...
In the first-order upwind scheme, numerical diffusion can be quantified as: $$\frac{dT}{dt} = -w\left(\frac{dT}{dz}\right) + \left(\frac{wdz}{2}\right)\left(\frac{d^2T}{dz^2}\right)$$ For Lax-Wendroff, it is: $$\frac{dT}{dt} = -w\left(\frac{dT}{dz}\right) + \left(\frac{w^2dt}{2}\right)\left(\frac{d^2T}{dz^2}\right)$$ I...
I am studying DG and I've seen that it's possible to define a multigrid method. Let's consider two nested grids $\Omega_{l-1}$ and $\Omega_{l}$ and $V_{l-1}$ and $V_l$ classical DG spaces, both of order $p$, with basis $\left\{\varphi_1^l, \dots, \varphi_{n_{l}}^l\right\}$ and $\left\{\varphi_1^{l-1}, \dots, \varphi_{n...
I would like to ask Python to compute the determinant of a large symmetric matrix where all off diagonal entries are known. The diagonal entries could vary. Since I need to compute the determinant many times with different diagonal entries, it seems a waste of time when the computation involves the multiplications of a...
I am trying to solve below ODE equations for Raman model but I am having errors, mostly overflow in multiply and add. Please I need your help. Below is the code I have written so far. I am new to Python thought. Thanks import numpy as np import math import matplotlib.pyplot as plt # Solving Raman model equations using...
Constructing Modified Euler Using the same strategy as done in the construction of Modified Euler. Starting from Trapezoidal Method $$y_1 = y_0 + \dfrac{h}{2}\left(f(x_0,y_0) + f(x_1,y_1)\right)$$ then approximating $f(x_1,y_1)$ using the explicit euler $y_1 = y_0 + hf(x_0,y_0)$ , thereby constructing the modified eule...
I am looking for comprehensive literature (papers, books, reports etc..) on iterative solvers for solid and structural mechanics problems to understand the best iterative solvers and preconditioners for general problems consisting of anisotropic and unstructured meshes with elements with large aspect ratios and multi-p...
This may be an easy question to answer but I am really stuck. In several topics (especially that of quasicrystals) the Fibonacci chain's Fourier transform and diffraction pattern is mentioned. Despite the chain not being periodic, its diffraction pattern shows sharp peaks (a hallmark of quasicrystals). See for example ...
I'm trying to model some two-dimensional waves, and am unsure how to combine my boundary conditions with spectral methods. The PDE I'd like to explore resembles the equations for damped, driven bending-mode waves in a thin disk or beam: $$\ddot w(\boldsymbol x,t) = -c \nabla^2 \nabla^2 w(\boldsymbol x,t) - d \dot w(\bo...
I have seen finite difference methods for fluid equations (Stokes and Navier--Stokes) that solve a pressure problem first and then a fluid problem. That is, although they solve two different problems, they are two smaller problems, which from a computational point of view is a tremendous advantage compared to solving o...
I'm looking for a way to implement the regular Coulomb wave function in python. This function is a solution to \begin{align} \frac{\text{d}^2\,u}{\text{d}z^2}+\left(1-\frac{2\eta}{z}-\frac{\ell(\ell+1)}{z^2} \right)u(z)=0 \end{align} The regular Coulomb wave function is given by \begin{align} F_\ell(\eta,z) = C_\ell(\e...
TL:DR How can one implement a bifurcation diagram of a seasonally forced epidemiological model such as SEIR (susceptible, exposed, infected, recovered) in Python? I already know how to implement the model itself and display a sampled time series (see this stackoverflow question), but I am struggling with reproducing fi...
Suppose I want to solve an overdetermined linear least squares problem $$ x = \operatorname*{argmin}_{x\in\mathbb{R}^n} \| Ax - b\|^2 $$ where $A \in \mathbb{R}^{m\times n}$ has full column rank. I make no assumptions that this system is nearly consistent. Suppose I know a have access to a matrix $P\in\mathbb{R}^{n\tim...
Assume that $f$ is defined as a composition of functions: $$f=f_2 \circ f_1$$ where $f_1:\mathbb{R}^n \rightarrow \mathbb{R}^{m_1}$ and $f_2:\mathbb{R}^{m_1} \rightarrow \mathbb{R}^n$. We can compute the Jacobian $J_f(x)$ using the chain rule: $$J_f(x) = J_{f_2}(f_1(x))J_{f_1}(x)$$ and we can also compute the Hessian $...
I read somewhere that the Measn squared error loss function acts as L2 norm of the paramter vector. I would like to know if I am using binary cross entropy loss function, do I need to calculate the norm seperately? or the BCE loss function also acts as a norm? As an additional question I would like to know that is grad...
I have working on 2 ways of training a neural network. The first method uses gradient descent updates the model with Adam optimizer. the second method minimizes the norm of the gradient of the functions and updates the network. What is the difference between the two? does normal gradient descent guarantee minimum norm...
I am interested in computing integrals of the form $\iint_{P\times P} Q(x_1,x_2,y_2,y_2) dxdy$ where $P$ is a polygon and $Q$ is a polynomial. The coordinates $(x_1,x_2)$ are in the plane of $P$. Of course $(y_1,y_2)$ represent again coordinates in the plane of $P$, possibly different from previous ones. The above inte...
How should I modify the following matrix formulation of a finite element (FE) approximation of Poisson equation at the (internal) interface denoted by the nodes $i-1$ to $i+1$ having a continuous 1st derivative $\epsilon_1 \nabla\cdot U_1 = \epsilon_2 \nabla\cdot U_2$ at the internal interface nodes (say from $i-1$ to ...
I have a distributed matrix in block cyclic layout. Is there an efficient way to out/in place transpose a distributed matrix with scalapack? Context: I am trying to diagonalize the transpose of a distributed matrix with pzheevd EDIT: Thanks to Ian Bush, It fixed the problem. Bit curious if there is a nice way to do it
I am just starting my MSc and we have been given an assignment in which we must model two-dimensional, laminar, incompressible Poiseuille flow in a channel. We are supposed to use a VELOCITY INLET inlet boundary condition and two different outlet boundary conditions - the OUTFLOW boundary condition and the PRESSURE OUT...
I'm new to Gmsh and after browsing many sites I haven't found the answer for this silly error. Using the native language of the software, I'm assigning a value to the Transfinite property of a bunch of lines (with no consecutive ID's) in my model, using this syntax: value = 10; For i In [81, 83, 85, 87, 72, 73, 75, 77,...
I'm starting to look at ways to analyze the output of a mass spectrometer. My first searches led to some white papers far from what I'm looking for (complex molecules vs simple atoms for me). With mass spectrometers being over a century old I'd thought it'd be easy to find algorithm to extract data from the spectra, bu...
I'm searching for an algorithm that can generate a set of 500 to 2000 characters from the alphabet a-z, A-Z, 0-9 (no interpunctuation) where the set has the following properties: highly compressible with gzip, ideally compressing 2000 characters input to 200 characters output, and generated text looks "random enough" ...
I am trying to solve the following problem: $$ \frac{d^2y}{dx^2}=\sinh(y) $$ Where the boundary conditions are: $y(0)=-1$, and $ \frac{dy(x\rightarrow \infty)}{dx}=0 $. Through central difference approximation, this can be simplified to: $$ y(x_{i+1})-2\cdot y(x_i)+y(x_{i-1})=h^2\cdot \sinh(y(x_i)) $$ Where $h$ is the ...
I am interested in computing the dispersion / phase error(s ?) of an (explicit) Runge-Kutta method when applied to a linear system of ODEs $$ u'(t) = A u(t). \tag{1} \label{1} $$ To begin, consider the linear test equation $$u_t = \lambda u = (x + iy) u \tag{2}$$ and a $S$-stage Runge-Kutta method with stability polyno...
I'm soon going to start a job as a Scientific Computing software developer. My responsibilities as discussed with the manager are as follows: Analyzing/understanding the existing functionalities (numerical algorithms and physical models) in the 2nd version of the code, written in Fortran. Acquiring skills and knowledg...
I'm looking at the solution to a structural mechanics problem that is modeled with first-order elements and then as a comparison with second-order elements. It is clear that the first-order elements behave as very stiff elements and give very different displacements compared to the second-order elements. But shouldn't ...
LAPACK.gglse allows me to solve min x^T Q x s.t. A x = y (in my present use case, $Q$ is symmetric positive definite) without having to think about the numerical stability, computational efficiency, and bug potential of my own attempts of wiring up the solution x^* := L y where L := Q^{-1} A^T (A Q^{-1} A^T)^{-1} Doe...
recently I need to solve a 2D steady state PDE equation. It’s not time dependent, and the only two independent variables are z and r direction. So far for this solution, I was thinking using Method of Lines (MOL) to semi-discretize only the r radius direction and source term, leaving the spatial z coordinate and Tempe...
I am looking for advice on what numerical methods to consider to solve optimization problems like the following, ideally with as few evaluations of the objective function as possible. I am looking to maximize a one-variable function $f(x)$ on an interval $[a, b]$. The function is a black box and cannot be computed out...
I have an oscillatory data generated vs time as shown below. Essentially, I want this data to be averaged and free of any oscillations. I am not satisfied with the results from a simple moving average algorithm. Which moving algorithms or approaches are worth trying?
Please, someone tell me what is wrong in my code it does not give any outputs ( No plot nor print). The code is as below: from scipy.integrate import solve_ivp import numpy as np import matplotlib.pyplot as plt from math import sin, cos, pi def f(t,p): # assigning each ODE to a vector element r,θ,ϕ,x,y,z = p ...
I have multiple set of input (5 parameters) and output from an unknown function. But I know this is a polynomial function. What method can I use to optimize to find the polynomial variable that can fit those parameters? A lot of optimization method that I know need a known function. I have tried optimizing the polynom...
In a current research project, I have a number of matrices with coefficients in ℚ[] for which I want to understand how their rank depends on the value of the parameter . These matrices are: sparse (a typical example is a matrix of size 160x200 with less than 10 non-zero entries per row), rather 'regular' (each entry i...
Recently I have obtained a csv value form and experiment I have computed. However, I was trying to understand how each individual component being calculated. The image attached shows sample point deformation with time as each row represent a time step (I am not sure if I can upload the csv file here as there is no uplo...
I am running a program that uses [a lot of] looping to perform a type of bootstrap analysis. The computational step - PCA - can take a long time (60+) seconds, which means that collectively this program could take almost a week to run serially. I have tried using multiprocessing on a high performance cluster - using co...
Do you suggest any references (papers, monographs, books) about the philosophy of computational science? Recently, I found out about the following two: Winsberg, E. (2009). Computer simulation and the philosophy of science. Philosophy Compass, 4(5), 835-845. Winsberg, E. (2010). Science in the age of computer simulat...
as I have to design a reactor and therefore have to get its length x, I have to solve the following differential equations: $$D_{eg}\tfrac{d^2A_g}{dx^2}-u_g\tfrac{dA_g}{dx} = k_la_b\left(\tfrac{A_g}{H_A}-A_l\right)$$ $$\frac{}{}D_{el}\frac{d^2A_l}{dx^2}-u_l \tfrac{dA_l}{dx}+ k_la_b\left(\tfrac{A_g}{H_A}-A_l\right) = (1...
Where can I find a source code for the SSOR method with Eisenstat's trick? The original paper includes pseudo code but also seems to have minor typos. For that reason, I would be very happy to see an implementation somewhere. Unfortunately, I haven't any in the common libraries (perhaps the code is hidden to deep).
I am trying to compute $\mathbf{X}\mathbf{u}$ for many times in my algorithm, where $\mathbf{X}\in \mathbb{R}^{n\times m}$ and $\mathbf{u} \in \mathbb{R}^{m}$. The problem is that, during the computational process of the algorithm, $\mathbf{X}$ is a constant, however, more and more elements in $\mathbf{X}$ can be chang...
I already asked this question on StackExchange Mathematics, but it seems too domain-specific. Searching where to put Computer Vision related questions it was suggested to use Computational Science since there is no specific CV StackExchange branch. With the direct linear transform, one can calibrate a camera and receiv...
I was reading a book by Simon Haykin on neural networks when I came across the following strong statement (on the pdf's page 188): "However, we still have a computational complexity that is $\mathcal{O}(W^2)$, where $W$ is the size of weight vector $\mathbf{w}$. Quasi-Newton methods are therefore computationally imprac...
What are the most prominent use cases for Java in scientific computing? I've viewed the domain heavily C/C++, Fortran and possibly Python dominant, but what about Java?
Software like Diamond and VESTA allow users to build a supercell by extending the structure along the basis vectors of the latttice. However, I'd like to do something more general and build a supercell from an arbitrary integer matrix transformation. For instance, if I want to convert a primitive hexagonal unit cell in...
I am developing a model to represent a dam, shown in the picture below. The geometry in the white circle is the curtain, which is required to be curved. I extruded this 2D face (including the indicated by the cut white line) at a distance $z_0$ to the back, resulting in the shape in the red circle. Given some constrain...
Context: I am trying to reproduce a figure from Keeling 2007 that illustrates time lags that can occur between the peaks (maximum) of the infected solutions for two subpopulations of a metapopulation model that uses deterministic $SIR$ equations (where $X=S$ and $Y=I$). The equations that model the subpopulation dynami...
Problem description We have a graph $G=(V,E)$. $V$ is the set of nodes. $c_{ij}$ is the profit of traveling through edge $(i,j)$. $T=\{1,2,3,...\}$ is the set of discrete time steps. At each time step, we have a set of packages that we need to transport to their destination. $d^t_{i,j}$ is the maximum number of package...
I am trying to solve a simple working example, a linear system $Ax=b$, where $A$ is sparse SPD and $b$ is dense, using CHOLMOD. #include <cmath> #include <iostream> #include <vector> #include "suitesparse/cholmod.h" int main() { cholmod_sparse *a; cholmod_dense *x, *b; cholmod_factor *L; cholmod_common...
I am trying to solve a discontinuous ODE using the lsode solver. I tried setting the t_crit parameter to specify the time where the discontinuity is present, but it didn't help. The analytical solution of the ODE looks like the following, where the discontinuity appears at $t = -0.433$, which is the value I set to the ...
VTK has had support for visualizing arbitrary-order Lagrange elements for a while now, but there aren't many resources out there (as far as I know) facilitating their use. Notably, these elements rely on a particular "onion-like" node ordering which many solvers (including mine) don't use by default. This means that pe...
I wish to compare the value of the normalized concentration (c+), between two contour plots (one is experimental and another is a simulation). If I don't have a c+ value from the same point on both plots, how can I compare? (A few data points and interpolation generate them). I want to know which turbulence model per...
I want to solve the compressible 1D Euler equations numerically. Theory says that for subsonic inflows, one can prescribe two variables, e.g. pressure and temperature. Density can then be computed with the equation of state, but how is the velocity calculated? For subsonic outflows only one variable can be prescribed. ...
Let $x$ and $y$ be representable floating point numbers. I'm looking for a unit test which can ensure that my user's compiler has not made the reciprocal approximation $\mathrm{fl}(x/y) \approx \mathrm{fl}(x)*\mathrm{fl}(1/y))$ as an optimization. However, I have been unsuccessful in coming up with a compelling example...
I've been working with TensorFlow and I'm very impressed with its automatic differentiation capabilities. I'm wondering what the state of the art in automatic differentiation for finite element methods (and other pde solvers) is. Has automatic differentiation rendered adjoint methods for computing sensitivities of obje...
Is there a fast method to compute an orthogonal complement of an arbitrary matrix $U\in\mathbb{R}^{m \times n}$ in BLAS / LAPACK? Specifically, I want any matrix $V\in \mathbb{R}^{m \times (m - \text{rank}(M))}$ such that $$ \text{rank}(U|V) = m. $$ The singular value decomposition methods in LAPACK can do this if call...
I want help with my Octave code regarding the unsteady heat equation. My geometry and mesh are generated with FreeFEM++, so there is no problem with that (I tried it with the steady problem with no for loop and it worked just fine). But when I introduce the for loop to iterate with the time step and try to visualize th...
I need to compute the logarithm of the binomial coefficient, $$\log\binom{x}{y} = -\log\mathrm{B}(y + 1, x - y + 1) - \log(x + 1)$$ accurately, where $\mathrm{B}(x,y)$ is the Beta function. I'm aware of packages computing $\log\mathrm{B}(x,y)$ accurately, but even using these I get some cancellations in the above formu...
I've got some code that I need to squeeze every bit of both time and space out of. I'm looking for a better solution to the following problem. For reasons outside of the scope of this question, I wrote a non-native data type Z2 that effectively wraps an array of three int8_ts and defines some operations over them. Most...
I want to calculate the total time taken for a fixed code run using an NVIDIA GPU (for instance, Tesla K40). The code has to run 1 million single-bit comparisons. All the comparisons are independent of each other. There is no memory access involved during the execution of the code since the complete data (2 bits per co...
Me and one of my colleague are trying to simulate the three-body problem with a C++ program in order to compare different integration schemes. At the moment we are trying to use the Euler's method, but we're stuck on a divergence problem. Using the attached code we obtain the result in the figure below, in which the th...
Recursive least squares can be implemented using the Sherman–Morrison formula to avoid resolving, however, have better methods without $n^2$ cost been developed? I'm interested if there is a good randomized approach here.
first of all thank you for all the answers you gave me yesterday for the integration via Symplectic Euler's method of the three-body problem. We managed to implement both Euler's and Runge Kutta 4's method using C++, but the results are distinct. Since the three bodies move chaotically, we cannot understand which of th...
In the paper [1], author has discussed a distinction between the 3 types of computations: numeric, combinatorial, and geometric. The author says that Geometric computation is one that has elements of both combinatorial and numeric computation. That is: Geometric Computing = Numerical + Combinatorial Computing. Numeric...
I have a bit lengthier ODE function which was simulated by using Scipy solve_ivp function. During this simulation I calculated many parameters but as the output, I am taking out put only some other parameters in return function. But now I need to get some values of some other variables I used during the intermediate st...
For solving a linear system, $Ax = b$. If $A$ is a dense but symmetric $n \times n$ matrix, how much memory is required? $A$ is symmetric, which means only the upper (or lower) triangular part of $n \times (n+1)/2$ entries would be necessary. Does $A$'s memory requirement have to be 8 bytes $\times n \times n$ or can i...
I am struggling with this assignment. I have to write an upwind scheme for the following PDE: $$u_t+a Du=0 \quad\mathrm{on}\;(-1,3)$$ $a$ is said to be positive, the initial condition is $\sin(2\pi x)$ and periodic condition on the inflow border. It seemed easy to me so I wrote this on Matlab but I am struggling with c...
Could someone please point me to an understandable definition of the Kolmogorov n-width? I'm having a hard time figuring out what is the output of the definition - is it an integer? Edit: I realize that my question was not well-posed. This paper defines the Kolmogorov n-width as $$ d_n(\mathcal{M})= \inf_{\mathcal S_n}...
How to efficiently convolve the function $h(t)=H(t)e^{-t}$ with a function $x(t)$ sampled non-uniformly, i.e. $\{x(t_0), x(t_1), ..., x(t_{N-1})\}$? $H(t)$ is the Heaviside step function, and the Fourier transform of $h(t)$ is $\tilde{h}(\omega)=(1-i\omega)^{-1}$. What I have done If $x(t)$ is sampled uniformly, I can ...
This is not a homework, but a hobby project, and maybe not all terms I use are correct - please help to fix. Imagine there are K vectors in n-dimensional space. I would like to: validate whether they can correspond to K+1 planes enclosing a volume (is that called a polytope?) validate whether a given further vector is...