instruction
stringlengths
43
28.1k
I am implementing an arbitrary bits random number generator (in [$0,2^n$)) and also want to ensure that the generator always generate unique numbers until all possible numbers generated, so I implement it using LCG (I also considered the linear feedback shift register method, but it cannot be scaled to arbitrary number...
Background I am trying to analyse fourier characteristics of a derivative. For example if I have a first order derivative approximated as following: $$\frac{\partial \Psi(x)}{\partial x} = \frac{\Psi_{i+1}-\Psi_{i-1}}{\Delta x}$$ to get its fourier characteristics, substitute $\Psi(x)= e^{j\, kx}$ in LHS, and its dis...
I am a Computational Biology master's student and I would like to study differential equations (both ODEs and PDEs). I tried to have a look at the available textbooks but what I found is either too theory-oriented or too applications-oriented. I do not want to waste time proving theorems but I do not want to simply sol...
Here, $n$ could be a few hundreds, or even thousands, so it is not possible to pregenerate a list of $$\{0, 1, \dots, 2^n-1\}$$ and shuffle it. Because it is traversal, no number should be visited twice. I want the process of generating the next number as fast as possible. I was trying to use LCG, but it was too slow ...
I have found the following example which is produced as documentation for RS3 geotechnical FE software. This is a validation document that goes through an analytical verification of triaxial testing for modified cam clay material model. It relies heavily upon the p-q stress representation of the model to make its argum...
I have a linear elliptic PDE (unfortunately not allowed to be shown here) with a constant parameter $\epsilon$ giving the stable solutions qualitatively shown by the functions below. As we smoothly increase $\epsilon$, the solution changes "qualitatively" from the viewpoint of the number of extrema relating to the sol...
Cross posted in mathematica.SE. Question : I want to test the solution which is given below is right by Matlab/Maple/Mathematica. Please look the post in mathstackexhange or Please look below. Q: Solve the following heat equation on the semi-infinite rod $$u_t=ku_{xx}$$ where $x,t>0$ and $u_x(0,t) =0$ and $u(x,...
I have a question concerning the branch of successive iteration methods (Newton, Runge-Kutta). I definitely know (or can read in Wikipedia) the implementation of these methods. But I was wondering about the precision in special case. I have a function $$ D(\omega)=det(L_{m,n}(\omega)), \omega = \omega'-i\omega'' $$ and...
I implemented as an exercise a program to sample the statistics of the escape time of a Brownian particle in a potential well. I used the Euler-Maruyama method to numerically integrate the trajectories of the solution of the Ornstein-Uhlenbeck equation. For each trajectory I stored the escape time from the well. #inclu...
For using any programming language, a mathematical formula should be written in the corresponding code. I wonder if there is any service (for any programming language, Matlab, Mathematica, Python, etc) to directly translating a mathematical formula (e.g., written in TeX) into the programming code. Input: a mathematical...
The equation and its meaning: Consider two sets $(A)_{l=0,...,m_a},$,$(B)_{l=0,...,m_b}$ of hermitian matrices and a set of positive semidefinite matrices $(C)_{l=0,...,m_c}$. Each matrix has the dimension $n \times n$. These form the ODE: $$ y^\prime(t) = \sum_{i=0}^{m_a} (A_iy+yA_i^\dagger) + \sum_{i=0}^{m_b}(B_iy-yB...
I have a CFD solver at hand which can deal with 2 phases and so far is able to exchange momentum and energy across the interface, where both phases meet. How this is done is well documented in the following paper "A conservative interface method for compressible flows" by Hu, Khoo and Adams, which publicly available. I...
I am trying to start using FEniCS, but have a problem with the simple hello world examples given in the books. Could you please give me the simplest hello world example for solving the Fick's second law. $$\frac{\partial c}{\partial t} = D \frac{\partial^2 c}{\partial x^2}$$ How can we apply the boundary condition to t...
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 decomposed like so \begin{equation} v = \sum_j \alpha_j u_j, \end{equation} where $u_j$ are the eigenvectors of $M$. I ...
Iterative eigensolvers such as ARPACK, give the option to find a subset of the eigenvalues which have the largest imaginary part. My question is how do these algorithms work. As I understand it, generally such algorithms use Krylov spaces and shift-invert methods which are very good at finding eigenvalues either at the...
I'm working on trying to extract the eigenvectors from a series of observations from a random variable, by using the PAST algorithm, see e.g. 6.2.3 in this book: Large pdf. I don't understand the cost function as described here. The citation refers to B.Yang.Projection Approximation Subspace Tracking. IEEE Transac...
So i have been working (as an undergrad, by working i mean "Redoing a few things my professor does") in a SIRS model for epidemies. SIRS stands here for: Susceptible -> Infected -> Recovered -> Susceptible. So, the system of 1st order differential equations that rule the model is: $$ S'(t) = - \beta I(t) S(t) + \mu R(...
This question on StackOverflow has led me to ask myself what would be involved in solving an equation like this one using tools available to the Python programmer. $$ \frac{0.125567841}{d^{2.25}} = \frac{2.513274d+0.10053+2.11\pi}{d+0.04}$$ What are the fundamental numerical tools that one would use to get the one real...
My variables are stored at the center of the cells. How can I transfer these values to grid points? If I calculate the algebraic average value there may be a shock.
Consider a non-convex distributed optimization problem. We have $X$ = a set of $n$ decision variables: $x_i$ where $i=1..n$ and $x_i \in R$, the set of Reals. We have $F$ = a set of $m$ constraint cost functions: $f_j($x$)$ where $j=1..m$ and each $f_j$ is defined for a subset of $X$ and each $f_j$ is known only to ...
I want to filter on 5000 stocks, each of which has 4 month or more worth of data (>= 500 data points each). my filtering criteria will be based on 8 calculated values from the data points. for example, moving average, standard deviation and values alike. my tools of choice are python pandas, numpy and CUDA C++; please ...
I am modeling some aerodynamics equations and am using meters / centimeters, kilograms, and seconds. I've heard that, "matlab doesn't know units". So, how can I make sure that it does? Just simply by being consistent in all of my code? E.g., if I run an ode solver in matlab for a time scale of [0 30], can I think o...
Devil-may-care that I am, suppose that I wanted to 'simplify' the following expression, utterly ignoring the fact that it's very naughty to raise various kinds of numbers to arbitrary powers or to divide by zero. $$ \frac{0.125567841}{d^{2.25}} = \frac{2.513274d+0.10053+2.11\pi}{d+0.04}$$ This is to say, I would like ...
I'm trying to use Riks' method and I'm not sure how to set the initial values for the loading coefficient, nor the tangent vector (i.e. the derivative of the displacements and loading coefficient with respect to the path length). At the bottom of page 538, the author assumes that these are known at the outset. The be...
I believe this might be a recurring topic, but i have not found a post that directly related to this issue. I come from a finite volume background and my experience is more with predictor-corrector schemes (such as SIMPLE or PISO), so my knowledge of stabilized finite element (Galerkin Least Square (GLS) or Variable Mu...
I am attempting to solve a large system, $\bf{Ax} = \bf{b}$ with the help of PETSc. Due to the size of the problem, I'm using a matrix-free approach, where $\bf{A}$ is just a shell. I'm also providing my own preconditioner (which is not a shell), and I'm using ilu(2) factorization on the preconditioner. The issue: the ...
I have a m*n matrix (m>1000000, n>50000). What I want to do now is to pairwise every two rows of the matrix and do some further computation (e.g computing common elements of two rows, or reveal subsumption relationship between two rows). I wrote applications with naive code (using two for loops) which can work for smal...
Suppose $ q $ and $ A $ are given and that $ q, p \in R^{N} $ and $ A \in R^{NxN} $, then how can I find the vector $ p $ such that $$ (q - p)^{T}A(q - p) $$ is minimized constraint to $ \sum_{i=1}^{N} |p_{i}| \leq 1 $ (thus the $ ||p||_{1} \leq 1 $ ) using projected gradient descent? Is it also possible to apply pro...
I am thinking to use discontinuous galerkin FEM (DGFEM) method to estimate discontinuous displacement field $u: \Omega \rightarrow \mathbb{R}^2$ at the crack surface of a material. The domain is discretized with triangles. I can think two ways to define control points where we evaluate displacement fields Control poi...
I have two sets of experimental data: $\phi(t)$ and $I(t)$. In theory they are related to each other as: $\phi(t) = nI(t) $. By fitting these curves together I can find the value of $n$ (which is a constant). I can calculate the error of this fit using residue and covariance. Now, for each point $t$ of my data sets I a...
I am interested to study crack propagation in a hyperelastic material in a variational setting. The crack surface exhibits a jump discontinuity. The function space for displacement field should consist of discontinuous functions. The discontinuous galerkin finite element (DGFEM) approximation space consist of piecewise...
I am trying to solve the following equation: $$\dfrac{\partial }{\partial \epsilon}\left[B\left(\epsilon\right)f_e\left(1-f_e\right)+D\left(\epsilon\right)\dfrac{\partial f_e}{\partial \epsilon}\right] = R\left(f_e, f_h, E\right)$$ Till now, there is nothing special at all, and I can solve this (with a simple $R$). ...
I am trying to solve equations of motion for an harmonic oscillator using 4th order runge kutta method, but as a result I get almost constant velocity and position; I feel that the problem is that I did not fully understood the method. This is th code I am using (in c++) #include <iostream> #include <stdlib.h> #include...
I'm working on the Nonlinear Schrodinger equation (NLSE) in 1d: $$i\psi _t (t,x)+ \psi _{xx} + |\psi|^2\psi = 0 \, ,$$ for $t\geq 0$ and $x\in \mathbb{R}$. This equation is integrable, and so similarly to the KdV equation, there is a way to solve it using the Direct and Inverse Scattering Transform. What I'm looking f...
Consider the following logistic function in 1D for the domain $0$ to $1$. $$ f(x) = \frac{1}{1 + \exp(-50(x-0.5))} $$ Let's say I resolve this on two meshes: first with 11 equispaced points (0.0, 0.1, 0.2, ... 1.0) second with 101 equispaced points (0.0, 0.01, 0.02, ... 1.0) The plots for the two meshes look like thi...
I'm working on optimizing the parameters of a mathematical model to fit experimental data, using an existing formula for the likelihood of observing the data given a set of parameter values. At the moment I use an algorithm (bound optimization by quadratic approximation, BOBYQA) to find the values that give the maximum...
I have the linear underdetermined system $$Ax=b$$ and I need to find $x$ constrained by the maximization of a score function $g(x)$. I could find the minimum of a function like $$|Ax-b|^2+1/g(x)$$ but I wanted to know if there exists a canonical way to solve this problem, exploiting the linear part to have a more regul...
Counting FLOP may not be representative of the actual algorithm real world performance but still all the GPU manufacturers mention FLOPS as a metric of Performance on GPU. Is there any way that this metric can be misleading in terms of GPU performance?
I need to take the Fourier transform of a 3D function $h(r)=h(|r|)$ so that I can invert a convolution problem. What is the best way to do this with Python? I know the the FT is equivalent to a sine transform (see below) but I can't find a Python library that appears to let me do this integral. One issue I have is that...
I've been learning about the Discontinous Galkerin Method by reading the book by Hesthaven and Warburton and have ran into a problem with the advection equation with forcing $u_t + u_x = g(x,t)$ Following the book I've been able to implement a method that works when $g(x,t) = 0$ in Mathematica but am having trouble to ...
Is the exponential function problematic and very expensive to compute in Matlab? When I write a new term for my model of ODEs that has an exponential term in it, the program almost never finishes debugging, and I hear the fan on my computer go crazy. So I quickly stop debugging and remove that term in my model. And t...
I am trying to solve a Vertex Centered, Finite Difference, Poisson equation $-\nabla^{2}u=f$ with Dirichlet boundaries on the left and bottom and Neumann boundaries on the top and right using Geometric Multigrid. An illustration is shown in 2-D (apologies for the hand drawn figure). Crosses indicate unknowns, red squa...
I have implemented finite-difference WENO scheme for Euler equations (with some variants - WENO-JS, WENO-Z, WENO-M, different flux splitting). It works well, but have problem with so-called carbuncles (shock instability in the areas where its front is almost aligned with the grid). This problem seems to be well-studied...
Suppose I have a nonlinear system of PDEs. I am actually interested in Navier-Stokes, but, for the sake of simplicity and example, suppose I had $$ \frac{\partial f}{\partial t} - f \frac{\partial g}{\partial x} = 0 $$ $$ \frac{\partial g}{\partial t} - g \frac{\partial f}{\partial x} = 0 $$ I assume that the domain $\...
I am trying to calculate the energy, magnetization and specific heat of a two dimensional lattice using the metropolis monte carlo algorithm. import numpy as np import random #creating the initial array def init_spin_array(rows, cols): return np.ones((rows, cols)) #calcuating the nearest neighbours def find_neigh...
This is a follow-up of a previous question. Let $p$ be a polynomial with floating-point coefficients. Is there a method for finding intervals where evaluating $p$ in floating-point arithmetic always gives the correct sign? I want to find (ideally, maximal) disjoint interval $I_1, \dots, I_m$ such that for all floating-...
I am using Dunavant quadrature in my software, specifically this file by John Burkardt. Recently, I wanted to convert the code into a constexpr code in C++. But doing so requires me understanding what the code does. I have read the code and the paper and I am confused about the suborders. I have specifically three ques...
I have a very high dimensional signal, say $15$ dimensions. Across each dimension the width is $N$ points. So total number of points is $N^{15}$. I already have the FFT given to me. Only low frequency coeffs are non zero. The non zero coeffs are the ones inside of the hypercube of width 5. So only $5^{15}$ are non zero...
Hi all and thank you in advance. I am working on a time-dependent transport-chemistry model to study the composition of planetary atmospheres. The equations are the following $$\frac{\partial n(z,t)}{\partial t} = -\frac{\partial \Phi (z,t)}{\partial z} + p(z,t) -n(z,t)l(z,t)$$ for each chemical component, characterize...
Hard to come up with a good title. I'm looking for an algorithm to adjust a range. Say I have 5.34 as min and 23.96 as max value. This gives it a range/difference of 18.62. I now want to divide this number by n (in my case always 5.5) and result of that division should be a "nice" or meaningful number to make a series ...
I have implemented a split-step-method for an equation of the shape $$\partial_z E = i\partial_x^2E+ic|E|^2E$$ resulting in a split into the linear part $$L=\partial_x^2$$ and the nonlinear part $$N=c|E|^2E$$ giving me $$E(x, z+\Delta z)=\exp(i\Delta z(N+L))E(x, t)$$ But now my $c$-variable is non-constant, but rather...
In this post I found a very similar probem to the one I have, but not a satisfactory answer for my purposes. I have a set of matrices $C_\ell$. They are exactly symmetric by construction. Unfortunately, they are also singular. Their structure is similar to a block matrix. Here a "picture" of how they look like: 0000000...
I have the following coupled differential equations also known as Guiding Center Approximation. It is used to explain the position- and velocity change of particles (electrons and protons, N = 1000) moving in plasma. I am trying to either solve this using the Runge-Kutta 4th order method or the built-in ODE45 in Matla...
If I have a partial differentail equation such as $\frac{\partial^2 u}{\partial t^2} + c^2 \frac{\partial^2 u}{\partial x^2}$, with boundary conditions $u(0,t) = 0$ and $u(1,t)=0$, I can solve this system using separation of variables: $u=X(x)T(t)$. This means I have an ODE: $X''(x) + (c^2-\lambda)X(x)=0$, with $\lambd...
In research on inverse problems, it's common to construct a synthetic data set from a known set of parameters and then test whether the inversion technique can reconstruct those parameters. In doing so, it's important to add appropriate levels of random noise to the synthetic data. Furthermore, if the method used to ...
I'm trying to simulate a 1D model of two bodies sliding on each other with a Coulomb friction in between. As I have explained here I modeled the friction as : The force required to keep two bodies adhered $F_{a12}=\frac{m_2F_1-m_1F_2}{m_1+m_2}$ kinetic friction force $F_{f_k12}=Sign\left(v_1-v_2\right)\mu_k F_{n12}$...
I saw in a code for discretization of something like $\frac{d^2T(x)}{d^2x}$ , ( $x = sin(\theta)$ ) tries !============== here are some defined variables deltaTheta = pi/150 deltax(i) = cos(theta(i)) * deltaTheta dx = 0.5*(deltax(i) + deltax(i+1)) dx1 = 0.5*(deltax(i-1)+ deltax(i)) !============== h...
I would like to know if there exists a package or how one can fast calculate the quantiles of a function within python, where the inverse of the function for calculating the quantile depends on the first and second derivative. More concretely. Suppose we are given a $C^2([a, b])$ function $f$ and define the curvature $...
I'm trying to understand when and why one would use a staggered vs. a colocated grid in problems that have velocities and scalars that they transport (e.e. density). If scalars are defined cell-centered, then in the physics world you often hear that velocities should be defined between cells, because apart from being...
I have a simple question today. I am new to GMSH and I am currently learning how to use the software program. I am using GMSH 3.0.4. What I am looking to do is to set a different mesh size for different faces in my 2D geometry. As a test, I am creating 2 squares next to each other. The square on the left will have a me...
I am working with finite elements for Maxwell's Equations (i.e. with Nedelec's edge elements) and for computation I'm using the FEniCS-project. While implementing the Augmented Lagragian Method, I need to solve a PDE with a non-linearity of the form: \begin{align*} f(v) := \begin{cases} v, \quad &\text{on } A=\lbrace ...
I am writing a finite element code for heat transfer (scalar field problem) and starting from simple 4 node quadrilateral element. I tried computing conductance (stiffness) matrix in the physical coordinate systems and comparing the answer with isoparametric system. Element looks like: |Y | 4 _____________3 | ...
The augmented global stiffness matrix is not positive semi-definite when using Lagrange Multipliers method to enforce boundary constraints on a simple square domain of integral form: I am considering linear elastic material constitutive. I checked the condition number which is order 10e3 indicating the augmented matrix...
I am trying to solve a system of PDEs $H_{t} = \frac{0.3}{0.7} - \frac{0.005 B f(h(H))}{\theta} - \frac{0.3 f(h(H))}{0.7} + \frac{500}{0.7} (HH_x)_x + (HH_y)_y$ $N_t = \frac{N_{in} - 0.002 [N] B f(h(H)) + 0.1 \frac{0.002}{g} B - 0.1 N}{0.7 H} + 10 ([N]_{xx} + [N]_{yy}) + \frac{500}{0.7} ([N] H_x)_x + ([N] H_y)_y$ $B_t ...
Posted this at math stack exchange as well, but alas no replies! So, I have been trying to find ways of distributing particles of spherical or other shape in 3D space, e.g. rectangular space. Random() and checking for overlaps will only get you up to a certain volume fraction percentage, then it is nearly impossible to...
I'm trying to do a high precision discrete fourier transform on a signal. To examine the precision, I use a gaussian function as the signal, because the fourier transform is also a gaussian function. The code is as follows #include <stdio.h> #include <tgmath.h> typedef long double complex cplx; long double PI; void ...
Background: Lagrange multiplier method has been employed in numerous fields, such as contact problems, material interfaces, phase transformation, stiff constraints or sliding along interfaces. It is well known that a bad choice or design of Lagrange multiplier space will produce oscillatory results (unstable problem) o...
I have implemented a pretty straightforward finite element solver for the following Poisson equation. For the purposes of this question we can assume the source term and the Dirichlet data both vanish. I assume that $g\in H^{-1/2}(\partial \Omega_N) \cap L^2(\partial \Omega_N)$ (instead of just $g\in H^{-1/2}(\partia...
This is perhaps a more focused version of this question. Using standard notation, I have a code that works and solves the following PDE using a Raviart Thomas mixed method. $$\begin{align} 0 &= \mathbf{q} + \mathbf{\nabla}u && x\in \Omega\\ 0 &= \mathbf{\nabla} \cdot \mathbf{q} && x\in \Omega\\ g &= \mathbf{q}\cdot \m...
The IEEE Standard for Floating-Point Arithmetic section "9.2 Recommended correctly rounded functions" lists functions that are recommended (but not required) by a language standard to provide, among them an exp2 function as a particular example. If a language provides exp2, does the standard require it to be correctly...
I'm trying to understand what a mixed FE method is, and I was recommended this pdf: http://www.ima.umn.edu/~arnold/papers/mixed.pdf (Arnold, Mixed Finite Element Methods for Elliptic Problems). On first page the author states the motivation as 'treating stress and displacement fields as primary variables'. However the ...
I have heard this many times that "FD is a special case of FE" and separately, that "FV is a special case of FE". However I have never come across a brief document that substantiates that claim, through derivation, examples, proofs, whatever. I understand the basics of FE and the 3 manifestations: Collocation, Least-sq...
I wonder why does this algorithm below work well? Many appreciates! Task: Suppose all elements in an array with length $n = 2^m$ are in descending order: $a_1 > a_2 > ... > a_n$, we need to turn them into ascending order. Algorithm: For each step from $1$ to $m$: Swap each adjacent (odd index, even index) pair into a...
In standard Monte Carlo simulations, say for hard sphere systems, how should one compute the mean-squared displacement of the spheres in order to extract dynamical properties such as the diffusion coefficient of the spheres? First problem that comes to mind is, how do we map our Monte Carlo steps to a real physical ti...
I'm running out of time for this code so any help would be greatly appreciated. I am currently coding the 2D heat/diffusion equation in matlab but i'm having trouble adding in the source term. my equation looks like this: $$ \frac{\partial u}{\partial t} = \alpha_x \frac{\partial^2 u}{\partial x^2} + \alpha_y \frac{\p...
Which Python package is suited for solving problems of the following type? Given the rigid body depicted in violet in the following sketch I would like to do the following: Define cartesian coordinate systems $\text{cs0}(x_0, y_0, z_0)$, $\text{cs1}(x_1, y_1, z_1)$ and $\text{cs2}(x_2, y_2, z_2)$. Specify forces and ...
It seems to me that a useful concept to define when studying Krylov subspace methods is the idea of a vector $v$ that belongs to a Krylov subspace $\mathcal{K}_{n+1}(A,b)$ but not to the preceding one $\mathcal{K}_{n}(A,b)$, i.e., $v$ can be written as a polynomial $v = p(A)b$ of degree exactly $n$, with a nonzero lead...
I wish to solve an eigenvalue problem: $$\nabla^{2}f=Ef $$ If I assume spherical symmetry $f(r,\theta,\phi)=f(r)$, I can reduce the problem to 1D: $$(\frac{2}{r}\frac{d}{dr}+\frac{d^{2}}{dr^{2}})f=Ef$$ My boundary conditions are $f(r=0)=0$ and $f(r=L)=0$, where $L$ is the size of the discrete grid. I am attempting to s...
I'm trying to solve a problem of finding the displacements of an elastic material subjected to external forces. Those external forces are themselves a nonlinear function of the material displacements. The first step is to define a functional for the energy in terms of the displacements. The solution is then the displ...
I want to solve the diffusion equation using the method of lines with Neumann boundary conditions $$ \frac{\partial p}{\partial t}=\frac{\partial^2p}{\partial x^2}\\ \frac{\partial p}{\partial x}(x=0)=\frac{\partial p}{\partial x}(x=1)=0\\ p(x,0)=\begin{cases} 1/dx \quad x=0.5,\\ 0 \quad elsewhere \end{...
I've just finished learning the physics behind the problem and would like to write a program in C++ than can solve the problem. I'm actually stuck at the start. I've quite a bit of research, the problem is there is not too many examples of code used to solve the problem. I'm going to solve the problem using finite-dif...
I'm trying to simulate the growth of a brain tumor using a 3d reaction-diffusion model $ \partial_{t}u = \nabla.{(D\nabla{u}) } + ku.(1-u)$ , knowing the initial distribution of tumor $u^0$, the non-homogeneous diffusion coefficient $D$ and the non-homogeneous net-proliferation map $k$. So I first tried to proceed to s...
In Machine Learning field, is there any work done, or research, or info in general about finding optimal permutations? For eg. to find a number of optimal arrangements of sliced shapes on 2D sheet of material - so that there is low number of leftovers? I assume it can be done by brute-forcing permutations, but what abo...
I have a linear ordinary differential equation (ODE) with a system matrix with constant coefficients: $$\dot{y}(t) = \mathcal{A}\; y(t), \quad y(0) = y_0$$ with $y(t) \in \mathbb{R}^{n \times 1}$ and $\mathcal{A} \in \mathbb{R}^{n \times n}$ where $\mathcal{A}$ has constant coefficients. I have a (large) series of $r$ ...
I'm trying to find the largest eigenvalues of very large $N \times N$ matrices ($N = 10^{10}$ and larger). The matrices are not sparse but the multiplication operation is fast. For now, I'm using methods without explicit matrix storage, from the simple power method to Krylov-Schur (using petsc/slepc in C). But all th...
How can I write an algorithm to calculate $R_n$s for any desired $n$ from the following equation with given $f,R_0$? So the output of the code would be $R_1,R_2,...$ $$R_n^2-2fR_n=R_0^2-2fR_0+\sum_{i=0}^n\sum_{j=0}^nR_iR_j$$ I have derived this equation for my specific problem myself and I can calculate every $R_n$ man...
I am using Chebychev collocation nodes for approximation, and my problem requires me to calculate derivatives of the polynomial. I have been reading from a few sources, but I am not sure I understand how to do it. Could anyone please help me with how I go about this? Thank you very much. Anup
I am trying to solve for the matrix $C$ in $Q = YCZ$ in matlab. I have preliminary results but they don't seem realistic. Here, $Q$ is $n \times m-1$, $Y$ is $n \times p$, $C$ is $p \times m$ and $Z$ is $m \times m-1$. The value of $n$ is very large, say $n = 10000$. On the other hand, $m$ and $p$ are of the same order...
I was looking for some help with derivatives of Chebychev polynomials at zero points. The recursive expression, $$ T_{(j+1)}(x) = 2xT_j(x) - T_{(j-1)}(x) $$ has the derivative $$ T'_{j+1}(x) = 2T_j(x) + 2xT'_j(x) - T'_{j-1}(x) $$ with $T'_0=0$ and $T'_1=1$. But I was looking at Trefethen's book (Chapter 6, Page 54) w...
I am developing a parallel 2D CFD code in C++ using PETSc and would like to use it as an opportunity to learn about VTK/Paraview. Right now, I have each processor output an ASCII file for the portion of the domain that it owns. Where is a good place to start to learn how to format the data to make a VTK file and view ...
I'm working on a Real-Time TDDFT implementation and I am currently comparing different propagation schemes for the propagation of the Kohn-Sham wave function, $$ \phi(t+\Delta t) = \hat{\mathcal{U}}\phi(t). $$ An external field is incorporated by a vector potential and the kinetic energy matrix element is modified such...
I am curious if anyone had literature references or knowledge on how to apply the Crank-Nicolson (with approximate factorization) to the $$ \nabla \cdot (\nu (\nabla \mathbf{u} + \left(\nabla \mathbf{u}\right)^{T})) $$ What I am unsure about is how to handle the mixed derivative. Currently I am using Crank-Nicolson f...
This is to help me relate continuous and discrete, predict what my scheme should be doing, and move toward using the method of manufactured solutions. There's a solution for constant velocity $c$ advecting a quantity $u(x,t)$ over a 1D domain: $$ \frac{\partial u}{\partial t} = - c\frac{\partial u}{\partial x} \\ u_t...
I have a coupled nonlinear PDE system in 1 spatial dimension, in which I want to solve using FiPy. The dependent variables are $n$ and $T$: \begin{align} \frac{\partial n}{\partial t} \,&=\, D\,\frac{\partial^2 n}{\partial x^2} \\ \frac{\partial T}{\partial t} \,&=\, \frac{D}{\zeta}\,\frac{\partial^2 T}{\partial x^2} \...
Having both programmed my share of c++ and studied some beginners group theory some year ago, I got curious about this... Is there any particularly popular template based (object oriented) design pattern for systematically programming any kind of stuff related to group theory?
I am computing the maximum of a function (with two-variables) using Newton-Raphson method. The function is : $e^{-(x \ - x_0)^2 - (y \ - y_0)^2}$, whose maxima exists at $(x_0,y_0)$. The Jacobian will be a function of the second derivatives (including mixed) of this function. It can be written as : $J = e^{-(x \ - x_o...
What is the best method to find for a linear system of inequalities $Ax\ge b$ with dense $A$ of moderate dimension the affine subspace spanned by the feasible points (i.e., the implied equalities $(Ax)i=b_i$) and a relatively interior feasible point in this subspace? It shouldn't need the solution of many linear progra...
I'm trying to implement Linear Least-Squares Optimization for Point-to-Plane ICP Surface Registration Paper describes linear approximation for point to plane distance for rigid ICP. This approach is pretty straightforward however during implementation I faced with some strange degenerative case where such approximation...
Say I have a matrix like this: \begin{bmatrix} 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 1 \\ 0 & 1 & 1 & 1 \\ \end{bmatrix} And this one: \begin{bmatrix} 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 1 \\ 0 & 0 & 0 & 1 \\ \end{bmatrix} The difference between this two matrices is 2 elements in 12, or 16,67%. So, I ...
I need to solve the following partial differential equation in seven variables with four boundary conditions. I don't think Mathematica has the capacity to solve this differential equation. Do you know of scientific packages which can be used to solve this equation and plot graphs of the dependent variable against eac...