# All Questions

822 questions
Filter by
Sorted by
Tagged with
7k views

### Least Squares and Fourier Series

I have a little bit of problem figuring out the relation between Fourier series and Least Squares. As far as I understand, LS is a way of minimizing the quadratic error between a measured value $y_i$ ...
3k views

### FEniCS: separate boundary conditions in normal and tangential direction of mesh boundary

Given a vector-valued PDE, I'd like to enforce the boundary conditions $$\vec{n}\cdot u = g\\ \vec{n}\cdot \nabla (\vec{t}\cdot u) = 0$$ on the solution $\vec{u}$. If the boundary happens to align ...
8k views

### Robust algorithm for $2 \times 2$ SVD

What is a simple algorithm for computing the SVD of $2 \times 2$ matrices? Ideally, I'd like a numerically robust algorithm, but I'll like to see both simple and not-so-simple implementations. C code ...
14k views

### Fast, lightweight C++ tensor library for dimension-agnostic code

I am looking for a C++ tensor library that supports dimension-agnostic code. Specifically, I need to perform operations along each dimension (up to 3), e.g. calculating a weighted sum. The dimensions ...
2k views

### Parallel I/O options, in particular parallel HDF5

I have an application that can be trivially parallelized but its performance is to a large extent I/O bound. The application reads a single input array stored in a file that is typically 2-5 GB in ...
2k views

### Example of a continuous function that is difficult to approximate with polynomials

For teaching purposes I'd need a continuous function of a single variable that is "difficult" to approximate with polynomials, i.e. one would need very high powers in a power series to "fit" this ...
2k views

### Efficiency of using petsc4py vs. c/c++/fortran

How much slower is petsc4py vs c/c++/fortran? I realize it will depend significantly on the code being executed, but what about something simple like a matrix-vector product?
1k views

### manufactured solutions for incompressible Navier-Stokes — how to find divergence-free velocity fields?

In the method of manufactured solutions (MMS) one postulates an exact solution, substitutes it in the equations and calculates the corresponding source term. The solution is then used for code ...
3k views

### Raviart-Thomas elements on reference square

I'd like to learn how the Raviart-Thomas (RT) element works. To that end I'd like to analytically describe how the basis functions look on the reference square. The goal here is not to implement it ...
494 views

5k views

### simple MHD simulation code for (self) education and play with

I would like some super simple computational code for solving magnetohydrodynamics problems. High accuracy nor performance is not my concern. I wan't it just to visually explore qualitative behavior ...
2k views

### How to compute the wavelet approximation of a function?

For the function $f(x)=x$, how to compute the wavelet approximation using Haar basis? I'm new to wavelet, I'm looking for a package which will do something like this ...
414 views

### CFL condition in polar coordinates

In this question, I suggested that the Couran-Friedrichs-Lewy (CFL) condition for the wave equation in polar coordinates reads $$C = 2c\frac{\Delta t}{\Delta r \Delta \phi} \leq C_\max \enspace ,$$ ...
167 views

### Support Vector Machines as Neural Nets?

This is more of a conceptual question. I have learned about Neural Nets, and I have some clue as to how Support Vector Machines work. I read somewhere however that given the appropriate kernel (is ...
1k views

321 views

### Commonly-used metrics to quantify the irregularity of a triangular mesh

Say you have a triangular mesh on a flat plane. This has been drawn to eventually solve some problem in mechanics, for example. A mesh of equilateral triangles is the best inasmuch as the distances ...
4k views

### discrete $L^p$ norms for non-uniform grid

I am reading a book on numerical methods and the square of the discrete $L^2$ norm is defined as $$||x||^2_2=h\sum_1^Nx^2_i$$ Every point gets a "weight", which is $h$, thus this is like an average ...
7k views

### Python implementations of Gillespie's direct method

I'm looking for a decent implementation of Gillespie's Direct Method in Python, as if I code the algorithm myself I'm nigh positive I'll do it inefficiently. Anyone have a favorite?
2k views

### Minimum image convention for triclinic unit cell

The minimum image convention (MIC), see for example a short note of W. Smith, is often used in molecular dynamics or monte carlo simulations of periodic systems with an orthorhombic unit cell. For ...
306 views

### Stabilization of convection-dominated flow and turbulence modeling

Are stabilization techniques for convection-dominated flows like SUPG+PSPG, interior penalty methods, etc. able to handle turbulent flows without tubulence model being employed, at least up to some ...
641 views

### When analyzing a parallel algorithm, how do you take communication costs into account?

My question is related in spirit to "Is algorithmic analysis by flop counting obsolete?". Counting the number of computational operations in an algorithm is commonly used as a first-order model to ...
2k views

### Solving Lx = b for big sparse Laplacian matrices

What algorithm is more practically suited in terms of performance for solving the $\mathbf{Lx=b}$ equation, where $\mathbf{L}$ is a generic Laplacian matrix (associated to a strongly connected graph, ...
1k views

### Find the direction of the gradient on a finite element mesh

Suppose we have a triangular mesh of a two dimensional shape $\Omega$, and on this mesh we define a P1 finite element structure. I know that given $u,v$ by their values at the vertices of the ...
2k views

### Trouble implementing Neumann boundary conditions because the ghost points cannot be eliminated

Neumann boundary conditions are implemented by introducing ghost points outside the domain and then using the boundary conditions to eliminate the ghost points. For example, see this question. I ...
Let us consider a problem of the form $$(\mathcal{L} + k^2) u(\mathbf{x})=0\, ,\quad \forall \mathbf{x} \in \Omega$$ with Dirichlet boundary conditions u(\mathbf{x}) = 0, \quad \forall \mathbf{x} ...
Given a matrix $M$ and a vector $v$, is there an efficient method to find the normalized eigenvector of $M$ that is closest to $v$, in that it has maximal overlap. More explicitly, a vector $v$ can be ...