instruction
stringlengths
43
28.1k
I am putting into MATLAB code the equations that describe a plastic extrusion process. From a paper, I found I should use a spatial grid that translates with the extrusion speed, being the reference coordinate system the centerline of the extrudate. In particular, $s = 0$ is the extruder die and the length of the doma...
Are there any circumstances under which using a value $w < 0$ would help us find a solution in over-relaxation faster than we can with the ordinary relaxation method? Over Relaxation Method: $$x'= [1 + w]f(x) - wx$$ Example Calculating $x = 1-e^{-3x}$ Take x = 1 as initial value, and w as 0.2 x' = (1+0.2)f(1)-0.2(1) = ...
Essentially I want to use paraview to recreate a flow visualization like the one shown in the picture above. I am able to create the 3d flow lines using a pipeline that looks like data (csv)-> TableToStructuredGrid -> Calculator-> ExtractSubset -> StreamTracerwithCustomSource where I have used the subset as my seed. ...
I am trying to finish a series of interpolation functions. The problem is more related with organizing the data than how to do the interpolations. Using the RegularGridInterpolator, I created this function: def interp_3d(x,y,z,fxyz,x_desired,y_desired,z_desired): interp_func = RegularGridInterpolator((x,y,z), fxyz...
So I am trying to do some further tests on a 2nd-order code Incompressible Navier Stokes equations, by studying transition to turbulence in a Poiseuille flow. Specifically, I'm interested to see whether the code is energy-conserving by modelling a 3D TS wave in a Poiseuille flow. Note that I have tested the code for a ...
My friend in the statistics department asked me how to do the following calculation efficiently. Suppose we have data $X\in\mathbb{R}^{N\times 2}$. He needs to do the following calculation: $$C_{i,j}=\sigma^2\exp\left(-\frac{||X_i-X_j||_2}{\theta}\right)$$ where $X_i$ is a tuple with two elements and $\sigma,\theta$ ar...
I am solving the following biconvex problem: $$\min_{x,y} f(y)$$ $$s.t. ~~ g(x) \leq 0$$ $$~~~~~h(x,y) = 0$$ $$x \in X, y \in Y$$ where $X$ and $Y$ are compact convex sets, $g(x)$ and $f(y)$ are convex and $h(x,y)$ is affine for fixed $x$ or $y$. I wonder if there is any efficient algorithm to solve this type of optim...
ReLU activation is defined as follows $$\sigma(x)=\max(0, x).$$ Let's assume that I have deep network of 1 hidden layer, than output from my layer has form $$ f(x)= \sigma(Wx +b), $$ where matrix W represents the weights, b is bias and x stands for input data (output of previous layer). What is connection between $f(...
I wanted to test the numerical accuracy of my program. For that I wanted to interpolate the function $$f=I_0\exp\left(-100x^2\right)\exp(-100y^2)$$ onto a grid, defined on $$\Omega=[0,1]^2$$ by using the equation $$u=f$$ and the continuous galerkin method. In addition I compared the result with the expected (interpolat...
Reading ARPACK documentation, I see that ARPACK will return an "orthogonal basis for the invariant subspace corresponding to the eigenvalues in D" if eigenvectors are not requested. Can this subspace be exploited in some kind of restart capacity? Documentation discusses restarts but I'm not sure how these have been imp...
Assume I have a system of at least (but generally only) $N+1$ points in an $N$-dimensional space ($N > 3$ is possible). At each of these points $x_i, i=1,...,N+1$ I know an initial potential/concentration/quantity $P_i$. I can evaluate the possible connections between all points. I also have an isotropic diffusion coef...
Please note: this question is not a duplicate of this question since, while the PDE is the same, the nature of this question is different, i.e. the other question treats a different aspect of this PDE. Here is the PDE system I am working with: $$\partial_tu = \nabla \cdot (a(x)\nabla u)-\beta(x)u\\ \partial_nu=0, x \in...
The PDE I am working with: $$\partial_tu = \nabla \cdot (a(x)\nabla u)-\beta(x)u\\ \partial_nu=0, x \in \Omega \subset \mathbb{R}^2\\ \beta(x)>0$$ Integrate the PDE: $$\int_\Omega \partial_t u=\int_\Omega \nabla\cdot (a(x)\nabla u)dx-\int_\Omega \beta(x)udx$$ Apply the Divergence theorem: $$\int_\Omega \partial_t u...
With a truncated Whitaker-Shannon series (cardinal series) $$ f(t) = \sum_{j = 0}^{n-1} y_{j} \frac{\sin\left(\pi( \frac{t-t_0}{h} -j)\right)}{\pi\left(\frac{t-t_0}{h}-j\right)} $$ we can naively evaluate the sum by repeated calls to sinc routines, such as the following code does: Real naive_sum(Real t) const { ...
I'm wondering if someone could help me out, or point me in a direction of how I can understand the following oscillations that occur when I solve the Porous Medium Equation $$u_t = u_{xx}^{m+1}$$ using FTCS method. The following plots occur for a the following initial condition $$ f(x) = \begin{cases} 1 & \text{if}\ |...
First Part: (First-order derivative) Assuming $f$ is an infinitely differential function everywhere, the Taylor series of $f(x + h)$ at $x$ is \begin{align}\tag{1} f(x + h) = f(x) + hf'(x) + \frac{1}{2}h^2f''(\xi) \end{align} where $\xi$ is a number between $x$ and $x+h$. After rearrangment of terms in (1), we can wri...
I am currently trying to solve some PDEs with FiPy. At page 56, the manual mentions (https://www.ctcms.nist.gov/fipy/download/fipy-3.0.pdf). The largest stable timestep that can be taken for this explicit 1D diffusion problem is $∆t ≤ ∆x^ 2/(2D)$. A few questions that might appear basic but I'm having a really hard t...
Now I have wave functions $\psi_a$ and $\psi_b$ of two states in Gaussian CUBE format. I'd like to evaluate the transition dipole moment integral $\pmb\mu$ between these two states. As my simulation cell is cubic periodic with length of $L$, I will need the Berry phase formula to calculate $\pmb\mu$: $$\pmb\mu= \rm{IMA...
I have a 32 cores machine, and I need to run 16 different dynamics simulations in parallel on it. I want the 16 jobs to run in parallel, not sequentially, on the same machine. The 16 dynamics input are in different folders and they requires the same time to complete. pbs script: #!/bin/bash -l #PBS -l nodes=...:ppn=3...
I currently have 2 different functions with options to vectorise them: acc_rej_sine(max_iter, algorithm=None) and analytical_sine(max_iter, algorithm=None) for which I'm trying to compare their run time against the number of iterations computed. i.e. compare all 4 methods; 2 looped, 2 vectorised. Essentially my code go...
Consider the advection equation (1D in space) $$ \frac{\partial u}{\partial t} + V\, \frac{\partial u}{\partial x}=0 $$ and we solve it numerically on $[0,1]\times [0,1]\ni (t,x)$ using a forward scheme in time and a backward decentered in space. This scheme is of order $1$ in space and of order $1$ in time and is sta...
I am trying to implement a routine to solve a differential equation in Python. Basically the kind of equation that I am interested in solving is of the form: $$\displaystyle \frac{d}{dx^2} \left(x y(x) \right) = 2 x ((U(x)-a) y(x)+ 2 b y(x)^3)$$ where $a$ is an unknown constant and $b$ is a known constant and $U(x)$ is...
I'm looking for current references on solving stiff ODEs. Most of what I know (say, BDF methods) apparently date back to the 1980's, and I feel like a lot of progress should have been made in that time, but I'm having trouble finding the "right" search terms to get what I need. What are the (current) best methods for s...
I was trying to implement the algorithm from the paper "Adapting a Fourier pseudospectral method to Dirichlet boundary conditions for Rayleigh–Benard convection". I am having a hard time to understand the way the boundary conditions are imposed. The author rewrites the no-slip (on upper and lower boundaries) boundar...
I have heard of space-time finite element methods. Although I was able to find some articles that describe the different possible methods from a mathematical point of view (thanks to Space-time finite element discretization for time-dependent PDEs for instance), I would like to know with more detail what are the main a...
I have a system of 10 ordinary differential equations of the form, $$\frac{dy_1}{dt} = f1(V1,k1,y1,y2)\\ \vdots \\ \frac{dy_{10}}{dt} = f_{10}(V_{10},k_{10},y_{9},y_{10}) $$ I want to estimate the parameters $V_1 ,V_6,V_7,V_{10}$ using a global fit. From the approaches suggested in the literature, I understand least-s...
I’d like to solve the below equation for the unknown $T$: $$\int_0^\infty \frac{x^2}{\exp\left(\frac{x}{T}\right)-1}\kappa_x \mathrm{d}x = C,$$ where $C$ is a known constant and $\kappa_x$ is some function of $x$, although the actual function is unknown – all I have as an array of values of $\kappa$ over different valu...
I have a $200 \times 200$ matrix representing the values taken by a function over an equally spaced grid. I would like to perform derivatives on it. I am interested in its gradient (i.e. its derivative in direction $x$ and its derivative in direction $y$) and in its Laplacian. I work on the Matlab platform, where I u...
I have a cost function with 2 parameters. The variables are dependent on each other. So, if I just take a partial derivative with respect to one variable the slope is in terms of the other variable and vice-versa. So, how can I compute the optimal values for these variables that minimize my cost function?
I have a bunch of data points in 3D that lie along a few planes. What would be the best approaches to estimate the normals of these planes? Edit: There are roughly equal number of points lying along each plane. All the planes contain the origin (0,0,0).
Let $A$ be an $3\times N$ matrix (where $N$ is large) with nonnegative real entries. I'd like an algorithm for determining when a vector $v\in\Bbb R^3$ can be written as $Aw$ for some vector $w\in\Bbb R^N$ with each entry of $w$ in the range $[0,1]$. In other words I'd like to find the image of the unit hypercube in $\...
The theta-method is a popular solution for solving time-transient PDEs (or ODEs), which consists of solving the general equation for each time step: $$ \frac{u^{n+1} - u^{n}}{\Delta t} + (\theta f(u^{n+1}, t^{n+1}) + (1-\theta)f(u^{n}, t^{n})) = 0 $$ Some values of $\theta$ are often use and their pros and cons are wel...
Solve the following minimization problem in $\mathbf{X} \in \mathbb{R}^{m \times n}$ $$\begin{array}{ll} \text{minimize} & \frac 12 \| \mathbf{X}\mathbf{X}^T -\mathbf{A} \|^2_\mathcal{F}\\ \text{subject to} & \mathbf{X}^T \mathbf{X} = \mathbf{I}_n\end{array}$$ where $\mathbf{I}_n$ is the $n \times n$ identity matrix, $...
I wrote a Lattice Boltzmann Solver in Rust a little while back using both the BGK approximation and the TRT (two relaxation time) method on the D2Q9 lattice. In both cases I run into major stability problems even in simple examples. Here is a video of the output from the simulation of a left-to-right flow with a cylind...
From the inviscid Burgers' equation: $\frac{\partial u}{\partial t}+u\frac{\partial u}{\partial x} = 0$, I get the discretization $\frac{u_i^{n+1}-u_i^n}{\Delta t}+\frac{(u_i^{n+1})^2-(u_{i-1}^n)^2}{\Delta x}=0$. Having the starting conditions $u_0(x)=sin(\pi x)$, $x\in[0,1]$, I wish to plot $u$ after $n$ timesteps. Ho...
In many CFD text books, usually there is a dedicated chapter for advection term discretization. Why discretization of such term in advection-dominated problems and near the discontinuities is challenging? I need some mathematical reasoning And how this is linked to the problem of boundedness and numerical diffusion? ...
In particular, if Euler's method is implemented on a computer, what's the minimum step size that can be used before rounding errors cause the Euler approximations to become completely unreliable? I presume it's when step size reaches the machine epsilon? E.g. if machine epsilon is e-16, then once step size is roughly e...
I'm running a simulation, and some linear solvers are returning a message of ill-conditioned matrix. Hence, I'm looking for a fast, easy to implement, method to detect if a matrix is ill-conditioned, before using the linear solver. And in case it's ill-conditioned, what's good way to make it well-conditioned?
I would like to make a visualization with ParaView for a paper. In order to have a high quality look, I would like the image to be, say, 300 dpi (or vector graphics). Moreover, since I know the column width of the paper, I'd like to somehow specify that width in ParaView so I can adjust the size of the visualization, c...
Problem I want to convert the general second order linear PDE problem \begin{align} \begin{cases} a(x,y)\frac{\partial^2 u}{\partial x^2}+b(x,y) \frac{\partial^2 u}{\partial y^2} +c(x,y)\frac{\partial^2 u}{\partial x \partial y}\\+d(x,y)\frac{\partial u}{\partial x}+e(x,y)\frac{\partial u}{\partial y}+f(x,y)u=g(x,...
Can you tell me these equations come from where in MATLAB fmincg.m? A = 6*(f2-f3)/z3+3*(d2+d3); % cubic fit B = 3*(f3-f2)-z3*(d3+2*d2); z2 = (sqrt(B*B-A*d2*z3*z3)-B)/A; It is either cubic extrapolation or interpolation. I have looked for these equations in many websites and books of numerical optimization but but I d...
Our data set has $10^4$ data points, but has a long baseline and many gaps. As the histogram shows, the horizontal-axis is time and most of the time, there are no data. The vertical-axis is data counts. The total time is, in fact, short (green lines), but gaps make the time baseline very long. If we bin the data, ther...
In our assignment, we are required to find the energies of the ground state and the first two excited states of the Schrödinger equation in a harmonic potential: $$V = \frac{50 x^2}{(10^{-11})^2}\, .$$ I have the Python code for solving Schrödinger equation using secant Runge Kutta method: import numpy as np m = 9.109...
I have an integer linear programming problem of the form: $$\DeclareMathOperator{\tr}{tr} \min \tr WX$$ subject to: $$\begin{align} \sum_j X_{ij} < c_i && \forall i \\ \sum_i X_{ij} = 1 && \forall j \\ X_{ij} \in \{0,1\} && \forall i,j \end{align}$$ I'm sure this is probably a common problem that's been well studied, b...
I have a $q$-dimensional grid, known at run, not compile-time, that has $50$ points in each direction and hence $50^3$ combinations that I would like to first build and then call a function with each point as its single argument, to store the output in a data structure that has a pointer to the argument. Is there a goo...
I am currently doing a computational physics homework which asked us to use leapfrog to give the relations between timevelocities and time-distance of these two objects. The full question is as follows: Consider two parallel wire with distance d. A negative charged object(m1) is moving along the wire with initial velo...
I'm going to be doing some weak scaling of an $N$-body integrator on AWS. In the past when I've done weak scaling for this integrator I've fixed the number of particles per core ($N/n = {\rm const}$). However, when I do this I get a weak scaling that is proportional to $n^\alpha$ where $n$ is the number of cores, whic...
I am trying to solve numerically (obviously) inviscid Burgers' equation with the finite difference method. The equation is the following: $$ \displaystyle \partial_t u + u \, \partial_x u = 0 $$ which also reads $$ \displaystyle \partial_t u + \frac{1}{2} \partial_x u^2 = 0$$ And since the discrete solution is positiv...
My task is to solve $$\eta_k\frac{d^2C_k}{dz}(z)=-e_k, k = 1,2,3$$ $$C_k\ge0$$ $$C_1(0)=0, C_2(0)=A, C_3(0)=0$$ $$C_1(L)=B, \frac{dC_2}{dz}(L)=0, \frac{dC_3}{dz}(L)=0$$ with $$e_1 = -\beta_1-\beta_3$$ $$e_2=-\beta_1-\beta_2$$ $$e_3=\beta_2-\beta_3$$ satisfying the constraints $$-e_k\le \frac{\eta_kC_k}{K_k+C_k}$$ where...
I'm trying to re-solve the governing equations in hydraulic fracturing modeling as instructed step by step in a paper. After (A-9), the author stated that by substituting A-6, A-8 and A-9 into equation A-4 we obtain a linear tridiagonal system which is easily solved for $∆W_i^m$ at m =1, 2,… Could anyone please help me...
I have a diffusion problem with an internal circular dirichlet constraint and a side condition which shall enforce a certain global volume integral. $\nabla(D \nabla u(x)) = 0$ outer boundary constraint: $u(x) = 0 ~~\forall~x~\in \partial\Omega$ inner boundary constraint: $u(x) = 1 ~~\forall~x~\in \Omega_{int}$ $\int_{...
I am looking for the most efficient way to plot a mesh using Matplotlib given the following information, coordinates of each node, what nodes belong to each element, and the value each node has. Below I have some example data and image showing what the mesh looks like nodeinfo=[[0.000,0.000],[1.000,0.000],[2.000,0.50...
I have to solve a set of nonlinear optimization problems in the subspace defined as the orthogonal space to a given vector. More precisely, $$ \arg\min f(\vec x) \qquad \text{with} \qquad \vec x \cdot \vec n =0 $$ I am thinking of applying the nonlinear conjugate gradient method projecting the direction of descent ...
I'm currently trying to solve a problem using numerical methods. The set-up is rather long, so I apologize in advance... TL;DR: My solutions change depending on how big my steps are and I don't know why. Set-up The first part of this problem can be described by a Lagrangian $L(s,\theta)$, which is given by $$L = \fra...
Given a singular matrix $A$, what is the fastest method to find a single non-zero solution to $Ax=0$? Note that we are not looking for the whole kernel, we just want any non-zero vector in it. I know we can use SVD to find eigenvectors, but that seems much too complicated.
Consider the continuity equation $$ \partial_t \rho(x,t) + \operatorname{div} (b(x,t) \rho(x,t)) = 0, \qquad t \in [0,T], \quad x \in \mathbb R^N, $$ with $b \in L^1((0,T), W^{1,p}(\mathbb R^N))$. Have any numerical methods been used to approximate the (unique renormalized) distributional solution of this problem? C...
Consider the explicit midpoint method, i.e $$y_{n+1}-y_{n-1} = 2hf(y_n).$$ I'm asked to apply this method to the linear test equation, $f(y_n) = \lambda y_n,$ in order to find the method's stability region. So I have $$y_{n+1}-y_{n-1} = 2h\lambda y_n.$$ In the problems I've done before I wouldn't have the $y_{n-1}$ t...
I try to solve numerically the following PDE for $E(r, z)$ with a cylindrical symmetrie (i. e. $E(r, z) = E(-r, z)$). $\frac{\partial E}{\partial z} = \frac{i}{2k} \Delta E + \mathcal{N}(E)$ Where $\Delta$ is the Laplace operator in transversal direction and $k$ a real number. I want to use the Crank-Nicolson scheme t...
I have coordinates of a set of points that form a closed loop that lies in a 3D surface. I know the equation of the surface and I can calculate it's surface normal at any point. I found that for a unit speed curve $\alpha(t)$ I can calculate the geodesic curvature as $$ \kappa_g(t) = \alpha''(t)\cdot (n(t)\times\alpha'...
I'm currently analysing some spatial point patterns that come from some fluid dynamics simulations and I'm having some difficulty computing the structure factor, $S(\pmb{k})$, from both the positions of the points and the radial distribution function, $g(\pmb{r})$. I have been following the structure factor Wikipedia p...
This is a follow up to my previous question posted here. I am solving an optimization problem using fmincon in MATLAB. There are no equality constraints in my model. I want to pass ODEs as constraint to fmincon using, non-linear constraint, nlcon argument. The function model contains odes function dz = model(t, z, c...
I am trying to solve the Poisson problem with Dirichlet boundary condition in 1D: \begin{equation} \begin{array}{rcl} - \mu \Delta u & = & f~in~[0,1], \\ u(0) & = & 0, \\ u(1) & = & 0, \end{array} \end{equation} using the FFT method. However, I get strange results for the rate of convergence of the method, compared to ...
I was testing the .fft package of numpy 1.16.1 in Python 3.7.2. In particular I was trying to verify that the transform resembles the analytical one for: $$f(x) = \mathrm{exp}\left[-\left(\frac{x-5}{2}\right)^{2}\right]$$ I get from Wolfram Alpha that $\hat{f} = \mathcal{F}[f]$ looks like this: Then I tried to replica...
The eigenvalue problem $$\frac{d^2u}{dx^2}+2i k\frac{du}{dx}-[k^2-6\sin(x)^2]u(x)=-\mu u(x)$$ gives the first five eigenvalues with $k=0$ or $k=1$ which are $2.06$, $2.26$, $5.16$, $6.81$, and $7.74$. And those eigenvalues I have calculated, but the corresponding eigenvector that I got did not agree with Fig.2 in th...
If each edge of a graph $G$ is unweighted or has equal weights, then the shortest path between two nodes in that graph is the path that contains the fewest number of edges. Such a path can be obtained by BFS. Here, i consider that each weight of the edge is the minimum of the end vertices and the weight of the path is ...
Trying to implement an adaptive step size Runge-Kutta Cash-Karp but failing with this error: home/anaconda/lib/python3.6/site-packages/ipykernel_launcher.py:15: RuntimeWarning: divide by zero encountered in double_scalars from ipykernel import kernelapp as app The ODE i am trying to solve (and using in the example be...
I am working with the following differential equation: The equation is $$x=\beta +\sqrt{2D} \xi(t)$$ where $\xi(t)$ is a white noise term, with a reflecting wall boundary conditions. After solving the equation numerically with Euler-Maruyama method, I used the Wiener-Khinchin theorem (Using FFT) to find a numerical ...
I am working on conductive polymer modeling and supposed to do one-dimensional diffusion model in the thickness of the polymer, however, due to the small value of thickness in micro, when I use the forward approach it leads to instability, no matter how I decrease the number of nodes. I have to use Backward Euler to co...
I am currently trying to segment cells from digital pathology images. The method I use is an algorithm based on color distance. This works for most of the cases, however, when dealing with the images which cells are overstaining, then the segmentation results is pretty bad. Is there any golden-standard method in treati...
Let us assume that we have a function, $f(A)=\text{vec}(A^{-1})^\intercal B$, dependent on $A^{-1}$. However, due to some machine-precision limitations, the programming language I'm using cannot invert $A$ even if it has $Det(A)>0$. So, I'm thinking of using a pseudo-inverse, instead. However, I don't know if there's ...
This is probably a long shot with such a short time, but I've been trying to get theoretical data for a project I'm working on. The project involves using a very simplified version of magnetic particle imaging to analyze fluids. So I've written some code with some help, and I'm pretty sure all the physics is correct bu...
Is there either a closed-form expression or fast/elegant algorithm for computing the positive root of the polynomial $$f(x)=x^q + \beta x - \beta,$$ where $\beta>0$ and $q\geq2$? How about the $q\in\mathbb R$ case with $q\geq1$? Note there is exactly one positive root of the function $f(x)$, since $f(0)=-\beta<0$, $\...
I have a function which requires the return type to be a container. The problem is that I need to integrate the contents of the container as efficiently as possible and was hoping to use adaptive Gauss-Kronrod integration or something equally efficient (or better). I was hoping to use the GNU Scientific Library quadrat...
I want to use the Crank-Nicolson scheme to solve the equation $$u_t = iu_{xx}+2iu$$ Here's the analysis: Suppose we make a grid, with $k = dt$ and $h = dx$, the usual notation, and also $u_j^n = u(x_j,t_n)$ . The round-off error equation for the crank-nicolson scheme for this equation is: $$\displaystyle\frac{\epsilon...
I have a set of data obtained for the I-V characteristics of an LED. 0.005 -0.004 0.053 -0.003 0.101 -0.003 0.153 -0.002 0.201 -0.002 0.252 -0.002 0.303 -0.004 0.354 -0.004 0.403 -0.004 0.454 -0.003 0.503 -0.003 0.554 -0.003 0.603 -0.003 0.654 -0.003 0.702 -0.003 0.753 -0.002 0.802 -0.002 0.853 -0.00...
I have a set of data data.txt which can be fit to a Gaussian function, f(x). I want to determine the coordinates of the point of maxima (peak) from both the data given and also from the fit function f(x). How can I achieve this in gnuplot?
I am solving the task that is as follows: Input: a polygon. Can be any kind of polygon without self intersections. Can be a non-convex and with holes inside. Goal: to cover it with 2 (at least) or more parallelograms that together are equal to or contain the whole polygon. The following criteria should be met: There i...
In Matlab, an ILU with threshold and pivoting (ILUTP) can be passed by default as: setup.type = 'ilutp'; [L, U] = ilu(A, setup); Looking for an equivalent in scipy, ex: sparse.linalg.spilu(A, options = ??) Tried to look up how matlab does the pivot and threshold but didn't seem to find much information.
My question is: how come that certain formulations of the wave equation can be time integrated more efficiently then others? Le me expand a bit on that. Consider the wave equation: $$ \frac{d^2 p(t,x)}{dt^2} -c^2 \frac{d p(t,x)}{dx^2} = 0 $$ with boundary conditions $ p(t,0) = \sin(\omega t) $ and initial conditions $ ...
I wanted to multiply two simple (big and sparse) matrix with numpy. And I saw that the calculation fails when matrices are too big. If i take $X$ a random vector (size $n$). With pandas, I transformed this vector with get_dummies and I obtain a matrix $M$. One can verify that $M^\top \cdot M$ is a diagonal matrix and ...
I am trying to implement Poisson image blending as in the paper Poisson Image Editing. This is the task of filling in a masked region of an image by minimizing $$\min_f\int_\Omega \left | \nabla f - \mathbf v\right |^2$$ with $$f|_{\partial\Omega} = f^*_{\partial\Omega}$$ which is equivalent to the Poisson problem $$\D...
I have started investigating in mostly Runge Kutta and Runge Kutta Nyström methods and there one of the only differences between the methods of the same type is their Butcher tableu. For the most common ones (RK4, RKF45, DOPRI54) they can be found on Wikipedia but otherwise I find it hard to find them. I could always g...
I find myself in the position of having to solve $-\Delta u = f$ on a subset of Cartesian grid points that don't necessarily form a cuboid domain subject to a homogenious Dirichlet boundary condition ($u = 0$). The Laplacian filter I require is the standard 7-point stencil for 3D. Now, for a cuboid domain, I know this ...
Is it necessary to reorder nodes (using Reverse Cuthill-Mckee algorithm, for example) if I am already using a CSR or CSC storing technique? Because since CSR/CSC stores only non-zero elements I guess reorder wouldn't be much advantageous.
For a given integer $n\in\mathbb{N}^*$, I want to find a pair $(x,y)\in{\mathbb{N}^*}^2$ such that $x*y=n$ and $|y-x|$ is as small as possible. A naive algorithm I found is : for k = floor(sqrt(n)) to 1 step -1 if n/k is integer then return (k, n/k) end if end for Although I am almost certain there is a mo...
I am supposed to do black-box modeling, I need the input and output data for training, however, the authors didn't agree to share the raw data with me, I can only use their publication where these attached images are given below. Of course, I do understand the curve, however, I don't know how to create raw data from fi...
I have a set of $n$-dimensional vectors, and would like to choose $m$ of them to become the columns of an $n\times m$ matrix. I would like to choose the subset that maximizes $|A^T A|$, where $A^T$ is the transpose of $A$ and $||$ is notation for the determinant. Can this be done faster than trying out each of $n \choo...
This is part of the code in matlab for a random-walk simulation. To test the code, I'm using steps=[30]; there will be more values, but I want to run it for 1 trial to decrease code processing. log_steps = log(1:steps); <--- corresponds to the log (steps vector) for the x axis of the plot log_AVG = log(d_AVG); <----...
I'd like to use the syms package to do some algebra for me, but the baseline assumption seems to be that variables are scalars. I would like to denote some variables as matrices. This will change the symbolic output/calculations. For example: inverse is not division, operations are not all commutative, and things can b...
Why not just Lagrange polynomials basis functions
https://en.wikipedia.org/wiki/Dormand–Prince_method I want to implement the Dormand-Prince 4(5) version to solve Initial Value problems. Using regular notation I have $A$ matrix and the $c,b,\hat{b}$ vectors. I also have the error tolerence of $ETOL$ absolute error tolerence $ATOL$ and relative error tolerance $RTOL$ A...
I have a object which is static, the camera is static and light source is moving. How can the depth mask be calculated ? Concept is to use - calculate height from shadow length Lets imagine a have more images likes this. And light source is moving, which is sun, and from time it's position, distance, orientation can b...
We have $X=[\mathbf{x}_1,\mathbf{x}_2...,\mathbf{x}_n]\in\mathbb{R}^{d\times n}$, $H=[\mathbf{h}_1,\mathbf{h}_2...,\mathbf{h}_n] \in\mathbb{R}^{d\times n}$, and $d<n$. $H$ has rank $r\leq d$ and $X$ has rank $d$. Assume we have $\|H\|_F\leq C$ and $\|\mathbf{x}_i\|_2\leq R$, where $\|\cdot\|_F$ and $\|\cdot\|_2$ are t...
After reading the matrix stability chapter (10) of Hirsch [1], I decided to dive in the reference list of the chapter. One of the papers [2], which is cited as reference shows an very interesting approach to stability analysis. The paper shows an stability evaluation of a real world flow solution of a NACA0012 airfoil ...
I'm trying to solve a Schrodinger equation of the form $i\frac{\partial}{\partial t}\psi=-\frac{\partial^2}{\partial x^2}\psi + (V(x)+\alpha|\psi|^2)\psi$ using the split-step Fourier method implemented via MatLab code. In order to make sure it works, I'm testing my code with $V(x)=x^2,\alpha=0$ and $\psi=Ce^{-x^2/2}$ ...
If I have a real positive definite matrix $A\in\mathbb{R}^{n\times n}$, and denote its eigenvalues as $\lambda_1\leq \lambda_2 \leq ... \leq \lambda_n $. Define the function as $f(A)=\sum_{i=1}^{k} \lambda_i$ for a constant $k<n$. What do we know about the convexity of $f(A)$? Is it convex or concave?
I have a function $F(\vec x)$ of many variables (let's say in the order of hundreds of thousands). I need to compute the determinant of the Hessian matrix at the point $x_0$. Is there a way to compute some approximation of it without explicitly computing the determinant? I want to compute this value because it appears ...
I need you to help me understand the Singular Spectrum Analysis algorithm. I already read a lot of articles about the subject but they never answered my questions like what is the mathematical reason for embedding the time series into a trajectory matrix and why applying the SVD gives us access to such trend and period...
I am running into a strange problem when solving the 2D compressible Euler equations on a inclined wedge. To elaborate, my top boundary condition seems to emitting some type of instability. I have tried using Neumann BCs for the u,v velocities, but the issue still persists. I am using a 2nd-order finite volume method ...
I have this non-linear partial differential equation. $$ \frac{\partial C}{\partial t}=\left(\frac{\partial C}{\partial x}\right)^2+C\frac{\partial^2 C}{\partial x^2} $$ I want to use the finite difference method to solve it either with the implicit method or the Crank-Nicolson method, witch I have done with linear PDE...