instruction
stringlengths
43
28.1k
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'm studying the weak formulation of NS equations. During the analysis, the book I'm using (Quarteroni-Valli, page 301-302), defined $$Z_h=\{v_h \in V_h: (\operatorname{div}(v_h),q_h)=0 \quad \forall q_h \in Q_h)$$ where $Q_h \subset Q$ and $V_h \subset V$ finite dimensional subspaces. Here we can set $V=[H_0^1(\Omega...
In my finite element notes, after the proof of the global estimate for the interpolation error, assuming a regular triangulation with triangles $T_m$: $$\sum_m|v - \Pi_h^r v|_{s,p,T_m} \leq \sigma^{-s} h^{k+1-s}|u|_{k+1,\Omega}$$ for $u \in W^{k+1,p}(\Omega)$ where $\Pi_h^k:C^0(\Omega) \rightarrow X_h^k$ and $X_h^k= \...
Let's take a mobile robot and suppose we know its continuous equations of motion, for example this car-like simple model. Now if I am simulating this robot in a continuous 2D plane, then coding the simulation is simple. But suppose i am now in a 2D grid world. Movement is only from one cell to another cell. Now how do ...
I am trying to solve a fractional-order 2-compartment model using the method of manufactured solution (MMS). I do understand the concept of MMS, but I am not sure how to come with a Mathematica code for such a system
I'm having lots of troubles in understanding the proof the estimation of the classical $H^1$ error using finite elements of degree $r$. $$||u-u_h||_{H^1(\Omega)} \leq \frac{M}{\alpha} C h^r |u|_{H^{r+1}(\Omega)}$$ where $M$ and $\alpha$ are the operator norm and the coercivity constant, respectively and $C$ is a consta...
I am working on simulating a car suspension system using Matlab. Specifically, I have to derive equation of motion using the Lagrange method and then use ode 45 to solve it. However, while using odetoVectorField I keep getting the error: System contains a nonlinear equation in diff(theta_rod_1(t), t). The system must b...
Suppose that $x = (x_1, ..., x_n)$ is a vector of variables and I would like to maximize the Shannon entropy of $\frac{|x|}{||x||_1}$ (i.e. the vector of absolute values of $x_i$, normalized to have $l_1$ norm = 1) subject to some linear constraints. However, this function is not directly expressible as a composition o...
I am solving an Integer programming using MATLAB, yet the efficiency is low. Here is the problem: Suppose $v$ is a $N \times 1$ vector. For $v_i \in v$, $v_i \in \{0,1\}$. $D$ is a 0-1 matrix, which means for each $d_{ij} \in D$, $d_{ij} \in \{0,1\}$. The translation of this problem is to make element $1$ in $v$ to be ...
Problem I have an $n\times n$ grid, and each point on the grid is assigned two values: a score, and an (inverse) speed factor. There is a "turtle" moving along the grid, and it's goal is to maximize it's score. Each time it moves to a point $x$ it gets the score $s_x$ at that point, but it takes $\epsilon_x$ turns befo...
In the expression: $${\underset{\Omega}{\min}\left\|\beta A\Omega^{-1}B+C\right\|_{F}^{2}}\, ,$$ $$\text{subject to tr}(\Omega)=1, \Omega \ge 0\, ,$$ where ${\Omega}$ is nonnegative and symmetric matrix. How to solve for the variable $\Omega$?
I think the relres in MATLABis the form that relres = norm(M(b-Ax))/norm(M\b),when it smaller than tol then stop the iteration. I want to know how to change relres to norm((b-Ax))/norm(b). Or use other code instead of the built-in one
I'm studying adaptive meshes, and my professor wrote the following property for a bubble function ( see this scicomp post for the definition I'm using)$b_T$ defined on a triangle $T$. $$||b_T \phi ||_{0,T} \leq ||\phi||_{0,T} \color{green} \leq c||b_T^{\frac{1}{2}} \phi||_{0,T} $$ The proof of the green ineuqlity is gi...
I'm using conformal mapping to solve a 2D electrostatic problem (calculating the potential $u(x,y)$ in the plane). Let $C_1$ and $C_2$ be two circles at an electric potential $U_1$ and $U_2$, respectively. They have radii $R_1$ and $R_2$, respectively, and their centers are separated by a distance $h$. I noticed that, ...
The answer to Convolute a gaussian kernel with a large array of off-grid centroids without looping? (how to make "A Thousand (Gaussian) Points of Light" ) involves summing a 3D array over its stacked direction. This question however is about convolution using continuous functions rather than summation. The answer there...
For a finite object size diffraction simulator, I need to generate arrays which are the sum of thousands of instances of a Gaussian (or other) 2D kernel at centroids that will not fall in any repeatable way with respect to the grid points. Below is a simple example with a simple hexagonal arrangement of centroids for c...
I have an ordinary differential equation that is solved as an initial value problem using different numerical schemes. I end up with several discrete time signals that should display a reasonably identical solution but most likely have different time steps. I would like to quantify the similarity of the solutions comin...
I'm studying the inf-sup conditions for saddle point problems. I'm referring to the usual one $$\begin{cases}Au + B^t p = f \\Bu=g \end{cases}$$ In the book I'm using (Ern - Guermond: Theory and practice of FEM) they say (pg. 100) The problem is well posed iff $$ \exists \alpha >0: \inf_{u \in \ker(B)} \sup_{v \in \k...
I wanted to learn how to implement a code for the Stokes and Navier--Stokes equations 2D/3D. I already know how to implement it when the elements are triangles or tetrahedral. Do exists finite element schemes using only square/cube elements for the pressure and velocity? Can you suggest me some paper or book with the m...
please help me with this question, I want to invert a huge sparse (non-circulant) this below in a $Ax=y$ equation: $$(\lambda I+ \beta D+ \sigma C)x=y$$ where I is an Identity Matrix,D is a Diagonal Matrix,C is a circulant Matrix and $\lambda$, $\beta$, $\sigma $ are positive constants. And all have the same size of 10...
I'm solving a system of stiff ODEs describing atmospheric chemistry and transport. I am using CVODE BDF from Sundials Computing. I have two ways to approximate the jacobian: Allow CVODE to approximate the jacobian with finite differences. I have a function for the jacobian, which uses a mixture of finite differences a...
First time posting here, so I apologize for any missing info upfront. I am working on a program in VBA that calculates a function (which itself calls another function), then calculates the derivative of that function, then uses that to form a Jacobian matrix to calculate the solution via the Newton-Raphson method. My q...
I'm studying mixed finite elements. The problem is a classical saddle-point one: we seek for $(u,p)$ in $V \times Q$: $$A u + B^t p = f$$ $$Bu = g$$ where $A: V \rightarrow V', B:V \rightarrow Q'$ and $V,Q$ are Hilbert spaces. For this problem, we have the inf-sup conditions on $A$ and $B$ that essentially tell us tha...
If we had, for example, labeled data, where for each entry (label) we have several data distributions associated to it, how can I get something meaningful from them? Is this a solvable problem? Is there a better way to solve it than just taking some parameters which describe the data (mean, standard deviation, etc.)? D...
Consider the Stokes problem and the usual divergence operator $B:V \rightarrow Q'$, $\langle Bv, q\rangle = b(v,q)=(\operatorname{div} v,q)$ and its discrete versione $B_h : V_h \rightarrow Q_h'$. In the lecture notes, I read the following consideration: It must be $\dim(V_h) \geq \dim(Q_h)$. If not, then $\ker(B_h)= ...
Is there any example support the case of $O(n^k)$ where $k$ has a fixed calculated value for every $n$ and $k$ is not a constant value for all $n$. As $k$ depends on the value of $n$ in polynomial representation. Also, I wonder, what is its type of time complexity?
I calculate 2D Model of Magnetotelluric responses which are apparent resistivity and phase. I do the calculation for Transverse Electric (TE) mode. Then I used edge based finite element with triangular element. When using finite element there are no problems till I get the result of the finite element calculation. I ge...
The leap-frog algorithm is able to conserve to a certain extent the energy of a system, which flucutates as a cosine around a stable value. Is this true if we apply the algorithm to a n-body gravitational system? Does the energy of the system stay between two values or grows with time?
When someone refers 2-norm of system,L2 and H2 are used interchangeably by author and is rather confusing. Even the matlab has different functions for H-infinity norm and L-infinity norm. as shown in picture the author refers it as L2, and later he refers it as H2 . so what is difference and when someone says 2-norm of...
I understand that the Arnoldi iteration produces a basis which tends to include in its span the eigenvectors corresponding to eigenvalues of large magnitude (hence the analogy between the last vector of the Krylov subspace, $A^{n - 1} b$, and the result of $n - 1$ iterations of power iteration method made in this Wikip...
Consider the following PDE \begin{align} -\Delta u &= f \ \ \text{en} \ \ (0,1)\times (0,1) \label{P1} \\ u &= 0 \ \ \text{en} \ \partial ((0,1)\times (0,1)) \label{P2} \end{align} if we use 5-point finite difference approximations we get a system \begin{equation} Ax = b \label{Sist_Planteamiento} \end{equation} wh...
I am working on a problem where I need to solve approximately 500 Million Linear Regressions (OLS). What would be the most efficient way to do this (e.g. using GPU or a some framework that can do this efficiently)? Note that in my case each individual OLS problem is "small" in size e.g. each input dataset has 100 obser...
I'm trying to debug an FEM that I inherited, and I unfortunately do not have much knowledge of FEM. I only know FD and FVM. If you're modeling a system with 2 materials, there will be an interface location between the 2 materials, where on one side are elements of one material, and on the other side are elements of the...
How to compute 2-norm or infinity norm of following system? i am confused whether to calculate using simple matrix theory "where it don't regard for s domain" or H2 and H-infinty norm. Thanks in advance. The problem is 4.4 from book Essentials of Robust Control
Consider the Navier stokes equation after the discretization with conforming finite elements with source term $f=0$. We have the algebraic structure of a saddle point problem: $$M \dot{u} = f- Au -B^tp - C(u(t))u(t)$$ $$Bu=0$$ where $B$ is the $- \operatorname{div}$ matrix, $A$ is the one corresponding to the laplacian...
From the package scipy.sparse.linalg in Python, calling expm_multiply(X, v) allows you to compute the vector expm(X)@v in a very efficient manner. Moreover, this function works best when X is a sparse datatype (like csr_matrix or csc_matrix). However, I have found that this function works slower when v is a sparse data...
Let $z, b \in \mathbb R^n$, $A \in M_n (\mathbb R)$ and $|z| := (|z_1|, \dots, |z_n|)$. I am searching for an efficient algorithm to solve the absolute value system: \begin{equation} z - A |z| = b. \end{equation} In general existence and uniqueness of the solution is not guaranteed; however, I will assume from now on t...
I am writing a code that checks the orientation of a list of vertices (along with face connectivity) describing both convex and concave hexahedra. The face connectivity table stores the list of vertex indices that constitute each face, as described on p.27 of this document. I flag a hexahedron as being positively orien...
I am trying to solve this with odeint module. But the first equation is function of second equation. If i ignore dw/dz in first equation and second equation is function of first one. I can solve it simply using odeint. I can solve these equation through fsolve through forward differential. But is it possible i can u...
Motivation: My plan is to get the overall euclidean distance matrix for all the vectors in N number of dataset. Each dataset is basically an array of n-dimensional points. For e.g: A dataset can be like [[1,2,3,...n],[1,2,3,..n],...[1,2,3,n]]. However, the datasets are not gonna be shared to a single entity for which I...
I have a system to simulate the bubble evolution at different temperature conditions. I used CVODE_DENSE algorithm to solve the ODEs and get the bubble size and concentration. But the code was halted as the above warning shows up. I tested at different temperatures, like 573 K and 773 K. The code was halted at 573 K at...
We are finding in Python some occasional errors in our coordinate transforms and other similar computations that produce a result of -0.0. What purpose does this serve in Python? So far it creates a zero testing error (that is, -0.0 does not equal 0.0; does it equal +0.0?). The easy test is at the prompt: >>> -1*0.0
I'm trying to perform a 4-dimensional numerical integration in R using a function I wrote in C++ code which is then sourced in R using the Rcpp package. Below there is my code: // [[Rcpp::depends(RcppEigen)]] // [[Rcpp::depends(RcppNumerical)]] #define EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS #include <Eigen/Eigen> #i...
I want to plot the motion of a positive charge in a cylindrically symmetric magnetic field. I am assuming a cylinder around the z-axis, with the magnetic field going in clockwise direction. The B-field has magnitude of 6 T and the distance R from the z-axis is 3 m. The charged particle is launched in positive direction...
I have a nonlinear mixed-integer optimization problem, and because of very high complexity when solving it using methods like Branch and Bound, I resorted to solve it using alternating method and continuous relaxation of the binary variables. So the issue is that the resulting optimum values are fractional. How to prop...
I am trying to solve a differential equation in the form: dx/dt = funct(x) using scipy odeint. However, for some initial values, I get a "ODEintWarning: Excess work done on this call", even if the ODE itself seems to be solvable analytically. Why does the numerical ODE solver give me a warning, and how can I make it wo...
In an introduction to Discontinuous galerkin methods, I have some problems in checking the weak formulation. I'm looking at page 16 here The context is the advection reaction equation: $$\operatorname{div}(bu) + cu = f$$ $$u = g_D \in \Gamma_{-}$$ where $\Gamma_{-}$ is the inflow boundary: $\{ x \in \partial \Omega: b(...
I am reading about QUICK scheme for calculating the value of unknown variable $\phi$ in finite volume method. Given a locally one dimensional flow, we assume the value of $\phi$ is computed as a 2nd order polynomial: $$ \phi = k_0 + k_1 x + k_2 x^2 $$ Subject to: $\phi = \phi_U$ at $x = x_U$ (Upwind) $\phi = \phi_C$ a...
I'm learning DG methods and in order to practice a little bit I'm using the deal.ii library. In particular, I'm looking at step-12, where they solve $$\operatorname{div}(\beta u) = 0$$ $$u = g_D \text{ on } \Gamma^-$$ for a field $\beta$ and a discontinuous data on the inflow boundary. In order to verify the order of c...
I am trying to solve the background equations of cosmology numerically using Runge-Kutta Dormand Prince method with simplified assumption $8\pi G=1$ and $c=1$. The equations are $$\ddot a = - \frac{1}{6}(\rho + 3p) a $$ and $$\dot {\rho} = -3 \frac {\dot a}{a}(\rho +p) $$ for matter$(p=0)$ and radiation $(p=\frac{1}{3}...
I need to solve an equation system $$ \begin{pmatrix} A \\ I \end{pmatrix} x = \begin{pmatrix} b_0\\b_1 \end{pmatrix} $$ in the least-squares sense. Let's assume $I$ is the $n$-by-$n$ identity matrix, $A$ is some $m$-by-$n$ matrix, e.g., Laplace with Poisson boundary conditions. I know a good preconditioner $M$ for $A$...
I came across this line in a class note I am reading where it discusses finding eigenvalues of matrices. In reality we don't go all the way with Arnoldi. We stop at a decent value of . Then the eigenvalues of are (usually) good approximations to extreme eigenvalues of . Trefethen and Bau emphasize for non-symmetric...
If I have a vector of M "continuous" decision variables (say it is called x) , and if I want a constraint to express that only one of them is allowed to have a nonzero value (i.e. no more than one variable can be nonzero). How can I express such constraint?
I've professional experience with physics simulations and C++ programming, although I don't have specific experience with astrophysics simulations. I'm trying to build a two-body evolving system myself, but I'm struggling with obtaining even the simplest stable orbit (more than just a few revolutions). Therefore I'm lo...
I am looking for MCMC codes with a GPU suport (like NVIDIA or OpenCL libraries) to make faster run chains. If someone could have a state of the art ...
I have the problem like this $$ -\triangle u = f \ \ on\ \Omega \\ u = g_1 \ \ on \ \partial \Omega_1 \\ u = g_2 \ \ on \ \partial \Omega_2 $$ If we choose $$ V_1 = \{ \nu_1 \in H^1 : \nu_1 = 0 \ on\ \partial \Omega_1 \bigcup \partial \Omega_2 \} \\ V_2 = \{ \nu_2 \in H^1 : \nu_2 = g_1 \ on\ \partial \Omega_1 \ and...
I have a very simple question concerning Alternating Direction Implicit (ADI) Scheme. If I have an equation of the form: \begin{equation*} \frac{df(x,y,t)}{dt} = \nabla^2 f(x,y,t) + f(x,y,t) \end{equation*} with f, my unknown function. I know how to use it for the diffusion term, but how should I handle the term $...
How to solve for small gamma in the integral equation in Scipy ? I recognize it has to be solved with both the numerical integral and a root solver (Newton's method) $$ \int_{\gamma}^{+\infty}f(x) dx = 0.01 $$ The function f isn't a known analytical function, it is a probability distribution represented by an array of ...
I'm looking at this famous paper which is available in the link below: Franco Brezzi, LD Marini, Endre Süli, Discontinuous Galerkin methods for first-order hyperbolic problems, Mathematical Models and Methods in Applied Sciences Vol. 14, No. 12 (2004) pp. 1893-1903, doi:10.1142/S0218202504003866, ResearchGate. I am ...
I have a complex part that contains features of the form shown in the figure below. Because of the cost of 3D finite element simulation of the part, I want to try an analysis with 2D thick shells. However, I am running into a problem when trying to extract the mid-surface of the part. Automated tools provide me with ...
Given a model $f$ as a programming routine, such that we are able to compute $y=f(x)$ for any $x \in \mathcal{D}$, I am interested in the sensitivity (or let us say derivative) of $y$ with respect to $x$. The important thing is that $f$ could be any model, for instance a machine learning model, a neural network or a mo...
I have a black-box simulation that produces the time evolution of a probability density function p(x, t) in 1 dimension from arbitrary initial conditions p(x, 0). The underlying simulation occurs on a discrete lattice of sites x=0, 1, 2, ... but when p(x, t) is a sufficiently smooth function of x, we expect that the be...
i'm looking for some advice for finite element analisys. i'm a biomedical engineering student with few knowledge about the FEM. Tools like Comsol and Ansys are very powerfull but also complex and i feel more industry oriented because of all the premade settings and configuration to learn. I'd prefer a more basic tool t...
I had written an algorithm that searches for the optimal weight parameter to be implemented in the successive-over relaxation (SOR) method which worked cleanly by vectorizing the interval and for each ω the spectral radius of the iteration matrix is computed. However, I was advised not to use this approach for large s...
Consider the diffusion equation with a coefficient $\nu$: $$-\nabla \cdot (\nu \nabla u)=f$$ with Dirichlet boundary conditions $u = g_D$ in $\partial \Omega$. If the coefficient would be constant, then the weak form (see step-74 from deal.ii library) is: $$\begin{align*} &\sum_{K\in {\mathbb T}_h} (\nabla v_h, \nu \na...
Attached below is some code I wrote to solve a basic problem: finding the node displacements of a cube with two vertices constrained (vertices 6 and 7 with coordinates [1,1,1], [1,-1,1]), and the rest of the vertices loaded with point loads in the y direction. What I expect is for the displacement at vertex 0, with coo...
For a given function $f(x)$, I have tried to find its numerical integral using Simpson's 1/3 and Simpson's 3/8 rules. I then compare the solution from the numerical quadratures to the analytical integral to calculate the errors. I find that the error for the 3/8 rule is double that of the 1/3 rule, while the opposite i...
I am trying to simulate the propagation of light in material using the non-linear schrödinger equation (NLSE): $$\partial_zE=\frac{i}{2k_0}\nabla^2_\perp E+\frac{ik_0n_2}{n_0}\vert E\vert^2E-0.5\beta^{(2)}\vert E\vert^2E-\frac{\sigma}{2}(1+i\omega_0\tau_c)\varrho_eE$$ together with a plasma-generating term $$\partial_t...
I'm using Python's optimize.lsq_linear method to run a linear regression with the bounds set between 0% and 100% power usage. x = optimize.lsq_linear(A, b, bounds=[0,100], method='trf') The A matrix is sparse and there are many situations where some of the X values have very, very little effect on the results. Someti...
I was looking at the Cheney and Kincaid book (6th edition) on numerical methods, with respect to collocation method for differential equations. Now for linear systems of ODES, collocation is just a linear solve. But for nonlinear systems of equations there is a residual function that we minimize. The residual function ...
I met a problem in solving a set of coupled differential equation, as shown below: $$A_1\psi_1(z)+A_2\frac{d^2\psi_1(z)}{dz^2}+A_3\frac{d\psi_2(z)}{dz}=\lambda\psi_1(z)$$ $$A_4\psi_2(z)+A_5\frac{d^2\psi_2(z)}{dz^2}+A_3\frac{d\psi_1(z)}{dz}=\lambda\psi_2(z)$$ with the following 4 boundary condition: $$\psi_1(0)=\psi_1(d...
I recently ran into an interesting result. I have a matrix $D$ containing pairwise distances between all points in a dataset. This matrix is converted to a similarity matrix $S$ via an RBF kernel. Because calculating the full distance matrix is expensive, I use randomized linear algebra techniques to approximate $S$. A...
In successive convex approximation method, can the solution be considered to be an acceptable solution if the algorithm reaches the maximum number of iterations without noticeable convergence? or it must converge to a certain tolerance?
I've always had this question in mind (even if it may sound vague), but in my numerical analysis courses we've always learned how to analyze and optimize code. However, since most linear algebra libraries (i.e. LAPACK, BLAS, etc.) have been continuously optimized by professional developers since the 1980s, I'm question...
To calculate the expected value of objective functions, we have two choices: Sample Average Approximation (SAA): $$ \frac{1}{N}\sum_{i=1}^N f(x,\xi^i). $$ Numerical Integration (e.g., Monte Carlo method): $$ \frac{1}{N} \sum_{\xi^i\in\Xi^N}^N f(x,\xi^i)p(\xi^i), $$ where $p(\cdot)$ is a probability density function an...
I have been reading Kloeden and Platen's Numerical Solution of Stochastic Differential Equations, and have more or less been trying to systematically complete the various exercises therein as I go along. I have been effectively stuck on a single problem for a long while, and despite returning to attack it periodically,...
I am trying to compute the double Richardson and Wolf integrals for the focusing of a lens with Boost in C++ (using the Gauss Kronrod method). As a starting point, I used the example presented in this question. My problem is that I have to perform several integrations (looping in the image space) with variable paramete...
I'm studying an error estimator for the equation $\nabla\cdot(\beta u) + cu = f$ and it contains the following term $$||f - cU_h - \Pi(f-c U_h) ||_T$$ where : $\Pi$ is the local orthogonal $L^2$ projection onto the classical polynomial DG finite element space $\{v \in L^2: v_{|K} \in \mathbb{P}^{r}(K) \}$ $U_h$ is the...
For instance, consider a module with the following general structure: module test implicit none contains function f(x) ... end function f subroutine sub() ... y = f(x) ... end subroutine end module test As such this is incorrect, as is doing something similar insid...
I have the nonlinear PDE $$\frac{\partial U(z,t)}{\partial t} + A(U)\frac{\partial U(z,t)}{\partial z} + B(U)U(z,t) + C(z,t) = 0,$$ where $A(U)$ and $B(U)$ are guaranteed to be real and positive. I want to use the MacCormack finite difference method to numerically solve it. For (Von Neumann) stability analysis, I use a...