instruction
stringlengths
43
28.1k
In some algorithms to refine tetrahedron, we need to calculate the longest edge. background If exist a tetrahedron with node ABCD, it has edges AB,AC,AD,BC,BD,CD. Suppose AB is the longest edge, and E is the middle point of edge AB, the tetrahedron can be split into two tetrahedrons, that is, BCDE and ACDE. My problem ...
I'm using Jacobi iterative method for finding eigenvalue and eigenvector for hermitian or symmetric matrix. Eigenvectors corresponding to eigenvalues are not exact. The third eigenvector is totally off. That I've implemented and read about Jacobi. What are the possible reasons for that? This is my function file in scil...
I want to solve the model of a tube with an elastic obstacle, something like a simple model of an vessel with a valve. The fluid is given by an evolutionary incompressible Navier--Stokes equations, and the obstacle for elasticity equation. In the step 46 of dealii appears a simple way to manage this kind of problems If...
(I hope this question is fitting for this SE, I couldn't find very relevant tags) I am looking for an online platform in the style of Google Colab with the following requirements: possibility to run notebooks like in JupyterLab necessity of at least python and julia and following wishes: privacy-focused (even if I a...
I am struggling with this: In a render view in Paraview, is it possible to draw a square or rectangle around the region of interest and have this as a close up render view in another window then being displayed? Hope the question makes sense otherwise please comment and I provide a sketch of desired behaviour.
After composing my Paraview scene, I realised that I need to represent the units in a "Plot Selection Over Time" filter instead of seconds in milliseconds. How can one accomplish this?
Is there any algorithm (or tricks) for rootfinding to take advantages of automatic differentiation (AD)? Rootfinding algorithms typically solve $$ \mathbf{f}(\mathbf{y}) = \mathbf{0} $$ where $\mathbf{f}:\mathbb{R}^n\rightarrow\mathbb{R}^n$ and $\mathbf{y}:\mathbb{R}^n$. Newton's method is not applicable in my case bec...
I adjusted plotting fonts in a Paraview scene, saved as .pvsm file, and loaded it in a different Paraview version. The fonts changed. Can this be avoided? Also ticks (I set it to maximum of 3 ticks) settings are gone. Is .pvsm not the correct way to save a complex scene?
I'm trying to compute the Lyapunov exponent for a smooth continuous time dynamical system(say, $\dot{\bar{x}} = f(\bar x)$). I using the QR decomposition method. Here are the steps that I follow. Choose some initial condition in the basin of the attractor. Call this $\bar v_0$. And have a blob (hypersphere, $U$) of un...
I am trying to build a triangle mesh of the surface of a sphere which also includes a subdomain defined by a 'polygon'. Here is a successful example (subdomain defined by the red dots): Note that the triangles crossing lon = 180 are not shown. The method I used to do this fails for finer meshes, because it only 'knows...
I am trying to solve a generalized eigenvalue problem using Arpack, right now the code is using LAPACK but that's too slow, we only need a few eigenvalues and the matrices are sparse so using Arpack should be the way to go. Before I start working with the original code I decided to test a simple case using scipy wrappe...
I have quite a lot of experience solving unsteady Euler equations, including multi-component ones, with in house-coded finite-difference and finite-volume methods, including MacCormack and MUSCLE schemes and WENO flux reconstruction. Now I'm considering "upgrading" to laminar NS equations for compressible gases (i.e. w...
I am trying to solve the boundary value problem for heat equation: $$ u_{xx} + u_{yy} = f(x,y) $$ where the solution $u(x,y) \in [0,1] \times [0,1]$ and the Dirichlet boundary condition $u(x,y) = u_0$. So I discretized the problem with $N$ interior points with step size $h = 1/(N+1)$ $$ w_{i,j-1} + w_{i+1, j} + w_{i...
I'm trying to numerically estimate the Jacobian from a time-series. Following the paper, https://journals.aps.org/pra/abstract/10.1103/PhysRevA.43.2787. Consider that I have a scalar time series $x = (x(1), x(2), \dots, x(N - 1), x(N))$. In total there are $N$ data-points. So the steps that I'm following are as follows...
I've a matrix equation $\bar z^{(r)}(k + 1) = \bar{DF} ~ \bar z^{(r)}(k)$. Now the $\bar z$'s and $\bar{DF}$ are $d \times d$ matrices. Now $\bar{DF} = \begin{pmatrix} 0 & 1 & 0 & 0 & \cdots & 0 \\ 0 & 0 & 1 & 0 & \cdots & 0 \\ \vdots & & & & \\ 0 & 0 & 0 & 0 & \cdots & 1 \\ DF_{d1} & DF_{d2} & DF_{d3} & DF_{d4} & \cdo...
Is the refinement equation for the orthonormal Daubechies scaling function $$\phi(x) = \sqrt{2} \sum_n h_n \phi(2x-n) \;?$$ The filter coefficients for Daubechies wavelets have been given e.g. in this page. Consider case D20. Do the indices $n$ for $h_n$ run from 0 to 19? Or do we set $h_{-n} = h_n$? Suppose we have an...
In the rational case, we are interested to find polynomials $P(x)$ and $Q(x)$ s.t. $f(x_k)-P(x_k)/Q(x_k)=(-1)^kE$ for $k=1,2,\ldots, N$ where $N=deg(P)+deg(Q)+2$ This can be rewritten as $$ (1)~~~~~~(f(x_k)-(-1)^kE)Q(x_k)-P(x_k)=0 $$ The equation (1) is non-linear. The notes in this document suggest using the following...
Using the Remez algorithm, implemented using multi-precision library, in certain functions that I want to approximate, the error curve does not oscillate in between reference points, and so no roots can be found (subsequently no extrema). For example, this happens when I try to approximate $ln$ (natural logarithm) over...
In the following code, if I compile using ifort runs ok, but if I run it with gfortran appears the error: "Program received signal SIGSEGV: Segmentation fault - invalid memory reference." Can someone told me what I'm doing bad? Or maybe is an issue of gfortran. PROGRAM testing IMPLICIT NONE REAL :: coordN(3,2),aux(...
So imagine I have a $m$ vectors each of dimension $d$. Lets call them, $\vec x_{i}$, with $i = 1, 2, 3, 4, 5, \dots, m$. Now the idea is to find the neighbours of $\vec x_{i}$ (calling them $\vec x_{j}$), within a ball of radius $r$. So, $$ || \vec x_{i} - \vec x_{j} || \le r$$. Note: $|| \cdots ||$ is the Euclidean no...
I am currently using Task Spooler, which is a job scheduler I have installed on my iMac. I have encountered a problem in which I cannot execute a job properly. Using a bash script, this is how I run can use Task Spooler effectively: K="opt" # Jobname ts -S 1 # Number of jobs to run (1 or 2) for a in *inp do ts -m...
I have inherited of a flight dynamics simulation in C++ which represents a small drone with it's autopilot, actuator dynamics and a solid state IMU. Hence, it is composed of a few models, some continuous (flight dynamics & actuators), integrated with a runge kutta 4 scheme, some discrete (the autopilot and IMU). I have...
In my application, I have two general real matrices $A$,$B$ defined as follows, $$ A=\begin{bmatrix} -s I_3 & A_0 & 0 & 0 \\ A_0^T & -s I_3 & 0 & 0 \\ 0 & A_1 & -s I_3 & A_0 \\ A_1^T & 0 & A_0^T & -s I_3 \end{bmatrix}, B=\begin{bmatrix} 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ I_3 & 0 & 0 &...
I am writting a Fem code in c++ for a 2d plane stress model. My question is regarding the assembly stiffness matrix.I noticed that some elements of the matrix are not exactly zero but insted a number close to zero for example -1.7677e-15. Can floating point arithmetic erros result to an ill-conditioned stiffness matri...
I receive the following error when I run the code. ODEintWarning: Excess work done on this call (perhaps wrong Dfun type). Run with full_output = 1 to get quantitative information. warnings.warn(warning_msg, ODEintWarning) I got this from messing around with an example received from my professor and can't seem to und...
I need to solve $Ax=b$ in about 1 million dimensions. Furthermore, A is only accessible through matrix vector products, and these are noisy/inexact. Is there any solver with Python interface I can try on this problem? Basically I want to check if there's anything in the linalg community that might work to train a neura...
Assume the time-dependent linear elasticity equation. Using a finite element discretization we obtain $$M\ddot{u}=Ku+F_\text{ext}$$ where $M$ is the mass matrix,$K$ is the stiffness matrix, and $F_\text{ext}$ is the external load vector. Further using a time discretization scheme(e.g. Forward Euler), we obtain $$ M\dot...
I am trying to approximate a symmetric tensor of which the values are in the range of [1e-7,1e-4], by a symmetric tensor decomposition of lower rank. For this I am using the L-BFGS-B method in SciPy's optimization package. The relative errors (based on the Frobenius norm) I am obtaining are quite big (greater than 1). ...
I have the following problem: $$\min_{x\in \mathbb{R}^n}\|Ax-b\|_1$$ where the matrix $A$ is large and sparse. I am looking for methods/code that can minimize this efficiently. References are very welcome.
I actually have this data locality as a possible problem for why my fortran program runs somewhat slow. In one part of this program, I have nested loops and throughout these loops, a given section of a big array is referenced multiple times. The pseudocode goes like this subroutine foo() use mymodule, only : big_arra...
I am trying to get the numerical integration of a function using scipy's integrate.quad as follows. $$ \begin{equation} G (\alpha) = \frac{4\alpha}{\pi}\int_0^{\infty} x e^{-\alpha x^2} {(\pi/2}+\mathrm{tan}^{-1}[Y_0(x)/J_0 (x)]) \mathrm{d}x \end{equation} $$ import numpy as np from scipy import integrate from scipy.s...
When one equality-constrained optimization is formulated, the method of Lagrange multiplier will be the choice for me. In Chapter 17 from the book Numerical Optimization, quadratic penalty method can be used for such case. However, it doesn't mention when one should select quadratic penalty method over method of Lagran...
I have two data vectors $y1$ and $y2$, and I want to plot both of them as functions of the vector $x$. I want the result to be two overlapping curves. Here is the set of commands I am using. y2=[0.003,0.003,0.011,0.011,0.015,0.020,0.023,0.024,0.024,0.024,0.024,0.024,0.024,0.025,0.024,0.024,0.024,0.024,0.024,0.024,0.023...
From Computer Systems: a Programmer's Perspective: With single-precision floating point the expression (3.14+1e10)-1e10 evaluates to 0.0: the value 3.14 is lost due to rounding. the expression (1e20*1e20)*1e-20 evaluates to +∞ , while 1e20*(1e20*1e-20) evaluates to 1e20. How can I detect lost of precision due to ...
In Computer Systems: a Programmer's Perspective: Writing TMin in C In Figure 2.19 and in Problem 2.21, we carefully wrote the value of TMin32 as -2,147,483,647-1. Why not simply write it as either -2,147,483,648 or 0x80000000? Looking at the C header file limits.h, we see that they use a similar method as we have to wr...
Consider a nonlinear hyperbolic conservation equation: $$ \partial_{t}u = -\partial_{x}f(u) $$ The spatial derivative of $f(u)$ may approximated after a spatial discretization by $x_{j}=j\Delta x$ $$ \partial_{x}f(u_{j}) \approx \frac{1}{\Delta x}\left(F_{j+\frac{1}{2}}-F_{j-\frac{1}{2}}\right) $$ where $F$ represents ...
One of the most challenges in distributed consensus mechanisms is both time complexity and message complexity. For example, PBFT message complexity is O(n^2) that means that it is only scalable to tens of nodes. Thus, classical BFT (Byzantine Fault Tolerant) consensus mechanisms are not scalable to the large networks. ...
I have an interesting little problem that I believe can be formulated in terms of optimization or constraint programming. I have a few dozen variables $a$, $b$, $c$ ... and a set of constraints that establish relations between them, such as $a < b$. Some of these constraints are "turned on" by binary indicator variable...
I am trying to solve a linear elasticity model using finite element discretization in a rectangle domain [0,1]x[0,1]. For the solution of the the linear system $Ku=F$ I am using the CG algorithm. However, I have noticed some weird behaviour of the algorithm. For small grids (e.g 2x2 or 3x3 or 2x1 ...) the algorithm fai...
Most of the time, when I see someone reporting the average timing of a certain algorithm on a computer in a computational mathematics paper, they do something like this: Run the operation $n$ times (e.g., $n=100$ times); Discard the lowest and highest $m$ times (e.g., $m=10$ outliers); Compute the average of the remai...
Let $A$ be a matrix with real entries, and let $A_+$ be $A$ augmented by a single column. From linear algebra we know \begin{equation} \operatorname{rank}(A_+) = \operatorname{rank}(A) \hspace{10pt} or \hspace{10pt} \operatorname{rank}(A_+) = \operatorname{rank}(A)+1 \end{equation} But what if $A$ has double-precisio...
I am trying to solve $M\ddot{u}=-Ku+F_\text{ext}$ for a 2D linear elastic model with $M$ be the mass matrix,$K$ the stiffness matrix and $F_\text{ext}$ the external load vector coming from a uniformly distributed load acting on one edge of the model.(Note: $F_\text{ext}$ is not time-dependent). An explicit time-scheme ...
I need to slove one optimization problem of quadratic programming. The number of optimization variables is about 16,000. The constraints include equality constraints and inequality constraints. I have no such practical experiences before. There are are three choices for the probelm after reading some materials: active...
I need to optimize a code where the most performance critical part is doing a 'change of basis', in other words it is an unitary similarity transformation on a big real positive definite symmetric matrix real matrix. This consists in the following operation: $U^T A U$, with $A$ real positive definite symmetric matrix a...
In many modern papers Navier-Stokes equations are solved with finite-difference or finite-volume methods using WENO reconstruction for non-viscous fluxes and central differences for viscous ones. It seems pretty straightforward to apply central difference to "simple" second derivative like $\frac{\partial^2 u}{\partial...
I am reading a book on digital circuits. It says that given a n-bit binary number $N$, its two's complement representation is itself, if $N$ is positive; and its two's complement representation is $2^n - N$, if $N$ is negative. It is unclear to me what it says. What does it mean by saying a binary number $N$ is posi...
I want to solve a linear set of equations (Ax=b) using LU decomposition. My "A" matrix is a complex matrix which is symmetrical. The code that I work has two parts. In the first part I do all the initialization where I compute L and U factors of the matrix. The second part of the code runs in every time-step (which is ...
Using Sympy, I would like to compute the negative binomial expansion of a general symbolic polynomial, e.g., $(x_1 + x_2 + x_3 + 4 x_4)^{-1}$. I understand that I can go by recursively partitioning the expression inside the parenthesis into two parts and computing their expansion like $x_1$ and $x_2 + x_3 + 4 x_4$, the...
I would like to solve two types of simple 2D problems, namely the stationary heat equation on an L shaped geometry like this: And also compute the magnetostactic field in an air gap of the following geometry: Since it wouldn’t be smart to reinvent the wheel, I searched for an open-source library that could handle suc...
In particular, I want to focus on finding the volume $V$ because I will need it to start working on solving the centre of mass This $3D$ homogenous body (Torus section) is defined by $$x^2 + \left(\sqrt{y^2+z^2}-5\right)^2 < 4 $$ where, $$y<1, z>2$$ I confined the $3D$ shape to a rectangular region where $$ -2<x<2\\ -7...
what is the time complexity of gradient $\nabla_{f}$ using the $\mathcal O$-notation? what is the time complexity of jacobian matrix using the $\mathcal O$-notation? who knows some references to introduce the time complexity of gradient? I make reply to reviewers for computational complexity of gradient and matrix oper...
I am trying out odeint and received the error 'Excess work done on this call (perhaps wrong Dfun type).'. The values returned are also super sensitive to small changes of the initial value. Some initial values don't run into this problem whereas others do. rho = 0.1 beta = 0.01 N = 50 gamma = 0.20 thet...
Initially I thought that this is the kind of question which ought to have already been answered in the form of an example online, but so far I haven't found one. I will admit that I am very new to both FEniCS and the use of FEM software for solving PDEs in general, so my goal here in solving this problem is to a gain a...
How to best export Scene/Screenshot in Paraview as a vector graphic? It seems PDF and PS export are not working really good for me (Paraview 5.3/5.5/5.8), either the scene is cropped at the borders or text is missing (legends).
I am looking for a simple to implement algorithm for the bipartite euclidean matching problem (or an implementation of any practical algorithm). I am aware of Agarwal's paper, but I would like to implement something simpler. The simplest idea I could come up with was starting with some initial matching (possibly random...
I hope that one of you guys can help me because i have been stuck here for a week. I am trying to read a gmsh file (.msh) using dolfin convert to XML and then download it with dolfin. The thing is when i assemble the stiffness matrix and the mass matrix and try to generate an exemple (MonteCarlo) using these matrices ,...
I am looking for the details of commonly-used predictors for accelerating the convergence of iterations using Newton-Raphson scheme for nonlinear problems in FEM. I am looking specifically for static problems. Note: Such predictors based on velocity and/or acceleration are used for transient problems but they are not a...
I am trying to solve the linear finite element equation $M\ddot{u}+Ku=F(t)$, where $M$ is the mass matrix ,$K$ the stiffness matrix and $F(t)$ the external load vector, parallel in time using XBraid package.Using Newmark's method for time integration we take three equations: $(K+\frac{M}{dt^2β})u_{n+1}=F_{n+1}+\frac{M...
Starting from $$ c_p \frac{\partial u }{\partial t} = k \nabla^2 u $$ in a one dimensional domain [0,1] where $c_p$ and $k$ are modeling two different materials: $$ k = \begin{cases} 1 ~\text{if} ~x < 0.5\\ 2.0 ~\text{else} \end{cases} $$ $$ c_p = \begin{cases} 10^{-8} ~\text{if} ~x < 0.5\\ 1.0 ~\text{else} \end{cases}...
I am doing a solar-system simulation. I am using Ruth's 3rd order sympletic integrator to avoid the problem of Energy Drift (which I had with RK4), but the the planets quickly leave orbit, and energy is by no means conserved (just like with RK4). I applied this to the N-body problem with the following: (KE=1/2mv^2...
I am trying to solve the Poisson Equation $\frac{\partial^2 T}{\partial x^2} + \frac{\partial^2 T}{\partial y^2} = 32(x(x-1) + y(y-1))$ for a 61x61 grid using Python3 with boundary conditions being $T=0$ on all four boundaries and taking an initial guess of $T=50$. I am considering a relaxation parameter $w=1.6$. To so...
Help me understand a part of Brent's root finding algorithm. In a typical iteration we have samples (a,fa), (b,fb), (c,fc) all real with (a<b<c) or (c<b<a) . Also, in the case I am interested in (1< fa/fb) and (fc/fb <= -1). In that case (using Mathematica syntax), the algorithm attempts inverse quadratic interpolati...
Consider independent random variates $X_0, X_1, . . .$ each uniformly distributed on the support $[0, 1)$ Let's say $Y = X_0 + X_1$, where $X_0$ and $X_1$ are independent uniform random variables with range $[0,1)$ I then derived the following PDF to describe the distribution of the sum $Y = X_0 + X_1$ using a convolut...
I have a linear system of the form $A x = b$ where $A$ and $b$ are known, $A$ is "square", and $\lvert b \rvert_1 = \lvert x \rvert_1 = 1$. Unfortunately, I am working in a framework that only gives me access to a dot product, not the individual vector or operator elements. The only way I have found to solve this probl...
I am trying to implement 3D tetrahedral elements in my finite element code (which works fine for linear triangles and quadrangles in 2D). But my simulations are crashing with tetrahedral elements. My implementation details in C++ are as follows: Shape functions and their derivatives w.r.t. $\xi$, $\eta$ and $\zeta$ $N...
I currently have a code that solves $u_t+ cu_x=0$ with periodic boundary conditions, and constant $c$ (using an upwind method). I'm wondering how I would alter this code to solve something of the form $$u_t +c(x) u_x=0.$$ I'm thinking it will look of like $$u_i^{j+1}=u_i^j-c_i \Delta t \left(\frac{u_i^j-u_{i-1}^j}{\Del...
I am looking for a concise description to help me understand the error for Monte Carlo Integration using Uniform Sampling and Importance Sampling For Importance Sampling I have that the error is just the square root of the variance... $$\sqrt{\frac{1}{N}<f(Xi)^2>-<\frac{1}{N}f(Xi)>^2)}$$ for Uniform Sampling what would...
I am trying to solve a 2D dynamic linear elasticity model parallel in time using Xbraid. The spatial domain is [0,1]x[0,1] and time domain [0,1]. For time integration I am using a backward Euler scheme and FEM for spatial descretization. I tried to run a simulation for a small spatial problem(4x4 quadrilateal elements)...
I have a matrix $A \in \mathbb{R}^{m \times n}$ where $m \gg n$ and I want to compute the full QR decomposition $A = QR$. Where $Q$ is an orthogonal $m \times m$ matrix. Bishof & Van Loan (1987) describe that $Q$ can be represented as the sum of a low-rank matrix plus the identity matrix: $$Q = I + W Y$$ Where $W \in \...
I need to take integer square roots $\lfloor \sqrt{n}\rfloor$ of (lots of) 128 bit numbers $n$. Calling gmp seems to take surprisingly long (though I can't tell for sure, since gmp routines are not showing up in the profiler information). Is there a standard way to compute $\lfloor \sqrt{n}\rfloor$ in this situation us...
So, my question is if one should ideally keep a record of all seeds that are used when publishing numerical work that involves one or more random number generators (e.g. a stochastic simulation), and if so, whether there's a standard approach to doing this when the number of random number generators depends on the hard...
I have some data that looks like as follows x-cor y-cor z-cor 0.02 0.0251 0.02 0.01 0.0257 0.02 0.014 0.02 0.03 0.023 0.003 0.05 0.013 0.002 0.77 .................... .................... I would like to draw an image like the above. Can you please suggest a way to start that in Matlab/python? image sourc...
I am taking a computational linear algebra course and i got stuck during a homework problem concerning the computation of inner products. I am supposed to compute the inner product:$$\mathrm{a}_{\mathrm{k}}=\frac{\left(\mathrm{g}_{\mathrm{k}} \mid \mathrm{f}\right)}{\left(\mathrm{g}_{\mathrm{k}} \mid \mathrm{g}_{\mathr...
I have a cell centered cartesian grid and am trying to implement the flux inside the divergence term using numerical flux with a flux limiter. I found different formulas for MUSCL flux limiter, where one source seem to say one needs to use a different stencil depending on which way the quantity propagates at the face, ...
Pasted below is my python code. It is a 4th order runge kutta that evaluates the 2nd order ode: y'' +4y'+2y=0 with initial conditions y(0)=1, y'(0)=3. I need help fixing it. When I run my code, my analytical solution does not match my numerical solution, my professor said they should be the same. I have tried editing t...
We'd better not to reinvent the wheel. But without some programming, one can hardly understand computational fluid-structure interaction. And I would like to know which papers or algorithms should a student reproduce in order to understand the big picture of computational fluid-structure interaction. It is better if t...
In practice, L-BFGS is frequently held comparably to other inexact QN methods, and it provides a middle ground of sorts between Hestenes–Stiefel CG and BFGS as memory goes from zero to infinity (Numerical Optimization Ch. 7). Lots of empirical results show L-BFGS outperforms GD, at least in certain large classes of set...
Hesthaven's book 1 mentions the following time step restriction for Navier-Stokes equations (see (7.32) in 2008 edition) $$ \Delta t \approx \frac{h}{N^2} \frac{C}{|u| + |c| + \frac {N^2 \mu}{h}} $$ ($h$-element size, $N$-degree of polynomial basis, $C$-constant) Isn't this equation dimensionally incorrect? $\mu/h$ doe...
Normally I write the incompressible Newtonian isothermal flow Navier--Stokes equations as follows: $$\displaystyle \frac{\partial v}{\partial t} -\nu\Delta v +\color{red}{(\nabla v)v} +\frac{1}{\rho}\nabla p = f_b $$ But I'm reading now the followwing $$\displaystyle \frac{\partial v}{\par...
I would like to integrate a discretized field in cylindrical coordinates, given as A(r, z), with z being spaced regularly (spacing distance dz), and r being spaced non-regularly. Moreover, r[0]>0 due to the chosen discretization. For integration, I would like to use the trapezoidal approach, and start with the z-compon...
I have to compute the trace of the product between three matrices $A,B,C$ in python, i.e. I have to compute $tr(A^TBC)$ and I was wondering what was a good way to do it in Python(here $A^T$ is the transposed of $A$). If I had just 2 matrices $A, B$ and I wanted to compute $tr(A^TB)$ I know I could do something as nump...
I am trying to understand the finite element method and want to apply it to a 2D equation with a triangular mesh. I have chosen the reference element to be the triangle with vertices $(0, 0), (0, 1)\text{ and }(1, 0)$. On this reference element, I define the three basis functions $$\phi_1(x, y) = (1 - x)(1 - y) \quad \...
I want to solve the nonlinear equation $\frac{d^2x}{dt^2} + k\sin x = 0$, numerically. I found that solving this elliptic integral would be cumbersome, so is there a numerical method i could use to solve it? I have tried to apply Newton's method, but it requires a rough value of where the solution lies, which i do not ...
For a cell-centered finite-volume calculation, with a nontrivial stencil (either using an unstructured grid or a strongly non-uniform structured grid), what are the main techniques for reconstruction of function values and derivatives on cell faces? What are their advantages and disadvantages, e.g., compared to the pol...
I am planning to do some basic algebra on continuous, non-analytical random variabels. I want to define their probability density functions as arrays x and f(x). Yet, I was surprised to find out that there does not seem to be any package that does basic operations like computing sum- or product distributions of two pdf...
I want to solve an IVP in python with two variables, x and u, but I need the values of u to be between 0 and 1. Right now it is giving me a solution with negative values for u. Here is the code I have. def model_case_3(t, z, Kmax, k, b, list_Kmax, sigma): a=1.5 x, u= z m=1 r = list_Kmax[0][0] dxdt = (x)*(r*(1-a*u...
What are the general algorithms used for diagonalization of large Hermitian matrices and Unitary matrices? ($>5000 \times 5000$) LAPACK seems to diagonalize Hermitian matrices almost 20 times as fast as unitary matrices, and as far as I know, the routines are also different. How is the computational complexity calculat...
I would like to research the Neuman boundary that can verify the following problem $\begin{aligned} &\text { (} P \text { )}\left\{\begin{array}{l} \frac{\partial U}{\partial t}(x, t)+A \frac{\partial U}{\partial x}(x, t)=0, \quad x \in[a, b], t>0 \\ U(x, 0)=U_{0}(x), \\ \frac{\partial U}{\partial \eta}=? \end{array}\r...
I've been trying to solve the following (relatively simple) system of Lotka-Volterra ODEs in Python using SciPy's odeint: $$\dot{z_1} = z_1 \left(- \sigma z_1 + \sigma z_2 + \rho z_3 - z_4 - z_5\right)$$ $$\dot{z_3} = z_3 \left(\sigma z_1 - \sigma z_2 - \rho z_3 + z_4 + z_5\right)$$ $$\dot{z_4} = z_4 \left(\sigma z_1 -...
Is there a name/standard algorithm to solve the following equation for $X$? $AX+X^TB=C$ Matrices $A$,$B$,$C$ are dense, diagonalizable, nearly singular, about $1000\times 1000$ in size. I've looked through SLICOT routines, and nothing looked directly applicable.
So I have a question about simplifying my C code , This is the question : A pandemic of the Heineken virus is underway in Croatia and around the world. The National Civil Protection Headquarters plans to introduce protection measures that will take effect from Sunday at midnight, and they are: If it is sunny and windle...
Recently I do simulation on Lorentzian Function with FFT Lorentzian Function is 2a/(x**2+a**2) import numpy as np from scipy import fft import matplotlib.pyplot as plt a =1 N = 500 x =np.linspace(-30,30,N) lorentz = (2*a) * (1/(a**2 + x**2)) fourier = (fft.fft(lorentz)) fig, (ax1) = plt.subplots(nrows=1, ncols=1) ax1...
I have skimmed through the LAPACK user guide, but I could not find if LAPACK offers routines for Krylov Subspace based methods (such as CG or BiCGSTAB etc) and Newton method based nonlinear solvers. Also, are iterative methods available in LAPACK in general?
I have been working on a solver for shallow water equations with reflective boundary conditions. I have found that it diverges very fast. As a workaround I noticed yesterday that if I smooth the momentum (water column height * velocity) field as post processing in each step, the solution no longer blows up. So it seems...
Consider the following problem, $$ -\Delta u(x) = f(x), \qquad x \in \Omega \\ u(x) = 0,\qquad x \in \partial \Omega$$ with $\Omega = [0,1]\times [0,1]$ being the domain and $\partial \Omega$ being the boundary. The source term $f(x) \in L^2(\Omega)$ is a smooth source term. The exact solution is known. I have generate...
I didn't really know if this stack was the right place to post but I was reading the documentation for creating an exponential random variable in numpy. But isn't there a typo. Like shouldn't it be : $f(x; \beta) = \frac{1}{\beta} \exp(-\frac{x}{\beta})$ instead of $f(x; \frac{1}{\beta}) = \frac{1}{\beta} \exp(-\frac{x...
I am trying to find a paper that I saw about a year ago. I am not sure of the actual date of the paper. I believe it was a finite difference CFD paper. The interesting part of the paper was the addition of a single degree of freedom variable to all of the mass conservation equations. This residual mass conservation var...
I am writing a FE program which calculates the displacements under a uniform load. I want to store the stiffness matrix in sparse form(COO) without using an external library.Assume an upper-bound for the number of non zero elements per row is known. My problem is that I can't assemble the matrix in a sparse form and al...
I was playing around with numerically solving the 1D wave equation with density and stiffness varying with position using central differencing methods and noticed that for certain discretization steps sizes $\Delta t$ and $\Delta x$ the solution could become unstable. Therefore, I thought maybe if I increased the order...
I have a background image of a fractal on my phone that I would like in a higher resolution with super sampling, and decided to write my own program for it. I've got down rendering a Mandelbrot set, even using HSV/HSL as coloring methods, but I can't get my fractals to look as nice as these. Here's a prime example, and...