instruction
stringlengths
43
28.1k
I'm looking for assistance in understanding a concise portion of a paper that involves a quadratic equation, so that I can properly implement it. There are 2 versions of the paper. Each paper utilizes a slightly different quadratic form to achieve the same goal, but I've found success with neither. Here are the papers ...
I'm no expert on the different types of algorithms to compute eigenvalues and vectors for a real, symmetric matrix (coming from linear mass and stiffness matrices for a frame FEA model). I am looking for a good blend of computational efficiency and ease of coding for a system of ~300 DoFs where I only need the first N ...
Suppose you have the following analytical information about a function $f(x)$ on $[-1,1]$: \begin{align*} f(x) &= \frac{1}{x+3}\\ f'(x) & = -\frac{1}{(x+3)^2}\\ f^{''}(x) &= \frac{2}{(x+3)^3} \end{align*} We are asked to find the linear polynomial that is the minimax (best) approximation to $f(x)$ on the interval $[-1,...
I have a set of points in a 2D space. I want to connect the outer points so I get the convex hull. The problem here is that there is a limit to the distance between two points. Let me clarify that with a picture: The green lines are lines that are good. The distance between the two points of the convex hull doesn't ex...
Suppose we have some function $f(x)$ defined as a Chebyshev series up to order $M$: $$ f(x) = \sum_{n=0}^{M} c_n T_n(x). $$ For a given coefficients vector $\mathbf{c}$, and $x \in [-1,1]$ I'm looking to determine the following: Is $f(x) > 0$ everywhere? The maximum value of the gradient $f'(x)$ The number of stationa...
I am trying to implement (in Python for now) low thrust orbit propagation for spacecraft using universal variables. For a given central body with the gravitational parameter $\mu$ and an orbit with the semi-major axis $a$ and the initial position $\vec{r}_0$ and velocity $\vec{v}_0$ at $t = t_0$ the position for a give...
I'm dealing with a set of nonlinear coupled PDEs that have the form: \begin{align} \frac {\partial y_1}{\partial t} &= y_2y_3 - y_1 \tag{1}\\ \frac {\partial y_2}{\partial t} &= y_1y_3 - y_2 \tag{2}\\ \frac {\partial^2 y_3}{\partial t^2} - \frac {\partial y_3}{\partial t} &= \frac {\partial^2 y_3}{\partial z^2} + \fra...
I am programming cubic element and very confused how to find interpolation function for cubic finite element. I have element like this in bi-unit isoparametic system : $-1 \hspace{15pt} -1/3 \hspace{15pt} 1/3 \hspace{20pt} 1$ <- distance |-------------|------------|-----------| $1 \hspa...
I am working with MATLAB, and I would have the following problem. I have the following matrix of random numbers rand(200,200) and I need to create a 3D matrix with the following structure 3D_mat(r,s,p) with 15 layers (p=15), where each layer will contain the given data rand(200,200). Perhaps, it is easy task, but I ...
Suppose I have a real vector $\bf x$ of length $KN$, where $K<<N$. Let's say I break this vector $\bf x$ up into $N$ vectors each of length $K$, $${\bf x}_1,...{\bf x}_n.$$ Now I would like to approximate the sum of their 2-norms: $$f(K, N, {\bf x})\approx \sum_{n=1}^N\left |\right |{\bf x}_n\left |\right |_2.$$ Where...
Assume I have a sequence of vectors $v_k \in V$ in some abstract vector space $V$ not necessarily equal to $\mathbb{C}^n$. Can I still use the Householder QR decomposition in this case, even though the concept of "reflecting onto the first coordinate direction" doesn't make sense if $V \neq \mathbb{C}^n$? Or do I have ...
I am simulating acoustic wave equation in which absorbing boundary condition has to be applied. It is applied in two ways Ist method is as mentioned in this paper. Boundary condition at bottom is (equation 9 in paper) $$ P_{zt} + \frac{1}{v} P_{tt} - \frac{v}{2} P_{xx} $$ which is finite differenced as following (se...
In the finite element method, we often construct the constraints of the system by adding penalty-function terms ( which often are many many magnitudes, up to $10^6$ order bigger than the largest stiffness matrix term) to the stiffness matrix by using the so-called Penalty Method (section 9.2) On the other hand, the e...
Is there any sufficient and necessary condition to check the feasibility of the linear constraints $Ax=b, x\geq 0$ without solving an LP with a constant objective function? $x$ is the variable and $ A\in\mathbb{R}^{m\times n}$ is given and has full row rank. $b$ is also given. Farka's lemma could be an option. But it...
In physical problems the infinite force is easily implemented by the mathematical form of that force, take $1/r$ as an example, whenever the distance between two particles becomes small the force goes to infinity. But, I want to simulate a system using agent-based modeling which the force between two objects becomes i...
$A$ is square and positive definite, and let $r_k = Ax_k - b$. Also let $M = \frac{1}{2}(A+A^T)$. I want to show that $$\frac{||r_{k+1}||_2}{||r_k||_2} \le \left(1-\frac{\lambda_\min(M)^2}{\lambda_\max(A^TA)} \right)^{1/2}$$ We define $x_{k+1} = x_k + \alpha_k r_k$, where $\alpha_k$ is chosen to minimize $||r_{k+1}||_2...
Edit: figure it out, made an error We are given that $$y' = f(y,t), y(t_0) = y_0$$ We want to use the following method $$ \begin{align} u^1_{n+1/2} &= u_n + \frac{h}{2}f(u_n, t_n)\\ u^1_{n+1} &= u_{n+1/2} + \frac{h}{2}f(u^1_{n+1/2}, t_n+h/2)\\ u^2_{n+1} &= u_n + hf(u_n, t_n)\\ u_{n+1} &= \alpha u^1_{n+1} + \beta u^2_{n...
I'm wondering specifically in regard to a recursive function such as massive a game tree. I can't specifically say how big yet, but definitely pushing the limits of a given processor or processor array. Is it correct to say that passing a variable to a function requires an operation. Certainly there must the the flippi...
I was trying to approximate 1st derivative of a function $\phi$ on a non uniform grids: basically my aim is to do this on a uniform grid on the same domain, so I can calculate it on the "new" grid. For example: I have $x_k$ a non uniform grid, and $\xi_k$ a uniform grid, both in $[0,1]$ and with the same length. Now wh...
How does one write general tensor contractions in the Python-based finite element package Nutils? For example, how does one write the contraction of a fourth-order elasticity tensor $\boldsymbol{C}$ with a second-order strain tensor $\boldsymbol{\varepsilon}$, to yield the second-order stress tensor $\boldsymbol{\sigma...
Suppose I am completely new with the Python-based finite element package Nutils, what example code would help me to get started?
How can one construct non-uniform rational B-splines (NURBS) in Nutils, and use them for NURBS-based isogeometric analysis?
Let $\alpha=1.714$ and $\lambda=-v(1-v^{\alpha})/\alpha$, where $0<v<1$. Consider $\phi(v)=\exp\{\int_{v_{0}}^{v}\frac{1}{\lambda(t)} dt \}$, where $0< v_{0} <1$ is an arbitrary chosen constant. How to integrate the given integral numerically and plot $\phi(v)$ vs $v$ using Matlab?
Consider the spherical advection problem: describing the conservation of a property $u$ in a closed spherical domain. $$ \frac{\partial u}{\partial t}+\frac{1}{r^2}\frac{\partial }{\partial r}\left(r^2u\ \boldsymbol{v} \right)=0 $$ In the domain $0<r<1,\ t\geq0$, with the following initial/boundary conditions: $$ \left...
I try to simulate thermal version of 1D $(x, t)$ sine-Gordon field model. I am interested in finding thermal static solution that minimizes functional of energy $E$: $$E = \int dx \left( \frac{1}{2} \phi' ^2 + 1 - \cos \phi \right) \ ,$$ where $\phi' = \partial_x \phi $ What is very confusing that acceptance ratio of ...
How do I compute the adjoint of MATLAB's dwt3 operator? In other words, how do I compute the adjoint of the linear operator that takes a 3D complex array x as input and returns the quantity dwt3(x,'db4') as output. This adjoint computation is an important step in many iterative reconstruction algorithms. One might gues...
For a typical Ridge Regression method for solving an inverse problem $$ \min_x ||A~x - b||^2 + \lambda^2||\Gamma~x||^2 $$ Which has an analytical solution of $$ \hat{x}_{est}=(A^TA+\lambda^2 \Gamma^T\Gamma)^{-1} A^T b $$ How should $A, \lambda, x, b$ be 'normalized'? I have a model where $b_{data}$ is a discrete measur...
I'm trying to use MATLAB to simulate an atom decay process by using Monte Carlo approach. The process is as follow: Suppose that atom 1 decay to atom 2, which, in turn, decay to stable atoms of type 3. The decay constants of 1 and 2 are $\lambda_1$ and $\lambda_2$, respectively. Assume that at $t = 0$, $N_1 = N_0$ and ...
I am solving a numerical optimization problem with my own L-BFGS (implemented in c++). The problem has $\approx 10^6$ optimization parameters. To find the objective function gradient, I am taking a discrete Fourier transform by using FFTW3 library in double precision, all my other calculations/variables are also in do...
I have applied SciPy's implementation of the Cuthill-McKee algorithm to a $48 \times 48$ sparse non-symmetric matrix in Compressed Sparse Row (CSR) format and the output is an array of length $48$ which the documentation calls a "permutation array". How do I use this "permutation" array? Obviously, the array is in so...
Consider the following program: $$\max_{\pmb a} \sum_i z_i\\ u.c. \pmb a \pmb P_i\pmb a^\top\geq z_i$$ where $\pmb a \in\mathbb{R}^p$ and the $\pmb P_i$ are all symmetric positive semidefinite matrix (the eigenvalues of $\pmb P_i$ are all $\geq 0$ for all $i$) and $z_i$ is a scalar. I am wondering if this is indeed a...
I am trying to generate initial velocity field which satisfies incompressible flows condition. To formulate this I am using Rogallo's procedure formulation which is given by $$ \tilde{u}(k) = \frac{\alpha k k_2 + \beta k_1 k_3}{k \sqrt {k_1^2 + k_2^2}} \hat{k_1} + \frac{\beta k_2 k_3 - \alpha k_1 k}{k \sqrt {k_1^2 + k...
As my question states, I want to calculate the Fourier transform $F(q)$ of a radial function $f(r)$ (defined on $[0,\infty)$ and which decays like an exponential $\exp(-Ar+b)$ at large $r$) as accurately as possible in Fortran. The function values come from a data file (which I can easily interpolate through cubic inte...
I am interested in working with systems of PDEs in two spatial dimensions, as part of a mathematical modeling project. The systems of PDEs are coupled, and there is no convenient reduction to 1 spatial dimension (due to the particular constraints of the modeling problem). It is my understanding that the built-in MATLAB...
I need to numerically evaluate 2-D integrals of the form: $$ \mathcal{I}(\theta) = \int_{0}^{1} \int_0^1 \varphi_\theta(x,y) dx dy $$ where $\varphi_\theta$ is a family of smooth functions indexed by $\theta$; and I need to evaluate $\mathcal{I}(\theta)$ for a large number ($> 10^6$) of $\theta_i \in \Theta$, which are...
I need some kind of inequality constraint in my optimization problems (rude version of SVM for example or skeleton based mesh fitting). However hard constraints is not suitable for me because sometimes small constraint violations are allowed. I think about $(max(0, f(x)))^2$ as soft constraint function where $f(x)$ is ...
I am working with matrix operations in MATLAB, and I would have the following problem. I have matrix containing zero elements: a=zeros(100,100) and another matrix with significantly smaller dimension containing value 6: b=6*ones(3,3) I define some coordinates in matrix a: a(45,50). I also consider this point as cente...
I was reading about Interpolation error formula and Runge's phenomenon. My question is : Is there any function that gives no error at all? In other words the interpolation function $p$ would equal the actual function $f$. My answer is : If we choose a function $f(x) = 1$ then we will get no error. Is my answer correct...
I am trying to solve ordinary differential equations with initial conditions using Laplace transform. A simple test setup includes an exponential discharge of RC circuit and an integrator from coil and voltage source. While the result of the first example is as expected, the second one is not. What am I missing? M...
I have a quadratic eigenvalue problem of the form: $$(A_2 s^2 + A_1 s + A_0)\hat{v} = 0$$ where $s$ is the eigenvalue. The matrices $A_i$ contain derivatives up to order six, and I have six boundary conditions: $$ \hat{v}(0) = \hat{v}(1) = 0 \\ \hat{v}^{ii}(0) = \hat{v}^{ii}(1) = 0 \\ \hat{v}^{iv}(0) = \hat{v}^{iv}(1) ...
My FDM code simulates Backward Facing Step flow when I use conventional BCs such as defining velocity profile at inlet and fully developed condition at outlet. I have validated the results and it seems functioning correctly. However, when I want to impose a pressure-pressure condition (both static), it only converges w...
So I have a PDE that I use to describe how material flows through a volume(2D or 3D). $$\frac{\partial C}{\partial t} + \vec{u} \cdot \nabla C = (D' + D )\nabla^2C$$ Now using finite differences I get to the following: $$C^{i+1}_{j,k} =C^i_{j,k}+\Delta t \biggr[ (D+D')\biggr[\frac{C^i_{j+1,k}-2C^i_{j,k}+C^i_{j-1,k}}{(\...
I often see neural networks extended to complex-values. Those networks allow complex input, complex parameters, and complex output. My understanding is that the inner products and point nonlinearities are simply extended. I can see it's advantage for signals that are naturally complex (e.g., phase/amplitude decompositi...
Im currently implementing a Nelder-Mead algorithm in MATLAB that can deal with constraints. In detail, the constraints should be added to the objective function with a Lagrange Multiplier($\lambda$) and the new function is then minimized by Nelder-Mead. Looks something like this. $$L(x_1, \ldots,x_n,\lambda_1, \ldots,\...
I have the following code to execute: $X$ = [0;0;0;0]; $sw$ = 0; for k = 1 : n if (sw(k) == 0 && X(2,k)> 0.7 ) || (sw(k) == 1 && X(1,k) >0) sw(k+1) = 1; X(:,k+1) = X(:,k) +h*(A1*X(:,k) + B1*u); else sw(k+1) =0; X(:,k+1) = X(:,k) +h*(A*X(:,k) + B*u); end end This is fine. I ...
Is there now a package for rigorous numerical integration that uses interval arithmetic and has access to a well-developed library of special functions? By "well-developed", I mean something that, at the very least, includes the error function $\text{erf}$, the incomplete gamma function $\Gamma(s,x)$ and the like. In o...
I need to discretize the surface of prolate spheroid given by the equation $$\frac{x^2}{L^2} + \frac{y^2}{D^2} + \frac{z^2}{D^2} = \frac{1}{4}$$ The surface has to be divided to 500 equal panels to calculate the velocity potential on it. This means I will need to calculate the normal vector at each panel Can anyone sug...
I have the following setting: An irregularly-shaped domain, expressed as a mesh of points A Laplacian operator, together with boundary conditions I am looking for the eigenvalues of that operator, i.e. functions (expressed on the mesh, though clearly approximating an underlying continuous function) satisfying the bou...
In this JCP paper, the authors simultaneously enforce the discrete maximum principles and element-wise mass balance for advection-diffusion equations through convex optimization. The least-squares finite element method is used, so the problem becomes a mixed formulation with a flux variable $\boldsymbol{q}\in\mathbb{R}...
To get cutoff frequencies and eigenmode field distributions for a waveguide, one uses following equation: $$1/\epsilon ∇ \times 1/\mu ∇ \times E = \omega^2 E$$ With $ \omega^2 $ as eigenvalues. This works fine. But what if I would like to calculate the wave number $k_z$ ? If the waveguide is not changing in $z$ direct...
I am adapting a Java program from C++ and need a C++ function to perform the same task as the Java BOBYQAOptimizer() function. Can anyone recommend a C/C++ library with equivalent or similar functions and good documentation on how to use them? I've found one that might be suitable ( http://dlib.net/optimization.html ),...
Let $a,b,c,d\in\mathbb{R}^n$. Is it possible to compute $$\langle a*b,c*d\rangle$$ faster than 6 FFTs? I can do it with 6 FFTs by doing normal convolutions, 3 FFTs each. In my application I know $b, d$ upfront and can do preprocessing, so the cost is actually 4 FFTs. Can I do better than this? The reason I believe that...
My problem is to compute eigenvectors and eigenvalues of a lot of small (n < 30) symetric, positive definite matrices. So far I am using LAPACK's DSYEV. The priority is speed more than accuracy. Is there a faster algorithm (maybe not asymptotically, but in practice for small input)?
I would like to solve the linear system $\mathbf{A}\mathbf{x}=\mathbf{b}$, with $$\mathbf{A}=\mathbf{T}+\mathbf{C}$$ where $\mathbf{T}$ is a symmetric tridiagonal matrix and $\mathbf{C}$ is a corner-only matrix: $$\mathbf{C}=\begin{pmatrix} 0& 0 & \cdots & 0 & c\\ 0 & \ddots & & & 0\\ \vdots & & \ddots & & \vdots\\ 0 ...
Coldae is a solver writter by U Ascher and R Spiteri, located here http://www.cs.ubc.ca/~ascher/coldae.f . It can solve upto index-2 DAEs using collocation. I am new to Fortran, and having a hard time writing the driver, which is a collection of subroutines that define the function, jacobian, boundary conditions, gue...
I'm currently working with this kind of mesh (AMR) : To compute the gradient at the center of the cell P, I use the following formula : $$\nabla \phi_P = \frac{1}{\Omega} \sum_{faces} \phi_f \vec{S_f}$$ where $\Omega$ is the volume of the cell and $\phi_f$ is the approximation of the flux on the interface between cell...
I am looking for a website/database of computer hardware (CPUs/GPUs) benchmarked with common scientific tools, e.g. *GEMM (see comment below for more info on this tool). Currently, I am quite frustrated looking for this information, as it seems scattered across blogs, embedded in manufacturing marketing materials, or ...
I have a function of many variables (~200-2000) which I am optimizing with some success using L-BFGS. While the function is expensive to evaluate, the gradient can be computed with not much additional effort. I would like to know if there are any techniques which could allow this optimization to be sped up by parallel ...
I am trying to solve convection diffusion type equations by a modification: $$-\epsilon \Delta u+ b \nabla u+cu=f_1,$$ with the following boundary conditions: $$u=g~ on ~\Gamma_D,~~~~~~~~~~~~~~ \epsilon \frac{\partial u}{\partial n}=g_N ~~on ~~\Gamma_N.$$ The idea is to solve another equation: $$-\nu\Delta u+ \nabla u...
So I have a code that I use which solves a 1D variable coefficient diffusion problem in cartesian coordinates: $\frac{\partial u}{\partial t}=\frac{\partial}{\partial x}\left(D(x)\frac{\partial u}{\partial x}\right)$. It solves the equation implicitly using a backward euler discretization. it works fine, but I want to ...
I want to numerically solve for electric field of an object in an external electric field. The object has linear displacement field such that its permitivity ($\epsilon$) is constant. The object's shape is not important but I would prefer an ellipse. I do not know how should I impose curl and divergence equations into ...
I want to interpolate a periodic function on a non-equidistant grid and have implemented it the using the Lagrangian formula described in wikipedia. For an odd number of data points, this takes the form $$p(x) = \sum_{k=0}^{2K} y_k\,t_k(x)$$ with $$t_k(x) = \prod_{m=0,m\ne k}^{2K} \frac{\sin\frac12(x-x_m)}{\sin\frac12(...
Just studying some toy examples of $2\times 2$ and $3 \times 3$ matrices, complex number multiplication already gets a bit messy. From a numerical analysis point of view, if one were to try and build very large matrices to model physical behavior, is it much more desirable to build real matrices over complex matrices, ...
Could someone explain the link (if any) between the spectral methods (SM), as presented for example here and the so called spectral volume methods (SV) and spectral difference methods (SD) for CFD ? Are SV and SD the applications of SM to CFD ? If not, is there an application to CFD of SM (that would then have no link...
I wrote a code which solves the 2D Poisson equation with homogeneous Dirichlet BC everywhere and a source term of -1. I am using the classical Jacobi iteration method. The grid is $N_x \, \mathrm{x} \, N_y$, and all the arrays are 0 based. The code yields good results with a 5 points stencil (2$^{\mathrm{nd}}$ order fi...
What would be the rigorous mathematical expression of the fact that a conservation law discretized with a Finite Element method with Galerkin discretization does not result in a conservative scheme ?
Our current lab uses SNOPT as an optimizer for aerodynamic shape optimization. I am currently working on building an approximate Hessian for the sake of improving the convergence speed and limits. Unfortunately, SNOPT only allows me to define an initial Hessian. Is there a FORTRAN package that would allow me to input t...
Consider the following scenario: I want to perform a large Monte Carlo simulation across a compute cluster with several nodes. To avoid excessive transmission of data, I am going to generate random data for my simulation on the individual nodes. Using Python, I would like to do this using numpy.random functions. I need...
i'm solving sparse linear equations within scipy 0.18 which internally resorts to SuperLU (after umfpack got removed due to license-issues). Current, i'm doing a complete re-factorization in each iteration of my algorithm, but now i want to re-use the permutation-ordering (at least the column-permutation; but maybe eve...
I have a system of two bodies, $b^i$ and $b^j$, each in position $\vec{p}^i = (x^i, y^i)$ and $\vec{p}^j = (x^j, y^j)$. The two are connected via spring and I'd like to know, given their states at time $t_n$, their states at time $t_{n+1}$ ($\vec{p}^i_{n+1}$ and $\vec{p}^j_{n+1}$). I have decided to use the backward E...
I am looking for the subject. The size of matrices will be around 1000x2000 elements with linear amount of ones (say, 6000 ones in the whole matrix). The operations I will use the most: iterating over elements of particular column; iterating over elements of particular row; getting submatrix by columns; solving undete...
In a previous question, link, I asked about how I could most effectively do a Fourier Transform of a radial function given at certain values and which we knew the asymptotical behaviour of. The Fourier transform reading $$\frac{4\pi}{q}\int^{\infty}_0 dr\, r \sin(qr) f(r).$$ I tried several ways and ended up choosing F...
I am trying to use CSDP and am struggling with this. Consider for example the SDP problem proposed by prof. Borchers here. Namely: $$\max_{A,z} \sum_{i} z_{i}\quad\text{subject to}\quad\mbox{tr}(P_{i}A) \geq z_{i},\quad i=1, 2, \ldots, n.\quad A \succeq 0.$$ I am wondering how one represents it in the standard CSDP fo...
I have been writing a control system toolbox from scratch and purely in Python3 (shameless plug : harold ). From my past research, I have always complaints about the Riccati solver care.m for reasons that are technical/irrelevant. Hence, I've been writing my own set of routines. One thing I can't find a way around is ...
Let $f(x,y)$ and $g(x,y)$ be two $\mathbb{R}^2\rightarrow\mathbb{R}$ functions, both strictly increasing in both arguments. Assume that they are well-behaved functions (continuous, differentiable, etc.) Given these properties, I want to find a root to the following system of equations: $$f(x,y)=f_0$$ $$g(x,y)=g_0$$ ass...
I am going to discuss my reasons for wanting this first, as this may in fact not be what I am looking for. My reason for asking this that I have finished writing a piece of code that solves, $-\nabla \cdot(a \nabla u) = f$ where $a$ is discontinuous, this is the result of the code we can see oscillations about the lin...
I do computational work as a PhD student and I try to find a correct way to separate code (solver) from the computational experiments based on this solver. Basically, each project that I do revolves around one particular solver (MATLAB or Python code), and for each project there is a set of experiments that should be d...
What is the difference between an explicit and implicit preconditioner?
Suppose we have a $f(x)$ to be minimized (we only know that $f(x)$ is three-differentiable), and a feasible, convex set of $S$ such that all $x$ belong to $S$. Using line search method, how we can "mathematically" prove that a descending direction pointing from previous $x$ towards a new $x$ within the $S$ exists? And,...
I'd like to take an photograph, subdivide it into a tesselation, either of squares, or (ideally), hexagons, and then find the centre of gravity (or, if you prefer, centre of mass) of each cell of the tesselation. The output, for any image, would be a matrix of points. For the attached diagram, something like this (in p...
The set of constructable numbers is commonly defined in one of two ways: the set of finite numbers reachable from the rational numbers through a finite sequence of addition/subtraction, multiplication/division, and square root operations. They are also defined as an infinite chain of "field extensions" on the rational...
Consider a real symmetric matrix of dimension N~10^5 and rank m~2000. What is the most efficient algorithm for determining the top m eigenvectors? If the answer isn't obvious, are there existing routines for this in languages like MATLAB or Python?
(a) Consider the following differential Equation $$Y'(t)=\frac{1}{1+t^{2}}-2[Y(t)]^2$$ $$Y(0)=0$$ The exact solution is $$Y(t)=\frac{t}{1+t^2}$$ Using the Euler method to solve the following differential equation with the help of matlab (code given below), run the program for $t=10$ and $h=0.1$ compute the error.Then...
I have a data file with some points equally spaced. These represent some function. I have to calculate the Fourier transform of this set of points. The thing is, I'm tempted to take a cubic spline of these data points to calculate the Fourier transform by FFT (actually I'm more than tempted, since I have done it alread...
Consider random variables $X$ and $Y$, their distributions are given. $Z = f_a(X, Y)$ where $f(\cdot, \cdot)$ is a deterministic, not random function $f_a: \mathbb{R}^2 \to \mathbb{R}$ depending on a deterministic real parameter $a$. For example, let $f_a(X,Y)=\sin X + e^{aXY}$. I've read a lot about Bayesian modellin...
(Note: Corrected code is posted below the original code.) For an exercise in optimization, I am interested in coding a simple example from scratch: a Tikhonov denoising routine using gradient descent, that matches exactly in output the LSQ-based Tikhonov denoising result. For regularisation of a noised signal $b$ to re...
I'm interested in testing some algorithms on the heat equation, and I'd like to assess their accuracy. When evolving a Hamiltonian system, one has the energy to check the validity/correctness of the algorithm, which turns out to be (arguably) the most important quantity to check. Is there a similar quantity for the hea...
I am doing a little project on solving the heat equation using finite-volume method on a solid cube, I converted the polyhedral mesh of the cube to an OpenFOAM mesh. I have a Python code where I parse the points, faces, owner, neighbour and boundary files of the OF case mesh, I've managed to create a hash list (let's c...
I have crude idea that numerical diffusion arises while using upwind scheme and causes solution to deviate from its original one. But I am unable to understand how numerical diffusion phenomenon is (directly) related to advection phenomenon?
I am trying to implement Adaptive Mesh Refinement. I am not a Mathematics/Computational Science person so I will try to write the algorithm in a simpler way. I will be grateful if experts can comment on the correctness of steps: Aim: To solve Laplace Equation with Dirichlet boundary conditions i.e. $\nabla^{2} u = 0 $...
I need to compare two computers and decide which one I want. My goal is to run faster simulations. The current run time is 3.5 hours and I would like to reduce that as much as possible. The code I am running has the capability of running on multiple processors (parallel). Which specifications of the pc should I pay at...
I have a question regarding the treatment of Robin boundary conditions in a multigrid solver. I am solving the Poisson equation in $\Omega=(0,1)^2$ with Robin boundary conditions on the boundary, $$- \Delta u = f \text{ in } \Omega$$ and $$\frac{\partial u}{\partial n} - au= g \text{ on } \partial \Omega.$$ I use a fin...
In my optimization problem, the hessian has a structure such that it can be written as the sum of two matrices. Populating the first of the matrices is efficient. Populating the second one is computationally very heavy and practically makes methods like truncated Newton useless. However, the second matrix is block diag...
I simply want to know whether the Dormand-Prince Numerical Method or the Cash-Karp Numerical Method is more accurate.
I have two graphs with nearly n~100000 nodes each. In both graphs, each node is connected to exactly 3 other nodes so the adjacency matrix is symmetric and very sparse. The hard part is I need all eigenvalues of the adjacency matrix but not eigenvectors. To be accurate, this is going to be once in my lifetime (as far a...
I know that, from numerical point of view, computing Ax = b B=inv(A), x= B*b are completely different things, and we should factor the matrix using TRF routine then solve with TRS/TRI routine, or in a combined gesv call. Anyway is there an efficiently routine to specifically deal with C = A* inv(B) BTW, I know some ...
I would like to program the following difference equation. Find numbers $v_{i,j}$ so that for $1\leq i\leq 4$, $0\leq j\leq 5$: $$ v_{i,j+1} = (0.1)v_{i+1,j} + (0.8)v_{i,j} + (0.1)v_{i-1,j} $$ In addition it satisfies the conditions, for $0\leq j\leq 5$: $$ v_{0,j} = (0.2)j \text{ and }v_{5,j} = 25 + (0.2)j$$ And fi...
Dekker's method and in its evolution Brent's method have as design goal to combine the certainty of a root, certified by function values of opposite sign in an increasingly smaller interval, of bracketing methods like bisection and regula falsi with the fast convergence of the secant (and higher degree of (reverse) int...
I have made a 2d slice cut of a 3 dimension figure. When I select "mesh" to display the mesh on the slice, tecplot seems to connect the vertices in a strange way (it seems like two 2d meshes are superimposed). I found a similar question in the forum of tecplot but they did not answer it. Edit: Here is a capture of the ...
I am trying to determine quality of my mesh elements using the Jacobian determinant as the measure. My algorithm takes vertices of nodes in triangular mesh and moves them around so as to form distorted triangles. Let us assume my vertex P(x,y,z) moves to P'(x',y',z') How to calculate the resulting change in mesh quali...