# All Questions

7,951 questions
Filter by
Sorted by
Tagged with
1k views

### Why would a computational scientist need to implement their own version of std::complex?

Many of the better-known C++ libraries in computational science such as Eigen, Trilinos, and deal.II use the standard C++ template header library object, ...
1k views

### Why does std::complex<> initialize its value to 0 upon default construction?

Doing so strikes me as a waste of time. Consider std::complex<double> *a = new std::complex<double>[1<<28]; This could be near-instantaneous ...
250 views

### Forced viscous damping in elastodynamics

I have an 2D elastodynamics problem, that is a problem which is driven by the Cauchy equation: $$\rho\ddot u-\mathrm{div}\sigma=\rho f$$ where $u$ is the displacement, $\sigma$ the Cauchy stress ...
2k views

### Compute smallest eigenvectors of a matrix

It appears that matlab's eigs is giving me bad approximations of the smallest eigenvectors of a matrix. I assume I can use some slower methods which would also be ...
43 views

### The region of allowed values ​​for solving the equation in Mathematica

In[2]:= Solve[sqrt(2x-9) == sqrt(4x+3), x] Out[2]= {{x -> -6}} But mathematically there is no solution, since sqrt (-21) is not defined. There is a flag that ...
4k views

### Problems that can be reduced to the Traveling Salesman Problem

Which search/optimization problems can be reduced to the famous "Traveling Salesman Problem"? For instance, I have a collection of N particles, in 3D, and there is a function (Van der Waals energy) ...
197 views

### MatMatMult and KSPSolve for MATMPIDENSE matrices

I'm trying to use MATMPIDENSE matrices to solve a system of type Ax=b, but I have some problems. The KSP documentation says that KSPSolve for dense matrices requires to set a 'gmres' solver and a 'lu' ...
69 views

### Are there any open standards for data exchange between components of a spatial model?

I'm just getting into climate research, and am amazed at how much poorly documented legacy code is used. This kind of thing means that models more or less have to be maintained by the people who wrote ...
4k views

### How to find QR decomposition of a rectangular matrix in overdetermined linear system solution?

While trying to find cell-centered gradients in finite volume method computation of incompressible fluid flow I get over-determined linear system. This is a well known "cell based least-square" ...
1k views

### Reporting curve-fit results in a scientific paper

(I hope this question fits this site; if not, accept my apologies). I ran a certain simulation, and got a time series y(t), t = 0, 1, ... 20. After trying some functions, I found that: ...
1k views

Below there are two algorithms for solving tridiagonal linear systems of the form $$\left[ \begin{array}{ccccc|c} b_1 & c_1 & & & &d_1\\ a_2 & b_2 & c_2 & & &... 1answer 318 views ### Generating a tuple in Maple I am trying to generate a 2 tuple using maple. Can anyone give me the command to generate this? Thank you very much. 2answers 4k views ### A good finite difference for the continuity equation What would be a good finite difference discretization for the following equation: \frac{\partial \rho}{\partial t} + \nabla \cdot \left(\rho u\right)=0? We can take the 1D case: \frac{\partial \... 3answers 114 views ### Whats wrong with my running time calculation? I am running a linear algebra iterative method (PCG) for solving Ax=b, the dimension of the matrix is 10000x10000. So, I did 2 preliminary analyses: Memory Analysis The size of the matrix dominates ... 1answer 169 views ### Recover curves from noisy collection of points Background: I'm trying to make a system that tracks a number of bubbles in a video I'm implementing the bubble detection in the single image case using the Circular Hough Transform. Due to occlusion,... 2answers 1k views ### Molecular dynamics simulation of water vapor? I'm trying to do MD on water vapor. As I know there exists some water models for liquid water, such as SPC,SPC/E,TIP3P, but will they also apply to vapor state of water? And what's the difference of ... 2answers 119 views ### Estimate Norm of a black-box functional Let V be a finite-dimensional vector space with norm \|\cdot\| and let F : V \rightarrow \mathbb R be a bounded linear functional. It is only given as black-box. I would like to estimate the ... 1answer 69 views ### How to use a web-embedded model in a computational workflow? There is a model embedded in a web browser (Caprio 1998) that I would like to use in an MCMC algorithm. What is the best way to do this? I could implement the model in my favorite language but I ... 3answers 327 views ### Given large x \in \mathbb{R}, How to determine if 2^x is an integer? Given large x \in \mathbb{R}, I want to know whether or not 2^x is an integer. Is there any fast way to answer the question for x>2^{500}? I have also asked a slightly different form of this ... 1answer 129 views ### Constructing the origin position by transforming distance information Suppose a set of n points, n\in M, is given in some d-dimensional space, X\in\mathbb{R}^{n\times d}. Among these n points, some k\in K are selected, so k<n, and the distances from ... 2answers 382 views ### Tools for computing an electric field based on location of charges? I have the positions of a large number of charges (the strengths are known, but are also variables). Are there any tools that will allow me to visualize the electric field induced by these charges (or ... 2answers 2k views ### Depth of a Binary Search Tree I wrote a function to search a Binary Search Tree, but I have logic problems: When I insert some values, and I have a tree of 2 levels, and the final level (2 in this case) is not full (full is that ... 1answer 172 views ### Estimating time for running serial/parallel codes Assume I am running an iterative method, I have a rough estimate of how many iterations it will need, How do best estimate the time it will run for in serial? For instance, If I have Conjugate ... 4answers 4k views ### Are DAXPY, DCOPY, DSCAL overkills? I have implemented CG in FORTRAN by linking it to Intel MKL. When there are statements like: (Refer Wikipedia) p=r; x=x+alpha*p r=r-alpha*Ap; or similar ... 4answers 4k views ### What are the best Python packages/interfaces to sparse direct solvers? Please list the Python package (petsc4py, etc...) and the sparse direct solvers it supports. One (community-wiki) answer per package, please. 3answers 498 views ### Quality Measures for Various Pseudo-Random Number Generators According to this paper, Ideally, a pseudorandom number generator would produce a stream of numbers that: are uniformly distributed, are uncorrelated, never repeats itself, ... 2answers 417 views ### Is there a generalization of the Sylvester Inertia Law for the symmetric generalized eigenvalue problem? I know that in order to solve symmetric eigenvalue problem Ax = \lambda x, we can use the Sylvester Inertia Law, that is the number of eigenvalues of A less than a equals the number of negative ... 0answers 137 views ### Potential Reduction and Primal Path following methods In both the potential reduction and primal path following interior point methods for linear programming, a barrier function is constructed which contains the terms -\sum \log x_j where x_j are the ... 1answer 208 views ### Error message when trying to get PETSc to draw to an X terminal by passing -mat_view_draw I've made a matrix, and now I want to draw it on the screen to make a basic check of correctness. The documentation for MatAssemblyEnd() states that I can pass an ... 2answers 4k views ### FEM: singularity of the stiffness matrix I'm solving the differential equation$$ \left( \sigma^{2}(x) u ''(x) \right)'' = f(x), \;\;\; 0 \leqslant x \leqslant 1 $$with initial conditions u(0) = u(1) = 0, u''(... 0answers 156 views ### Is there an easy way to read a PetscBag into a python dict? I'm using a PetscBag to store the input parameters of my program. At some point, I'm going to need to use python to plot these parameters against some output parameters, and ... 3answers 214 views ### Converting from planar polynomial domain to planar polygon Let's assume we have a planar domain whose boundary can be described with a polynomial curve (like Bezier curves). Now assume that you want to produce a discretization of the boundary, i.e. you want ... 1answer 480 views ### How to find the interior eigenvalues by krylov subspace method? I am wondering how to find the eigenvalues of some sparse matrix in given interval [a, b] by iterative method. To my personal understanding, it is more obvious to use Krylov subspace method to find ... 1answer 554 views ### Implicitly casting PetscReal to the real part of PetscComplex The version of Petsc installed on my machine has PetscScalar set to be complex. I am making a matrix which has all real entries. Something like the following code compiles: ... 2answers 472 views ### What does symmetrize mean? (imposing multifreedom constraints to stiffness matrix) I have a small FEM implementation program. And I want to add imposing multifreedom constraints (MFC) feature to it. The theory of master-slave method is given here (page 10 for general case). ... 1answer 733 views ### Finite-difference discretization for a convective term How does one discretize the classical convective term in a transport equation using finite differences? I know the finite volume schemes out ther i.e. upwind, central differencing etc. Are there ... 4answers 2k views ### Finding the square root of a Laplacian matrix Suppose the following matrix A is given$$ \left[\begin{array}{ccc} 0.500 & -0.333 & -0.167\\ -0.500 & 0.667 & -0.167\\ -0.500 & -0.333 & 0.833\end{array}\right]$$with ... 5answers 459 views ### What material should I include with a journal article (or post online) in order to make my computational research reproducible? Reproducibility has become more and more important in computational science research. (For instance, see this article by Roger Peng in Science; I'm aware of other such articles and web sites also.) ... 1answer 256 views ### Adaptive h for gradient estimation Can anyone point me to methods for varying h in gradient estimation for noisy numerical optimization? Some programs have the user give a fixed h, which is used for forward-difference or central-... 1answer 830 views ### Optimal use of Strang splitting (for reaction diffusion equation) I made a strange observation while computing the solution to a simple 1D reaction diffusion equation: \frac{\partial}{\partial t}a=\frac{\partial^2}{\partial x^2}a-ab \frac{\partial}{\... 3answers 2k views ### I/O Strategies for computational problems with large data sets? My research group focuses on molecular dynamics, which obviously can generate gigabytes of data as part of a single trajectory which must then be analyzed. Several of the problems we're concerned ... 0answers 600 views ### Perron-Frobenius theorem on general real symmetric matrices From the Perron-Frobenius theorem, it might be concluded that the spectral radius is the largest eigenvalue for positive matrices, ie, matrices with strictly positive entries. In other words, the ... 4answers 2k views ### Why can't Householder reflections diagonalize a matrix? When computing the QR factorization in practice, one uses Householder reflections to zero out the lower portion of a matrix. I know that for computing eigenvalues of symmetric matrices, the best you ... 0answers 69 views ### Understanding how Numpy does SVD [duplicate] Possible Duplicate: Understanding how Numpy does SVD I have been using different methods to calculate both the rank of a matrix and the solution of a matrix system of equations. I came across the ... 3answers 7k views ### Understanding how Numpy does SVD I have been using different methods to calculate both the rank of a matrix and the solution of a matrix system of equations. I came across the function linalg.svd. Comparing this to my own effort of ... 2answers 292 views ### What about this simple error estimate for linear PDE? Let \Omega be a convex polygonally bounded Lipschitz domain in \mathbb R^2, let f \in L^2(\Omega). Then the solution of the Dirichlet problem \Delta u = f in \Omega, \operatorname{trace} u ... 4answers 325 views ### How to create a random 3D domain representing a plant's root structure? I would like to model laminar flow of water from roots to the stem of a plant. At the very end of the roots, the tubes vary from millimeter to centimeter scale in diameter and length. As we get closer ... 3answers 138 views ### How can I compute the sensitivity index of an expression with a modulus operator in it? I have a set of equations of the form:$$\begin{align*} x_1&=(ax_0+c) \bmod (m)\\ x_2&=(ax_1+c) \bmod (m)\\ x_3&=(ax_2+c) \bmod (m)\\ &\vdots\\ x_{n}&=(ax_{n-1}+c) \bmod (m) \end{...
Suppose I knew that a random number sequence was generated by a linear congruential generator. That is, $x_{n+1}=(aX_n+c) \bmod m$ If I am given the entire period (or at least a large contiguous ...
### How can I obtain a one dimensional finite difference formula for $U_{xx}$ with unevenly spaced nodes?
I know that if I had evenly spaced points, I can use $U_{xx}\approx \frac{U_{i-1}-2U_{i}+U_{i+1}}{dx^2}$. But if my gridpoints are unevenly spaced, I assume that I can obtain the finite difference ...