instruction
stringlengths
43
28.1k
I am trying to calculate the best set of cuts for some wood cutting to reduce the waste. So: Given a set of numbers, the goal is to find the best matches below a limit (size of wood beam). Example of the set of numbers: const input = [ 4, 13.5, 17.5, 18.5, 20, 26, 43.5, 44.5, 45, 46, 54, 54.5, 55, 60, 61, 62, 70.5...
I'm trying to calculate the 2 perpendicular versors (unit vectors), $\vec{n_1}$ and $\vec{n_2}$, that define a plane whose normal versor (unit vector) is $\vec{n_n}$. For example, assuming that the versor of the normal is $\vec{n_n} = <1, 0, 0>$, the two perpendicular versors that define the plane whose normal i...
I've been working on modelling the NS equations in order to simulate shock waves. The equations are set up on the form: \begin{equation} \frac{\partial U}{\partial t} + \frac{\partial F(U)}{\partial x} = S(U) \end{equation} where \begin{equation} U = \begin{bmatrix}\rho\\ \rho v\\E\end{bmatrix}, F(U) = \begin{bmatrix}...
I'm working on a project for which I have inherited some FEM code. This implemented FEM calculates, given some force field, displacements on a discretised square using square elements and assumes a homogeneous isotropic and linear material. I want to do away with the assumption homogeneity. I would like to assume a spa...
Overview and Prior Research I am looking for a way store a (in principle arbitrarily) large "3D-table" for interpolation/ lookup in combination with python. I have considered CSV files, but, as far as I know, I will run into file size issues starting at 2GB Pytables: as I understood it, it is close to a proper databas...
I'm trying to fit a simple logistic growth model to dummy data using Python's Scipy package. The code is shown below, along with the output that I get. The correct output is shown below it. I'm not quite sure what's going wrong here. import scipy.optimize as optim from scipy.integrate import odeint import numpy as np i...
I work in the medical field. Sometime we receives MR images that have been acquired along the same direction, however when looking up the direction cosine matrix, the values are slightly different (up to a certain precision). The scanner only stores the first 6 values of the matrix, the last 3 values are computed using...
Let $\mathbf{P}$ be a permutation matrix (i.e. a matrix that is all zeros except for a single one in each row). Is there an efficient algorithm for computing the determinant of such a matrix?
I have the two following algorithms for GMRES(m) and left preconditioned GMRES. GMRES(m) Left preconditioning I would like to know if anyone could explain why steps 10 through 12 are not used in the left preconditioned GMRES. Are they lost, or is it implicit that these need to happen? If not, am I correct to assume t...
I hope this is the right place for my question. I am a university student who designed a pea-pouring machine.Now I‘m really interested in simulating the behavior of those peas. Basically, they are inside a tank that is closed by a slider. When the slider opens up, the peas fall out due to gravity. I have a license for...
import numpy as np import matplotlib.pyplot as plt Fs = 200 # sampling rate Ts = 1.0/Fs # sampling interval t = np.arange(0, 1, Ts) # time vector f_f = np.arange(30, 80, 0.001) a = np.arange(0, len(f_f), 1) y2 = 0.0 for i in range(len(f_f)): y2 = y2 + n...
Is there a formula which enables the computation the tensor of curvature knowing the following at each vertex and cell of a triangulated mesh: Normal vector Two arbitrary vectors in the tangent space Mean and Gauss curvature I am trying to script it using vtk/python. The final goal is to compute the principal directi...
I’m trying to to obtain the values of the tortoise coordinates (Eddington-Finkelstein Coordinates) integrating the expression: $\frac{dr^*}{dr} = (1 - rS/r)^{-1}$ using the GNU Scientific Library (GSL). I know that the analytical expression is $r* = r + rs·ln(r/rS - 1)$ so I can compare both results: analytical and int...
Is there a library of some programming language (MatLab, C, Python, R, etc.) that includes a function for efficient calculation of convex-convex quadratic fractional programming problems of the form $$ \begin{align*} \sup& &\frac{x^TQx}{x^TPx}\\ \text{s.t.}& &A^Tx \leq b\\ &&x\geq 0 \end{align*} $$ where $Q\in\mathbb{R...
Considering page 10 of Jos Stam's GDC tutorial on stable fluids, the function project() first obtains the divergence of the velocity field: ¹ div[IX(i,j)] = -0.5*(u[IX(i+1,j)]-u[IX(i-1,j)]+ v[IX(i,j+1)]-v[IX(i,j-1)]) / N; p[IX(i,j)] = 0; then subtracts a curl-free part from the original velocity f...
One more question about Jos Stam's GDC tutorial on stable fluids: in the advection step on page 8, the timestep for each dimension is implemented as dt * N, where N is the height or width of the grid. This corresponds to a position update: $x_{prev} = x - \frac{\Delta t}{h} \cdot v_x$ where $h = 1/N$. But why is $h$ in...
I want to solve the thermal expansion of solid by using FEM approach. When I developed the model based on the the principle the minimum potential energy, the solutions for thermal expansion are not correct, although the results of static bending problems under external mechanical loads shows good results. The basic equ...
I am trying to understand how cell to cell communication is studied using a discrete modelling framework. Could someone please suggest suitable references or libraries which already have implementations of this? I have come across continuum-based approaches which treat tissue mass as a homogeneous medium but I am looki...
I'm trying to use solve_ivp from scipy in Python to solve an IVP. I specified the tspan argument of solve_ivp to be (0,10), as shown below. However, for some reason, the solutions I get always stop around t=2.5. from scipy.integrate import solve_ivp import numpy as np import matplotlib.pyplot as plt import scipy.optimi...
I would like to determine the stability of a system of periodic delay differential equations (a seasonal host-parasite model). I've tried to implement the method described in Lemma 2.5 in this paper: Liang, X., Zhang, L. & Zhao, XQ. Basic Reproduction Ratios for Periodic Abstract Functional Differential Equations (wit...
I'm looking to compute the value of the following integral, for small values of $|a|$. $$u_n(a,b)=\frac{1}{2}\int_{-1}^1 x^ne^{ax^2+bx}\mathrm{d}x$$ In this equation, $a,b \in \mathbb{R}$ and $n \in \mathbb{N}$. It's easy to show that: $u_0(0, 0) = 1$ $\frac{\partial}{\partial b} u_n = u_{n+1}$ $\frac{\partial^2}{\par...
In this post, they mentioned that C++ and FORTRAN are low–level programming languages. However, In other references, they consderd these language as a high-level programming languages. Which one is correct?
I have been doing a lot of reading on the development of finite element methods and their analysis using, e.g., functional analysis. I am clear on the formulation of the weak form of a PDE and properties defined on the bilinear form. However, for my research I am pursuing the solution of nonlinear PDEs using Discontinu...
Strong Scaling and Amdahl's Law Strong scaling is a measure of how, for a fixed overall problem size, the time to solution decreases as more processors are added to a system. An application that exhibits linear strong scaling has a speedup equal to the number of processors used. Strong scaling is usually equated with A...
I am trying to figure out the exact formula for a three convoluted exponential gaussian probability function from the software Igor Pro, from my research. Unfortunately all I the closest equation from the software is the coding for it, which is below: w[0]+(w[3]/w[4])*ExpGauss(t-w[2],w[4],w[1])+(w[5]/w[6])*ExpGauss(t-w...
I want to compute the eigenvalues and eigenstates of a quantum well with different effective masses of electron in the barrier and in the quantum well. As can be seen [1]: https://github.com/mholtrop/QMPython/blob/master/Finite%20Well%20Bound%20States.ipynb [1], the mass of the electron is constant, therefore the Hamil...
Suppose you have a trigonometric polynomial of the form \begin{equation*} x(t) = \sum_{k = 0}^N a_k \cos(2 \pi k f_0 t). \end{equation*} Using Clenshaw algorithm, one can evaluate this polynomial in $O(N)$, just as an ordinary polynomial via Horner's rule. Now: Is it possible to evaluate $x(t)$ in less than $O(N)$ in ...
I'm trying to write a program that can simulate a rainbow. So far I've got figured out how to determine the change in the refractive index depending on the wavelength, the angular deviation of the scattered ray depending on the number of reflexions inside the water droplet, and so on. The only thing I'm still uncertain...
If I have 3 lists: points, faces and cells that represents a mesh, where: points is a list of x,y,z coordinates, for example [-0.05, -0.05, 0. ], [-0.05, 0.05, 0. ], [ 0.05, -0.05, 0. ], ... faces is a list of list of points, where each row is a list of point indices that represents a face [ 1, 4, 8, ...
I would like to implement a givenRotation algorithm without having matrix-matrix multiplication. Matrix-vector is fine or just for looping. I am to decompose a rectangular (m+1)xm Hessenberg matrix. I found an algorithm here but it appears to be for square matrices. With matrix-matrix multiplication I have made the fol...
Wave equation. Mixed BC. Applied Neuman boundary condition ($\frac{\partial u}{\partial x}\big|_N=0$) to the RHS of the domain You may observe the sharp edge in the middle of the string in the image attached. I do understand it bouncing at Dirichlet BC, but for some reason, it bounces off the Neuman Boundary on the rig...
I am looking for a manufactured (or analytical if it exists) solution to the 2d boundary-value problem $$\frac{\partial u}{\partial t} = \mathbf{a} \cdot \nabla u + D \nabla^2 u \quad \quad \mbox{in } \Omega $$ $$ u \ \mathbf{a} \cdot \mathbf{\hat{n}} + D \ \nabla u \cdot \mathbf{\hat{n}} = 0 \quad \quad \mbox{on } \p...
In Galerkin methods, we seldom can measure the accuracy of an approximation by tracking the value of the residual. For example, take the wave equation: $ u_{tt} = u_{xx}$, $(x,t) \in (0,L) \times (0,T)$ with approximation $u(x,t) \approx u_N(x,t) = \sum_{i=1}^N\phi_i(x)q_i(t)$ The residual for this approximation is def...
I'm continuing the research of a former Ph.D. student in my group requiring the solution of a system of ODEs. On a technical note, they wrote: The system of Boltzmann equations behaves numerically stiff. This means that it is advisable to use an implicit method for its numerical solution to achieve acceptable step siz...
I'm trying to understand the notion of relative error for vectors in $\mathbb{R}^n$, but it's not "clicking" somehow. $$\operatorname{\varepsilon-rel}(x_\text{approx}, x) = \frac{||x_\text{approx} - x ||}{||x||}$$ The intuition I have for the relative error between two positive real numbers is that it's the approximati...
I'm trying to solve $-u''=\cos(2 \pi x)$ with boundary conditions $u'(0)=u'(1)=0$ and the constraint $\int_{0}^1 u = 0$ I have to use linear finite elements, so let's assume that I have $M$ degrees of freedom. Since the contributions from the Neumann data on the r.h.s. vanish, the weak formulation is to find a $u_h \i...
In order to undergird a theoretical model concerning many body physics, I want to have exponentially large eigenvalue spectra from the random matrix GOE ensemble. its properties are mainly (i) a semicircle distribution, (ii) a level repulsion between the eigenvalues. These are met in some physical systems, so it is nat...
I want to build an application for Material Point Method (and probably other meshfree methods too) in Julia and I am looking for library for direct and iterative solvers that can help me with it. One of the most common library used for such applications is PETSc and I do know that it has bindings to Julia. But I am als...
I have an ODE for an unknown $x(t):[0,\infty)\to\mathbb R^n$ of the following form: $$ x_i'(t)=a_i^\top x(t) + x(t)^\top Q_i x(t), $$ for $i\in\{1,\ldots,n\}$. Here, the vectors $a_i\in\mathbb R^n$ form the columns of an $n\times n$ negative semidefinite matrix $A\in\mathbb R^{n\times n}$, and $Q_i\succeq0$ for all $i...
I'm calculating the entropy production of a shockwave by utilizing the equations: \begin{equation} \sigma = J'_q\frac{\partial}{\partial x}\left(\frac{1}{T}\right) +\frac{1}{T}\frac{4\eta}{3}\left(\frac{\partial v}{\partial x}\right)^2 \end{equation} and \begin{equation} \sigma = \frac{\partial \rho_s}{\partial t} +\fr...
I would like to generate the most unique string (20 long, primer) of a defined length that does not occur in a much larger string (6.4 billion long, human genome). Of course, there could be many unique strings, but I want to avoid string with any mismatches/deletions/insertions that could occur in the larger stringer...
I am reading some optimization methods and I am facing some issues with two terms "asymptotic and non-asymptotic convergence". What is the difference between them?
What is the best method to do a Monte Carlo Integration of a multidimensional integral where the integration limits depend upon other variables? I am interested in getting a numerical value of a 5 dimensional integral, the limits look like this: $$\int_{0}^{a^2} dS_{12} \int\limits_{S_{12}}^{a^2} dS_{123} \int\limits_0...
In my computer vision course, we are working on extracting a 3D surface from a chain of 2D images taken under several conditions. This procedure is known as Photometric stereo. Prior to extracting the surface $f(x,y)$ numerically, we have to perform what's called a test of integrability : $$ \frac{\partial^{2}f}{\parti...
My question is specific to algorithms and models of computation. I would like to write code to evaluate the following expression quickly and accurately: $$\log \left( \sum_{i=1}^{\infty}{I_{\nu+i}(2\lambda)} \right)$$ Where $I_\nu(x)$ is the modified bessel function of the first kind. I have limited experience with num...
I have a staircase/step function $n(E)$. I know the points $\{E_i\}$ at which each "step" occurs and all steps are of constant height 1. I need to fit a line $a + bE$ to this function and find the least-squares deviation. In particular, I have to calculate the quantity $$ \Delta = \min_{a,b} \int_{E_i}^{E_f} [n(E) - a ...
I'm newbie here. I'm wondering if it's possible to generate $(X_i, Y_i, Z_i)$ from my own distribution function? I know that there is a way to make own class for 1D variable. But what about 3D case?
What is typically the best way to multi thread the assembly loop in a finite element code? Does anyone have experience with implementing this, that they can share? I can think of a couple of ways of doing it: Divide the mesh into different cell sets, where the elements in each set does not share dofs, such that the th...
I'm interested in how digital beamforming works and I can not find an answer for a lot of time. I googled, asked teammates, and couldn't get it. Let me describe my question. From my understanding, the beam means the area in the space where waves from a number of antenna elements are in superposition which means, in tur...
I am aiming to get a numerical value for a five-dimensional integral using Monte Carlo Integration. I am getting good results using the Mean Value Method, but I would like to try to use Importance Sampling to get even better results. My main source gives me an example of how to do this method using a one-dimensional in...
Consider the Laplace problem: \begin{align} -\nabla^2 u = f \qquad \text{in } \Omega \\ u = 0 \qquad \text{on } \Gamma \end{align} The weak problem is find $u_h \in V \subset H^1$ such that $\forall v_h \in K \subset H^1_0$, $u_h$ satisfies: \begin{equation} \int_\Omega \nabla v_h \cdot \nabla u_h \, d\Omega = \in...
I am trying to evaluate and analyse a NURBS curve to generate a mechanism. I understand that the general form of a NURBS curve is commonly written as a parametric equation in the form of $f_{par}(t)$. Now, the criteria to generate the above mechanism from a curve are well-established. However, they are based on the imp...
Consider the problem $-\Delta u = f$ in $\Omega$, with $u=0$ on $\partial \Omega$. Suppose that $\Omega$ is a polygon and that we approximate the solutions to the previous problem using Lagrange finite elements on a triangular mesh. When solving such a finite element problem there are multiple sources of error: The di...
Edited Given a computer model $F:\mathbb{R}^3 \to \mathbb{R}$, with inputs $x, w$ and $z$, and output $y=F(x,w,z)$, where for any input, we are able to evaluate the output, my goal is to tune the inputs to achieve a certain state change (change in output). More precisely: Goal: Given an input $x_0, w_0, z_0$ and an out...
The first guess is using the forward Euler approach. The first jacobian is using finite differences. Then NR method is used to solve for the next iteration and Broyden's method is used to update the jacobian until tolerance is met. The figure shows the results that I got compared with correct results. What improvements...
I have written block version of GMRES by referring [1] and MATLAB implementation of gmres. I need to write it for complex matrices. My block implementation when run on single RHS is giving correct answer but when run with block RHS is converging but LHS is not matching. Can anyone please help me to debug or point in di...
This question is neither scientific nor technical but more career related. I am at a junction in my professional life where I need to make a decision with regard to the future of my career. At the moment I am an R&D manager and my job is very management-oriented (supervising, problem identification) so I asked my own m...
I often hear that cell centred finite volume is second order accurate but at the same time I come across notions of high order FVM flux schemes. Is there a distinction between the two? If I were to use something like a first order upwind referencing vs something like a third order MUSCL would that make my entire FVM sc...
I want to solve a 2-dimensional particle in box problem with two electrons in the quantum well.I would like to take into account spin of electrons and Coulomb interactions to compute singlet and triplet eigenstates. My question is it possible to solve this problem using finite difference method, if yes then please guid...
This is the same question as this one, except for Python instead of Mathematica. Basically, the MATLAB software PPLANE is a staple in ODE courses. Is there a Python equivalent? I don't know much about the software since my class just started using it, but I basically need it for plotting nullclines and trajectories, as...
I have a linear* problem which arises from an integro-differential system, and writes: $$ (\mathbf{I}+\lambda \mathbf{A})x = b $$ where $\mathbf{A}$ is a real full matrix, size $n\times n$, but is not symmetric and has some zero eigenvalues. I know what these eigenvalues correspond to. When $\lambda$ increases (but is ...
I'm implementing a solver of Finite Element Method, and to solve the linear system of equations I'm using gmres from MKL of Intel. Exists the option with and without a preconditioning. In what case it is not necessary the preconditioning? The matrix is sparse and not symmetric.
I do a lot of 2D discrete FFT in python using np.fft.fftshift(np.fft.fft2(y)), then throw away 90% or more of the array, keeping only the central low-frequency area. I understand that there's .rfft2() for cases where the input is real. I'm wondering if there are significantly faster ways than numpy's fft to do this, es...
This is a continuation of my previous question. I am trying to effectively compute a bound for the roundoff errors in some FEM computation (2d polygons, triangular meshes). Below I will write some of my computations which lead to a quantifiable bound (if I'm not mistaken), but the error is quite large for small mesh si...
I am following this example https://scikit-fuzzy.github.io/scikit-fuzzy/auto_examples/plot_tipping_problem_newapi.html from documentation of scikit-fuzzy library,but I have a question in the figure why the triangle of both low and high is colored when the result is for example is 14.5%? Is that righ? the low and high i...
Engineering FEM When I studied engineering, I learned the traditional approach for finite elements for elasticity. The point was to solve the PDE $-div(\sigma)=f$ as: Multiply your PDE with a test function, integrate, find the weak form: $\int \sigma(u): \epsilon(v) - \int v f = 0$ Interpolate $u=\sum_i u_i N_i$, set ...
To compute the $N$-point DFT $$ X[k] = \sum_{n=0}^{N-1} x[n] W_N^{kn} $$ where $N = N_1 N_2$, we can write the indices as $n = N_2 n_1 + n_2$ and $k = k_1 + N_1 k_2$, (effectively packing the data into a 2D array) and then $$ X[k_1 + N_1 k_2] = \sum_{n_1=0}^{N_1 - 1} \sum_{n_2 = 0}^{N_2 - 1} x[N_2 n_1 + n_2] W_N^{kn} $...
I'm following this low-pass filter example in the text "Image Operators: Image Processing in Python 1st Edition" by Jason M. Kinser, but can't seem to duplicate their results. The text's code: import imageio import scipy.fftpack as ft import mgcreate as mgc amg = imageio.imread('data/reschartsmall.png', as_gray=True) ...
I have been using Pointwise for grid generation and found the quality of smoothed grids to be stunning. I am not aware of any free/open source alteranative that offers the same capabilities for structured grids (I am not interested in unstructured meshes). I am aware of Meshlab but never used it (it doesn't even have u...
Consider the following differential equation \begin{align} \frac{\partial f(u)}{\partial x} &= g(x), \ \ x\in [x_{L},x_{R}] \label{Eq2.2} \\ u(x_{L}) &= g_{1} \end{align} where $f(u)$ is a nonlinear function. Let $\{x_{i}\}_{i=1}^{N+1}$ be a partition of $\Omega$ with $N$ elements such that \begin{equation} x_{L} = x_...
I am currently solving the harmonic equation using a P1 FEM discretisation. The resulting matrix $A$ is SPD and fairly sparse so I use a preconditioned conjugate gradients (CG) solver to find a solution. I have tried to accelerate the convergence both through a Jacobi preconditioner and an incomplete Cholesky precondit...
I have always taken for granted circuit simulators and I didn't spend time understanding now. I wish to understand better now. Normally when you forward simulate ODE systems there is a single dynamic equation which you forward integrate(ex, simplest way is Eulers method). What I am wondering about is in the case of cir...
I did this simple analysis on RFEM, of a rigid-supported beam loaded with a point moment. Before analysis, I didn't assign any kind of mesh manually. When I turn on the FE Mesh visible on Project Navigator, RFEM highlights the two end nodes of the member. I assume that if no mesh is defined manually, RFEM uses the end...
I am looking for some LBB-stable velocity-pressure combinations for incompressible Navier-Stokes where the pressure space is element-wise discontinuous, preferably with a linear variation elementwise. I can think of two options: (i) Discontinuous Galerkin and (ii) Crouziex-Raviart element, but I am not sure which one w...
For the past couple of days, I have been thinking a lot and searching online for an algorithm capable of estimating the number of Self-Avoiding Walks (SAW) of length $n$ in $\mathbb{Z}^2$. There is a very simple way to do so by simply generating all random walks of length $n$ and then checking whether each one is self-...
Suppose I have a triangular element with vertices ${\vec{r_1},...,\vec{r_3}}$ and a function $f(\vec{r})$. I want to calculate the fourier integral over this triangle such that: $$F(k_x,k_y)=\int \int f(x)e^{-j2\pi(k_xx+k_yy)}dxdy \, .$$ Normally, for any integral inside such a triangle element, I would do the master e...
I want to simulate the hyperbolic partial differential equation $$W_{tt} + V W_{tx} + k_E V W_x + k W_t = 0,$$ but I am having trouble finding a discrete analog of this equation which is numerically stable. I introduced central differences in both space and time. Time and space are discretized via $t_n = n \Delta t$ an...
Any literature that extensively discusses the ability to strongly inter-/extrapolate computationally on little empirical data? This topic has fascinated me, but I find that it seems a bit novel. Particulary, instead of gathering large amounts of empirical observations, is there something that could guide interpolating ...
I am trying to import data generated external to Fluent using CGNS (CFD General Notation System) files. The data consists of velocity vectors, temperature, pressure, density, and species mass fractions. The procedure I have followed : Export an empty mesh (variables were initialized with junk values) form fluent in th...
To investigate a counter-current flow heat exchanger while considering temperature dependent physical properties (such as specific heat $c_\textrm{p,i}$, heat conductivity $\lambda_\textrm{i}$, viscosity $\eta_\textrm{i}$ ...) I am trying to solve a system of equations by finding its roots using scipy.optimize.fsolve()...
Suppose for a grid-based calculation a grid is used such that the grid Jacobian is discontinuous. For example, in 1D, for a domain $x \in$ [0,1], one half of the domain is covered uniformly by twice as many grid points as the other side of the domain (and this always remains so as the number of grid points is increased...
I am trying to simulate light propagation on python using FFT following the Fresnel diffraction equation given on Wikipedia: The problem with this is that the output matrix from the DFT would be given in coordinates $(p,q)$, which would inversely scale with my variable propagation distance $z$. To use the new $(x,y)$ ...
I’ve been facing a problem of solving linear systems Ax=b arising from discretized PDEs (Stokes equations in particular). Nively, it seems that solving Ax=b should not take much more time than simply multiplying matrix A by some vector v as long as A is sparse. More specifically, when discretizing a linear PDE, one end...
I am new to the field of magnetostatics. I wish to write a 2D finite element code for obtaining the magnetic field inside a solenoid coil. I have started with a 2D code and have followed the method as described in the book by J.Bastos and N Sadowski. I managed to get the solutions and verified it from FEMM (a open sour...
Is there a method for finding the number of eigenvectors with a given eigenvalue? I do not need the eigenvectors themselves, and to find the eigenvectors seems quite tough, given the comments on the answer to the question Compute eigenvectors of a matrix with known eigenvalue spectrum. I have many randomly-generated ...
I am a newbie in CFD and single/multiphase flow and transport in general. As part of my quest to learn, I am trying to model solute transport around a solid object in the center of a 2D domain. The governing equation is the advection-diffusion equation, given as: where C is the concentration, v is the flow velocity, D...
I am trying to derivative the equations from [1] for a compressible Volume-of-fluids formulation but I am stuck in one of the last steps and would like to request some help to solve it. The governing equations are: Mass conservation: $$ \frac{\partial (\alpha_k \rho_k)}{\partial t} + \nabla \cdot (\alpha_k \rho_k \vec...
I am facing an issue with convergence of a contact problem consisting of three successive bars, as presented below. A force is applied on the right hand of the first bar so there is contact between both the first and the second bar and the second and the third bar. Another bar is linked to the second bar so there is n...
In Numerical Linear Algebra by Trefethen & Bau, it is claimed that subtraction is backward stable. Here is the proof: Let $f(x, y) = x-y$ and let $\tilde f(x,y)$ be the answer you get when doing $x-y$ on a computer. We have $$\begin{align*}\tilde f(x, y) &= (x(1+\epsilon_1) - y(1 + \epsilon_2))(1 + \epsilon_3)\\ \end{a...
I would like to insert a series of vertical lines to divide up a line chart. The figure below shows the chart so far, but instead of the orange diamonds I want vertical lines that go from top to bottom of the figure. What's the easiest/best way to do this? Context: this is a trust-region optimization problem showing th...
Suppose that I have a very long and tedious set of differential equations. After discretization, I can get a mapping $f:\mathbb{R}^N \to \mathbb{R}^N$ such that solutions $\phi =(\phi_0,...,\phi_{N-1})$ to the discretized diffferential equations are exactly the zeros of $f$, i.e., $f(\phi)=0$. Now say I want to find so...
I have a system of equations that have the following structure. Let $x\in\mathbb{R}^m$ and let $x_k$ be the $k$-th element of $x$. Let $H_k\in\mathbb{R}^{m\times m}$ for $k=1,\ldots, m$. I need to find the $x$ satisfying, \begin{align} x_k = x^\top H_k x \end{align} for $k=1,\ldots,m$. I know that I can solve this syst...
I am trying to solve problem $15.1$ from Numerical Linear Algebra by Trefethen and Bau, which reads Determine whether the algorithm is backward stable, stable but not backward stable, or unstable. Data: None. Solution: $e$, computed by summing $\sum_{j = 0}^{\infty} \frac {1}{j!}$ from left to right, and stopping whe...
I apologize in advance if the question has been posted before or if it sounds a bit naive. I am writing my own code in MATLAB for a staggered finite element solver for fluid-structure interaction problems with small displacements. So far, I have benchmarked the fluid and solid solvers separately and both are working fi...
I am learning C++ scientific computing with "Parallel scientific computing in C++ and MPI A Seamless Approach to Parallel Algorithms and their Implementation" since it kept coming up a lot in questions, for example. The problem is that it is really outdated and when compiling I get lots of errors. Up until now, I've be...
I am trying to solve this equation for $v_{Sl}$ in the range $[0.001,1]$ to obtain the values of $\delta_l$. I have tried Fsolve with python, which gives results where the values of $v_{Sl}$ are between $[0.001,0.1]$ when I put an initial guess of $\delta_l$ that is close to the solution. But, when I vary the initial ...
Could we train an AI to find only Mersenne primes and beat the current record $2 ^ {82 589 933} - 1$? A Mersenne number is a number of the form $2 ^ n - 1$ (where n is a non-zero natural number), a prime Mersenne number (sometimes Mersenne prime number), is therefore a prime number of this form. There is an efficient p...
I'm trying to understand how Nitsche's method works in practice. I understood the theoretical principle behind it, but what I can't understand is its implementation. More precisely, I'd like to solve the classical Poisson equation on the square with classical conforming degree 1 finite elements using Nitsche's method f...
I have a problem dealing with heat transfer which is spherically symmetrical. I was thinking it should be possible to solve this as a 1d problem in spherical coordinates using the radius only. Normally, the 1d heat equation can be solved as: $$ u_n^{k+1} = u_n^{k} + \frac{\alpha \Delta t}{\Delta x^2} \left(u_{n+1}^{k}...
I have a real square matrix $X$ which I need to perform a Singular Value Decomposition on. Now, performing the operation $$ X = USV^T $$ as $U$ and $V$ are orthogonal, we know that $\det(X)=\pm\det(S)$ and $\det(S)$ is non-negative as singular values are non-negative. Now, I need to know the sign of the determinants of...