instruction
stringlengths
43
28.1k
I have tried to set up a model for the diffusion of a gas into a liquid. The two media are next to each other and the geometry is spherical because the system should simulate the diffusion out of a gas bubble. I have made a diffusion model for the gas phase (the left compartment) and a corresponding diffusion model fo...
This is a follow-up of my previous scicomp question (https://scicomp.stackexchange.com/posts/28863/edit). I figured I'd start a new thread on this as the question is a bit different from my previous question. I am solving the linear elasticity equations, using Hooke's Law and the strain-displacement relationship. My ...
I have some questions about the implementation of non-reflecting OUTFLOW boundary condition for Navier Stokes equations. Following Poinsot, Lele "Boundary Conditions for Direct Simulations of Compressible Viscous Flows" Pirozzoli, Colonius "Generalized characteristic relaxation boundary conditions for unsteady compr...
Projection of a vector $v$ onto the column space of a matrix $A$ is given by $AA^\dagger v$. From the definition of Moore-Penrose Inverse we know that $AA^\dagger v = (A^T)^\dagger A^T v $. Below is the code for implementing the projection of a random vector onto the space of a random matrix. This is related to my othe...
I would like to obtain a feasible solution for an under-determined system of linear equations, $$Ax=b$$ where, $A \in \mathbb{R}^{7\times9}, \, x \in \mathbb{R}^{9\times1}\text{and } b\in\mathbb{R}^{7\times1}$. Clearly, there is no unique solution, but I would like to obtain a solution that satisfies some non-linear i...
I have written some multithreaded code using PyOpenCL, which works fine under the following conditions: GPU 32-bit floating point values (Intel Iris GPU can only handle single precision values) CPU 32-bit floating point values. All data buffers are defined, and the program executed and output data enqueued, all insid...
I'm using LAPACK's zggev_ routine to solve some generalized eigenvalue problem. While it produces the correct results, I want the eigenvalues and according eigenvectors sorted by absolute value. For this I implemented a naive sorting algorithm which provides me with the permutation vector needed by the LAPACK routine z...
I am looking for assistance with calculating the fabry-perot standing modes in a resonator which has a non-static refractive index. For a resonator with perfectly reflective mirrors only the standing modes experience sustained population. For a resonator with no internal medium the wavelengths at which a standing mode ...
I am solving 1D laplace problem discretized with finite differences (3-point stencil). I would like to use additive Schwarz method in classical form: $U_{k+1}=U_{k}+M^{−1} r_k,$ where $r_k=F−A U_k$ and $ M^{−1} = \sum_{i=1}^N R_i^T(R_i A R_i^T)^{−1} R_i$. Restriction operators $R_i$ are defined as binary matrices, ...
I've may have reached a point in my neural network research that I cannot continue without significant financial investment. I am using neuroevolution to evolve a network on the EMNIST data set. It is embarrassingly parallel (100 individuals * 116,323 records). The program is impossible to accelerate with a GPU. I have...
This question is rather simple but I have some difficulties to find code. Let us suppose that I wrote a routine, in a given language, that computes the evolution of a particle doing Brownian motion in one dimension. Given all the steps, how should I write an algorithm to derive the heat kernel from them? Some good refe...
I have implemented a schur complement domain decomposition method for solving large scale problems in Matlab. It works well but I think there should be some alternative approaches to implement some parts of the algorithm more efficiently to circumvent high memory usage. Specifically, I need to evaluate $M=BQ^{-1}B^T$ w...
I have to use Kronecker product of a matrix with a unit matrix is there any routine in ScaLapack or Lapack which can do so efficiently.
I'm trying to solve an equation whose solutions I know are plane waves but there are a few nuances. First, the equation is of the form $$ \partial^2_t \psi + A(r)\partial^2_r \psi +B(r) \partial_r \psi + C(r)\psi =0 $$ Second, my boundary conditions are $ \psi(a)=\psi(b)=0 $ Third, my "initial" conditions are: $$ \ps...
I am solving an equation of the form $(*)$ $0 = a(f) (\partial_rf)^2 + b(f) (\partial_rf) + c(f),$ where $f$ is a real function of $r\in \mathbb{R}$, and $a,b,c$ are real functions of $f$. The boundary condition $f=f_0$ at $r=0$. Right now, I am solving $(*)$ by finite differencing $(*)$ and then applying a relaxation ...
I want to implement an algorithm to solve a heat equation, i.e. \begin{align*} \partial_t u - \Delta u = f \text{ in } \Omega\times(0,T)\\ \partial_nu = 0 \text{ in } \partial\Omega \times (0,T)\\ u(0) = u_0 \end{align*} I'm looking for some reasonable functions $f$ and $u_0$ to model a very hot area (e.g. a box in the...
I have a table of the orbital coordinates and velocities of an object with time steps of 1 minute. Now I would like to interpolate this to a finer time increments with time steps of the order of 1 second. How to make use of the velocities in coordinate interpolation and what might be the most accurate way to do this?
I am reading Chapter 5 of Saad's iterative methods book, and I don't understand section 5.2.1 about the two propositions of optimality results. In the statements of the propositions, what does it mean that: $\tilde{x}$ is the result of a projection method onto $\mathcal K$ with the starting vector $x_0$? Because $\tild...
Is measuring mean-squared-displacement in Monte Carlo simulations uncommon? I'm very interested to find out if this has actually ever been tried. For instance, in the context of spheres, or cylindrical particles in a periodic simulation box, where we have our usual Monte Carlo moves of translation and rotation. So a pa...
Given a flow inside a square duct with constant temperature at the walls $(T_{w1} = T_{w2} = T_w)$ the physical property in terms of temperature that repeats itself in a periodic fashion is the $\textbf{Dimensionless Temperature} ~ \mathbf{\theta}$ defined as shown in the picture below :- I am interested in defining $...
A non-linear molecule has $3N-6$ degrees of freedom ($N$ is the number of atoms; ignoring translation and rotation). Therefore, a set of $3N-6$ distances and/or angles is enough, to describe the whole system. I am searching for an algorithm, which takes $3N-6$ ($N$ is the number of points) distances as an input and cal...
I am currently trying to parallelize the incompressible flow solver code. However, when I run the code I realise that the parallel code takes much longer time than sequential code to finish one iteration. The mesh is partitioned by ParMetis so the work load is balanced. I also timed my code, the main time-consuming p...
I have a fluid dynamic solver written in python which I want to accelerate by moving the most expensive computations to the GPU. Ideally all arrays and sparse matrices used in my code should remain on the gpu, and matrices in COO format should be built directly from arrays on the gpu. From my search it seems that there...
Suppose I have $n$ generally nonlinear equations for $n$ variables, like e.g. for $n=2$ the system $F(x,y)=0$ $$ \begin{aligned} x^2+2y-4&=0\\ \sqrt{8}x+y^2-5&=0 \end{aligned} $$ By introducing variables for intermediate results, I can transform this into an (almost, at least, up to some additional singularities, which...
I am trying to solve the LWH traffic flow equation, which is a nonlinear hyperbolic equation $$\frac{\partial \rho}{\partial t}+\frac{\partial (v\rho)}{\partial x}=0,$$ where $$v=v_0(1-\frac{\rho}{c}).$$ $v_0$ is a given constant that may or may not vary with position, which represents the optimal velocity for the v...
I am quite new in snappyhexmesh and OpenFoam world and I am trying to mesh a multi stl geometry. My geometry is a geometry which is split in 3 different stl files. Globally it is closed, but each single part is not closed. As far as each stl is not closed the feature extract step crashes. How can I solve this problem? ...
Suppose I have a symmetric matrix $K$. Subdivide $K$ into pieces as $$K=\begin{pmatrix} K_{11} & K_{12} \\ K_{21} & K_{22}\end{pmatrix},$$ where $K_{21}=K_{12}^\top$. Then, the Nystrom approximation of $K$ replaces $K_{22}$ with the approximation $$K_{22}\approx K_{12}^\top K_{11}^{-1}K_{12}.$$ See e.g. this paper f...
I am currently working on a scheme that uses finite differences WENO5-Z with 3rd Order Runge-Kutta time integration for solving the Euler equations. The code projects the conserved variables and fluxes onto the eigenspace using Roe-averages at i+1/2 and uses a local Lax-Friedrichs flux splitting before applying the WEN...
Let's say I have an algorithm that can be tuned by a parameter $h>0$ and is expected to converge as $h\to 0$. I want to study the computational complexity of this algorithm, i.e., how the required runtime increases with increasing accuracy. For this purpose, I run the algorithm for different values of $h$ (say, $h_1>h...
I am trying to solve the radially symmetric polar form of the PDE with homogeneous Neumann BC in deal.II on a unit circle: $$ u_t = \Delta u - \nabla \cdot (u \nabla h) $$ $$ h_t = \Delta h $$ I am not sure how to handle the origin & how the bilinear form change in this case. Also, how to use the grid and triangulatio...
A jump-diffusion process is a stochastic process where both continuous noise (in my case complex Wiener noise $dZ,dZ^*$ such that $dZ^2=dZ^{*2}=0,|dZ|^2=dt$) and discrete Jumps (in my case Poissonian $dN,dM$ such that $dN^2=dN$, $dM^2=dM$, $\langle dN\rangle=A dt$, $\langle dM \rangle=B dt$ ). My equations are in the I...
Based on your empirical knowledge. This paper suggests a nonlinearly accelerated Fourier series approach, such as the one proposed here, but I have one constraint: we should be able to express the method as a linear combination of the function $F$ at different frequencies $s$, that is $f(t) \approx \sum\limits_{i=1}^N ...
I have a system of 1st order odes given by $$ \dot{x_1}(t) = \alpha_1 f_1(x_1,t) + \beta_1 u(t) \\ \dot{x_2}(t) = \alpha_2 f_2(x_2,t) + \beta_2 u(t) $$ They are constrained by an algebraic equation $$ x_1(t) + x_2(t) = k $$ where $\left( \alpha_1,\alpha_2, \beta_1,\beta_2 , k \right) \in \mathbb{R}$ are known consta...
I have a triangulated surface that I want to work with. In order to optimize certain quantities related to this surface I want to find all points which are accessible from a given direction. To be more precise, let's denote by $S_h$ the surface and by $B$ the body enclosed by $S_h$. Given a direction $\vec d \in \Bbb{R...
Since the permittivity of any material is usually complex function of temperature, frequency, density, etc. I was wondering if it is possible to use a dynamic permittivity which changes as a function of time using the fdtd method. This would also enable to simulate moving objects. Any hints, keywords, etc.?
In the context of the solution of advection-diffusion equations by finite volume method, many numerical schemes, papers and book chapters are dedicated to address the numerical diffusion and/or numerical dispersion that comes from the discretization of the advection term. If I understand it correctly, the discretizatio...
I would like to solve $$\alpha u_{tt} = -\nabla^2u$$ with $\frac{\partial u}{\partial n} = 1$. On using a Galerkin approximation I obtain $$M\ddot{c}=\frac{1}{\alpha}(Dc+b)$$ where $M$ is the mass matrix and and $D$ is the stiffness matrix. I note that I can write this in the form $$\dot{U} = ZU+B$$ where $U = [c, \dot...
When solving a reduced KKT system of a nonlinear (and nonconvex) constrained program after eliminating slack and dual variables, how do we actually take the next step in a primal-dual method? For example, following notation from NW, if the original nonlinear system is like (19.12) \begin{align} \begin{bmatrix} \nabla_{...
Consider a linear system, $Ax=b$ where $A$ is the coefficient matrix, $x$ is the unknown vector of variables, and $b$ is a vector of constants in which all entries are same. Is there a way to find out relative values of $x$ without actually solving the system of equations? In other words, can we say by just looking at...
This question might be so obvious and trivial that I'm having a hard time googling it. I have a multivariate root finding problem that I'm trying to solve in C# and the library that I'm trying to use is alglib. That package doesn't have any dedicated root solvers in it, but has Levenberg-Marquardt. To do root finding...
As far as I have seen, solving problems of nonlinear elasticity using the finite element method proceeds by linearizing, either around the initial configuration (total Lagrangian approach) or around the most recently solved configuration (updated Lagrangian approach). This produces a system of linear equations, and re...
Suppose that we have a linear system of equations $$Ax=b$$ where $A$ is a $3 \times 3$ matrix and $x$ and $b$ are $3$-vectors. Let $y$ denote the solution of this system of equations. I want to change matrix $A$ such that the new solution is vector $z$ in which $$z_1 > y_1, \qquad z_2 = y_2, \qquad z_3 < y_3$$ Is the...
Imagine I want to compute the eigenvalues of an operator $\hat O$ defined on $ L^2(\mathbb{R})$, however using a properly scaled N-dimensional polynomial basis of $ L^2([-a,a]) $ which fulfills Dirichlet boundary conditions: $P_n(\pm a)=0$ (e.g. scaled Legendre polynomials), i.e. $ O_{i,j}=\langle P_i|\hat O|P_j\rangle...
Typical finite volume methods are conservative, because fluxes (of e.g., mass or energy) are always between neighboring cells. Is the same generally true for finite element codes? Do I correctly assume that implicit time stepping would then be 'globally' conservative, except for flows through the domain boundaries? Bac...
Is there a direct way to use SLEPc from Matlab? I remember that in some old manuals there was some Matlab interface. However, in the last one, I cannot find any reference to this. For me, it would be really useful in the computation of eigenvalues for some large, sparse matrices. (Matlab's eigs does a pretty good job ...
When it comes to discretization schemes for finite volume method, the following terms can be found in literature: monotone schemes monotonicity preserving schemes local extremum diminishing schemes TVD schemes NVD schemes bounded schemes stable schemes stability preserving schemes A single work doesn't use all of the...
This question is a continuation of Fourth order IMEX Runge-Kutta method and Implementation details for high order IMEX methods by Kennedy and Carpenter. I need confirmation that ARK3(2)4L[2]SA by Kennedy and Carpenter has the "First Same As Last"-property. I have verified it numerically for ARK4(3)6L[2]SA and ARK5(4)8...
My project involves large simulation and estimation. For each simulation I need to solve 600,000 systems of nonlinear equations. Currently I am using Newton's method to find the solutions. That involves inverting 600,000 million Jacobian matrices at each iteration. Currently I iterate 100 times for convergence in MATLA...
I have the following situation: I have a sequence of vectors $x_1, x_2,.. $ and for each I want to compute the product $Ax_i$ where $A$ is fixed at the outset. Although there is no information about the structure of $x_i$, $A$ typically has a particular pattern where many values are repeated and I would like to compute...
Let $$f(x,y) = \exp \left(- \frac{1}{2}a x^2 - \frac{1}{2}c y^2 + bxy \right)$$ where $a,b,c\ge 0$. I want to integrate numerically: $$\int_{x_0}^{x_1}\mathrm{d}x \int_{y_0}^{y_1}\mathrm{d}y \, f(x,y) x^ny^m$$ where $-\infty < x_0 < x_1 < \infty$, $-\infty < y_0 < y_1 < \infty$, and $n,m\in\{0,1,2\}$. A naive method h...
The 2014 paper "Iteration-Free Computation of Gauss--Legendre Quadrature Nodes and Weights" by I. Bogaert (https://doi.org/10.1137/140954969) contains the following expression in Appendix A: What is the meaning of the "LL" here? It is not defined in the body of the paper and it's such a commonly occurring character se...
I'm reading this paper and trying to follow everything that the author has done. A Comparative Study of Finite Volume Method and Finite Difference Method for Convection-Diffusion Problem But there is a problem. I cannot derive the following equation (third line in equation (6) of [1]) for two reasons: I cannot match ...
I'm writing a genetic algorithm to minimize a function. I have two questions, one in regards to selection and the other with regards to crossover and what to do when it doesn't happen. Here's an outline of what I'm doing: while (number of new population < current population) # Evaluate all fitnesses and give them a...
I'm trying to model a projectile motion, considering every detail such as projectile aerodynamics, effects of wind, air temperature etc. What is a good software to model it in with good graphics? I like how COMSOL multiphysics works and it's parameter sweep. It could be used to find the optimum angle for longest range ...
This question is mainly about hardware, but also about software. In my current work I have approximately 68 millions of combinations that I am iterating through, in parallel. For each of those combinations - there is processing involved on the same data set. The idea is very similar to how neural networks train, I gue...
I am trying to use scipy.optimize.minimize to minimise a quadratic objective function: $f(x) =x^\top Q x$. As a start, I have successfully implemented this using the built-in Nelder-Mead Simplex algorithm, by defining a function: def objective(x): Q = np.asmatrix(DF.cov()) # Covariance matrix x = np.asma...
I'm trying to find both the dominant $k$ left and right eigenvectors, that is, $$V_L\mathcal{A} = \Lambda V_L\\ \mathcal{A}V_R = V_R\Lambda\\ V_LV_R = I_{k\times k}$$ $V_L$ being the $k\times N$ matrix of left eigenvectors, $V_R$ being the $N\times k$ matrix of right eigenvectors, and $\Lambda$ being the diagon...
I usually work with Python, but my basic knowledge of c++ allows me to switch when I need to increase the speed of my code. Currently, I have a python script that (among other things) computes the mean and standard deviation of all principal minors (of a specified order) of a square matrix. Minors are determinants of ...
I was suggested to move that question here. The question to be as follows. Statement of the problem Is it possible to achieve the second order of convergence (OOC) of Lax-Wendroff (LxW) scheme applied to solve inviscid Burgers equations with discontinuous initial data? If no, then how to achieve (and prove numericall...
I have two sets of magnets. One set consists of two electromagnets (Shown below: Blue) and the other set consists of two NdFeB N40 permanent magnets. Both sets of magnets lie on the same plane. I want to plot the force of attraction/ repulsion between the two sets of magnets as the distance between them varies from 10c...
I know L-BFGS-B only supports simple box constrains of the form: $l_i \leq x_i \leq u_i$, where $l_i$ and $u_i$ are constants. For my specific optimization problem, I need to specify some simple linear constraints of the form: $x_{i-1} + k \leq x_i \leq x_{i+1}-k $ where $k>0$ is a fixed constant. Essentially, I need e...
We can use random optimization/ derivative free/ direct search to find the minimum of some black box function $f$. If I have some 2D black box function, $f(x,y)$ - which I know to be convex - what is the best derivative-free method to use? i.e. from a speed perspective is it best to use e.g. Nelder-Mead, Compass/Patte...
I have two models which I would like to investigate for my data. One form is: \begin{equation} \label{one} f(r) = A e^{-B r} \end{equation} and the second is: \begin{equation} \label{two} g(r) = \frac{A}{r^{C}} e^{-B r} \end{equation} Does anyone have any advice on how to tell the difference between these two?...
I have the discrete likelihood estimation problem $\max \sum m_i\log p_i $ where $m$ is a given vector of length $n$. The constraints are $0 \preceq p \preceq 1$, $\sum_{i=1}^n p_i = 1, $ and one final constraint which is not convex: $$ \log p_i \geq \frac{1}{2}(\log p_{i-1} + \log p_{i+1}); \quad i = 2, \dots, n-1. $$...
I know that it is generally a bad idea to compute the inverse matrix directly. However, if it is necessary to compute the inverse of an ill-conditioned invertible dense matrix, then what can I try? For example, I know that scaling a matrix may decrease the condition number of it. This may be an example of preconditiong...
I was wondering if we could model rigid body motion of bodies using finite element models. Particularly I'm interested to know if we can model motion of objects with no constraints or with some degrees of freedom (such as only rotation). Though I've used word 'rigid body' to convey the situations closest to what I'm co...
Mesh Adaptive Direct Search (MASH) is an algorithm for black box optimization I want to understand an implement this method to solve some 2D multivariate blackbox function $f(x,y)$, but am having trouble understanding the algorithm. What I understand so far: Start with some initial trial value $x_0, y_0$ Create the 'M...
I used pretty much all my expertise with finite differences to solve an advection-diffusion equation with space-dependent coefficient with a grid in the $x$,$z$ domain with regular spacings. Something like this: This is nice because it is easy to initialize with some experimental measurements that I have. However, nea...
OK, I know a bit of C++ (very basic syntax), and I want to do physics simulation in C++, like stuff like (also the things mentioned here): Ripples and waves over a 2-d surface Vibrating string/membrane Various electric/magnetic fields (as per my wish) in 2d/3d Gas molecules simulation Newtonian mechanics stuff (rotati...
I need help computing the following integral: $$ \int_{}\frac{(1+jk|\vec{r}-\vec{r}^\prime|)e^{-jk|\vec{r}-\vec{r}^\prime|}}{|\vec{r}-\vec{r}^\prime|}d\vec{r}^\prime $$ in this integral $\vec{r}$ and $\vec{r}^\prime$ are the position vectors that correspond to the observation point and source point, respectively. This...
I have n spots with 2 possible positions each. I would like to explore all of this possibilities in C++ using loops (or something else if there is a better option). I was thinking of looping from 0 to power(2,n) and convert it to a binary number, for position j, take j-th digit of the binary number use 0 for first pos...
Let assume that one would like to translate an input-output model, into a state-space one. It is well-known that the process of realization addresses this aspect. Let assume to have the following input-output ARX model $$ y(k) = \sum_{i=1}^{N_a}a_iy(k-i) + \sum_{i=1}^{N_b}b_iu(k-i) $$ in which, at the discrete time ste...
I would like to use Multiscale Combinatorial Grouping for my PhD research. However, I am restricted to use open-source implementations and this one runs on Matlab. Does anyone know of an equivalent contour detection method that works on large images that is implemented open-source, preferably in Python? Here some more...
I'm trying to simulate Stokes flow in 2D around an arbitrary polygon (representing a rigid body). I'd like to get both the effect of the body on the flow velocity and the forces on the body by the fluid. Basically, like how panel methods are used to examine inviscid flow around airfoils, I'm trying to examine "airfoi...
Consider the heat equation $$u_t = \kappa u_{xx}$$ with boundary conditions of $$u(x,0)=0\\ u(0,t)=100\\ u(l,t)=0$$ Numerical analysis by pyton can be done with import numpy as np import matplotlib.pyplot as plt from scipy.sparse import diags def Crank_Nicolson(dy,ny,dt,nt,k,T,ntout): Tout = [] T0 = T[0] T...
I am using Python, and I have a Pandas dataframe with hundreds of thousands, if not millions, of $(x,y,z)$ coordinates. I am looking to find an efficient method to index the original dataframe so that I'm only left with entries that are within some distance of a given point $P$ that's not necessarily in the set of coor...
I am developing a code where I am using the least squares method to compute gradients. Generally, we use least squares to obtain some model based on a set of data (${q_1 \cdots q_N}$) at locations (${x_1 \cdots x_N}$), and use this model to predict $q_c$ at $x_c$. In my case, I am looking for $\nabla{q}$ at $x_c$ usin...
Given a triangulated surface in $\Bbb{R}^3$ we can simply project it on a plane. This will result in a family of triangles which do not form a mesh of the projection for the following reasons: each point of the projection is covered by at least two triangles (see the picture). the orientation of the triangles is not r...
I've been trying to implement the CPU GS-PCA algorithm in this paper . The code starts on page 28 I have a program written a script in python which gives the same output as the C++ program in the paper. My function looks like this [T, P, R, L, U] = IterativePCA(theData, numDimensions, 10000, 1.0e-7) Where theData ...
In this comment I wrote: ...default SciPy integrator, which I'm assuming only uses symplectic methods. in which I am refering to SciPy's odeint, which uses either a "non-stiff (Adams) method" or a "stiff (BDF) method". According to the source: def odeint(func, y0, t, args=(), Dfun=None, col_deriv=0, full_output=0, ...
In the context of a scientific computing application, using data coming from (powerful) embedded systems, acquiring raw data (but from calibrated acquisition electronics), I have been asked to integrate these data (in RT), with an empirical sum, instead of making use of usual numerical methods. (Important note : even i...
Background A neutral delay differential equation is one where the derivative does not only depend on its past state, but also the derivative at a past point: $$ \dot{y}(t) = f\big(t, y(t), y(t-τ_1), y(t-τ_2), …, \dot{y}(t-τ_1), \dot{y}(t-τ_2), …\big).$$ A clear problem when numerically integrating such DDEs is the init...
I am trying to solve/optimize $Ax=b$ in the least squares sense subject to box constraints; a few (less than 5) equality/inequality constraints; and an absolute function penalty (or some other piecewise linear convex function). That is, min $f(\mathbf{x})=|A\mathbf{x}-b|^2+\mathbf{c}\cdot|\mathbf{x}|$ where $\mathbf{...
I am basically asking about eigenvalue problems of differential equations using some finite difference method (FDM). Usually the system is subject to some boundary conditions (BC), e.g., Dirichlet or Neumann. Often it is homogeneous BC like $u(0)=0,u'(R)=0$, which seems to be fine to deal with. One way is to introduce ...
Let $M$ be a manifold and $UT(M)$ its unit tangent bundle. I have a PDE which looks something like $$ \frac{\partial f}{\partial t}(x,v) = (v\cdot \nabla_x) f(x,v) + \Delta f(x,v) $$ where $x\in M$, $v \in T_xM$, i.e. $x$ is a point on the surface and $v$ is an unit vector at that point, $\nabla_x$ is gradient on the s...
I am trying to solve this problem where we have a 1D-lattice of size 100 and the particle can start from any position in the lattice and moves randomly on it(with equal probability of moving to either direction). When the particle reaches either of the ends of the lattice it stops. The problem is to plot the time avera...
The Padua points $\mathrm{Pad}_{n} \subset [-1,1]^{2}$ are a unisolvent pointset with optimal growth of Lebesgue constant, described in detail here. With some work they can be used to generate a multivariate Chebyshev series representation of the function they attempt to interpolate. I would like to use the Padua point...
I wrote a code on Python 2.7.5 to solve numerically the following differential equation. $\frac{\partial^2f}{\partial x^2}=-S$ $S=\pi^{2}\sin(\pi x)$ S is chosen that way in order to have $f= \sin(\pi x)$ as the exact solution, that can be compared with the constructed solution. The differential operator is discretiz...
A nonlinear least-squares problem with $F:\mathbb{R}^m\to\mathbb{R}^n$, $$ F(x) \to \min_x \quad (\text{in the least-squares sense}) $$ really means minimizing $$ \frac{1}{2} \|F(x)\|^2 \to \min_x. $$ In principle, one could throw any old minimization method at it and get something. In turn, given any minimization prob...
If $x_k$ are the Chebyshev nodes, that is for $n \in \mathbb{N}^*$, we have $x_k = \cos(\pi \frac{2k + 1}{n})$. Now suppose you have approximated values of $x_k$ and $x_{k'}$ for $k,k' \leq n$. In the worst case, what is the number of significant values we may loose when we calculate $x_{k'} - x_k$? Now, taking into ac...
I am using cvxpy to do a simple portfolio optimization. I implemented the following dummy code from cvxpy import * import numpy as np np.random.seed(1) n = 10 Sigma = np.random.randn(n, n) Sigma = Sigma.T.dot(Sigma) orig_weight = [0.15,0.25,0.15,0.05,0.20,0,0.1,0,0.1,0] w = Variable(n) mu = np.abs(np.random.randn...
I have understood how CUR and SVD works, but have not been able to understand the following. How can we use CUR in place of the SVD decomposition? Do the $C$ and $R$ matrices in the CUR follow the same properties as those of $U$ and $V$ matrices in the SVD decomposition? If we want to reduce the dimension of the orig...
I am working on a implementing a simple quadratic optimisation problem: $$\min _x \; {\underline{x}}^T Q {\underline{x}}$$ $$s.t. \,\quad {\underline{\mu}}^T{\underline{x}} = R^*$$ $$ \quad \quad \underline{1}^T\underline{x} = 1 $$ I also expect to go on to include the inequality constraint, as an additional complexity...
I'm implementing a function $f(x_1, x_2, \dots x_n)$ given by the ratio of two closed form equations. $$ f(x_1, x_2, \dots, x_n) = \frac{g(x_1, x_2, \dots, x_n)}{h(x_1, x_2, \dots, x_n)} $$ Unfortunately, when $x_1 = 0$, both $g$ and $h$ are $0$. However there is a well-defined limit $$ k (x_2, x_3, \dots x_n) = \lim_{...
I have a problem that I have been attempting to solve for a few days now. I was wondering if I would be able to get some assistance from the community. In order to detect if a point is in a polygon, I am using the winding number method. The algorithm is based on what I found on this site here: http://geomalgorithms.com...
As a model for a nonlinear least-squares problem with a large linear part problem, consider $$ \Delta u = 0 \quad\text{in } \Omega,\\ n\cdot\nabla u = 0 \quad \text{on } \Gamma,\\ (u(x_i) - u(y_i))^2 = 1 \quad \text{ for } i \in\{1,\dots,10\}, $$ i.e., on a domain $\Omega$ we're looking for a function $u$ that's somewh...
I'm looking for the best way of implementing the following algorithm: consider the set of all polynomials with a high degree (say, degree 30) whose coefficients ranges from a given set of values (say, {-1,0,1}). To any polynomial of this set, I want to apply some test (say, to verify if all its roots are real). If the ...
I'm having trouble figuring out how to implement boundary conditions for this problem: \begin{align} \frac{\partial n}{\partial t} &= D_n\nabla^2n - \nabla\cdot\left(\frac{\chi}{1+\alpha c}n\nabla c\right) - \nabla\cdot (pn\nabla f) \\ \frac{\partial f}{\partial t} &= \beta n-\gamma nf \\ \frac{\partial c}{\partial t} ...
I am trying to solve the following diffusion equation problem: $\frac{\partial f}{\partial t}=\frac{\partial (D\frac{\partial f}{\partial x})}{\partial x}+S$ $D=1+x^{2}+\sin(x)$ $f(x,0)=1 , f(0,t)=f(1,t)=1$ $S $ is choosen adequately in order to have $f_{ana} = 1+\sin(\pi x)\sin(\pi t)$ as the analytical solution of ...
I am trying to solve this diffusion equation : $\dfrac{\partial D\dfrac{\partial f}{\partial x}}{\partial x}+S = \dfrac{\partial f}{\partial t}$ ($D$ is not constant and varies according to $x$) with the following BC: $f(x,0)=1 , f(0,t)=0, \dfrac{\partial f}{\partial x}(1,t)=0$ I am using a central finite difference s...