Questions tagged [numerics]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
33 views

Numerical stability in the product of many matrices

I have to calculate in numpy the matrix-product of many matrices (~400). Are there common practices to increase numerical stability? If this is relevant, the matrices are 300x300 orthogonal ...
2
votes
1answer
63 views

Does mass balance hold in convective diffusion

I'm trying to understand how convection-diffusion equations are solved in pipe flow modules available in CFD solvers. $$ \frac{\partial C}{\partial t} + \nabla \cdot (\mathbf{v} C) = \nabla \cdot (D \...
4
votes
1answer
106 views

Complex differentiation of linear solvers

I have a linear system $$Ax=b$$ which I'm solving approximately, and I need to take the frechet derivative of x with respect to z. Were I solving the problem exactly (either analytically or to machine ...
0
votes
1answer
70 views

How do I get power from gaussian beam numerically?

I would like to get the power from a Gaussian beam given a set of points at which electric field is evaluated. Please follow my reasoning and tell me what assumption maybe are wrong Power definition ...
0
votes
1answer
51 views

Solving differential equation in Python with discretized variable coefficients

I am trying to solve a differential equation with discretized variable coefficients which are calculated from a time serie. In this case the Runge-Kutta step size is fixed by the frequency in the time ...
5
votes
2answers
107 views

Is the diffusion equation with Neumann and Dirichlet BCs well-posed?

I am considering the following diffusion equation: $$\frac{\partial f}{\partial t} = \frac{\partial}{\partial x}[D(x,t)\frac{\partial f}{\partial x}]$$ over a grid ...
-4
votes
0answers
26 views

Derive the Finite Difference equation corresponding to the steady state PDE. Explain how to implement Dirichlet and Neumann boundary conditions

A rod of length L = 1m, is made of copper, with thermal conductivity κ = 380W/m/K. A uniform heat supply h = 10kW/m3 is applied to the rod. The left boundary of the rod is kept at constant temperature ...
3
votes
0answers
61 views

Numerical integration with singularity term

In https://www.johndcook.com/blog/2012/02/21/care-and-treatment-of-singularities, the author explains the subtraction method to get rid of singularities when performing numerical integration. The ...
4
votes
2answers
262 views

Chebyshev and Legendre expansions

I am looking at approximating my function $f(x)$ using a Chebyshev and Legendre series and I ran into this question. Is interpolation using $n+1$ Chebyshev nodes the same as representing the ...
6
votes
2answers
1k views

Runge-Kutta in the presence of an attractor

Suppose you are solving a system of equations numerically that possesses an attractor (no matter the initial conditions set, all the different solutions will approach a specific set of values that ...
0
votes
1answer
75 views

Robin Boundary Condition with Implicit Upwind - Finite Difference Method for 2D Convection-Diffusion Equation

I am trying to solve a problem with 2D Convection-Diffusion equation with U = Concentration ($mg/m^{2}$) using Implicit Upwind Finite Difference Method like this $$ \frac{\partial U}{\partial t} + ...
6
votes
0answers
93 views

How to check if my stiffness matrix is correct

I built the stiffness matrix for the Poisson equation on a 2-dimensional domain with the shape of "almost" an octagon, using pyramid basis functions. I used almost to intend the fact that I have an "...
2
votes
1answer
42 views

Numerical integration of the dataset of a function

The energy equation for a spherically symmetric system is given by $$\mathscr{E}=\frac{v^2(r)}{2}+\frac{c_s^2(r)}{\gamma-1}+\phi(r)$$ where $\mathscr{E}$ is the total energy, $v$ is the velocity of ...
2
votes
1answer
51 views

Defining Current Density in a FEM model (MATLAB)

I'm attempting to solve the Poisson equation in 3D for a magnetic vector potential in the presence of a current source. To validate my code, I'm initially looking to reproduce the model described in ...
4
votes
0answers
97 views

Integrators for Nonlinear/Stiff PDE

It was suggested I ask this question in this section. Anyway: I have a particular nonlinear PDE of the form $$ u_t(x,t)=iu_{xx}(x,t)+f(x,u(x,t)) \tag{1} $$ Where f is some nonlinear function. With ...
8
votes
1answer
143 views

Radial integration of expensive function with Bessel weights

I need to calculate the integral $$I = \int_0^R f(r)J_n\left(\frac{z_{nm}r}{R}\right)rdr$$ where $J_n$ is the $n^{\mathrm{th}}$ order Bessel functions of the first kind, $z_{nm}$ is its $m^{\mathrm{...
1
vote
1answer
84 views

Solve linear system with Newton-Raphson method

Is it possible to solve a linear matrix system $A x = b$ using the Newton-Raphson method? If yes, how can this be done? More special, how is the derivative build?
-1
votes
1answer
37 views

Integrate using Composite Simpson's rule

In a question, we have been given the speed of a car at time t= 0,2,4,6,.......,20 minutes.But it asks us to approximate the distance travelled by the car in 30 minutes using Composite Simpson's rule. ...
7
votes
1answer
122 views

Numerically estimating expected value of f(x) when x is normally distributed

I need to estimate $$ \mathbb{E}_x[f_i(x)] = \int_{\mathbb{R}^n} f_i(x) p(x) dx $$ for many functions $f_i(x)$, where $p(x)$ is the density of a normal distribution. The evaluation of all the ...
-1
votes
1answer
33 views

Recursive Algorithm to Calculate Determinant via Expansion of Minors in C#

I have been recently trying to attempt to write an algorithm in C# that would calculate the determinant of a matrix via recursion using the expansion of minors method. I understand that there are ...
1
vote
1answer
294 views

1-D turbulent energy spectra in homogeneous direction (non-isotropic)

I am trying to compute the one-dimensional energy spectra for my channel-flow simulation. I have already written a post-processing script to achieve this; however, I need to validate my code before ...
2
votes
0answers
56 views

What exactly is the cause(s) of blow-up for too-large step size in a method like RK4?

I have been working on creating a few home-made numerical methods, and I am using them to visualize text-book problems from my Strogatz dynamics textbook. It feels like a good way to learn numerical ...
0
votes
0answers
22 views

Interpreting results of using no-flux boundary condition

I am solving for solute transport in 1 D. $$\frac{\partial C}{\partial t} = D\frac{\partial ^2 C}{\partial x^2} - v\frac{\partial C}{\partial x}$$ No-flux boundary condition is imposed at both the ...
1
vote
1answer
62 views

Implementing Robin Boundary condition (finite difference)

I'm interested in applying Robin boundary condition to a convection-diffusion problem in 1D. In the following system, $$\frac{\partial C}{\partial t} = D\frac{\partial ^2 C}{\partial x^2} - v\frac{\...
2
votes
0answers
78 views

Extracting FEM matrices in matlab pde toolbox

I am trying to follow the dynamic linear elasticity in Matlab, link here. My goal is to extract the FE Matrices using the function assembleFEMatrices in matlab and solve the resulting system of second-...
-1
votes
1answer
94 views

Imposing periodic boundary condition for linear advection equation - Node problem

I've spent the whole day trying to figure out what is the correct way to impose (and implement) periodic boundary conditions $u(0,t)=u(1,t)$ for all $t>0$ for the simple advection equation $u_t + v ...
1
vote
1answer
108 views

Runge-Kutta fourth order method. Integrating backwards

I am using a Runge-Kutta fourth order method to solve numerically the usual equation of motion of a background scalar field in curved spacetime with a quartic potential: $\phi^{''}=-3\left(1+\frac{H^{...
1
vote
1answer
69 views

How to Break Coupled ODEs down to first order for Runge-Kutta

My question might seem a bit simple. I am trying to solve a system of ODEs using Runge-Kutta method. I am having difficulty breaking down the equations into a system of first order ones required ...
2
votes
1answer
58 views

How to robustly and numerically expand a $k$-order polynomial in two variables defined on a polygon domain?

Given a $k$-order polynomial in two variable $p(x, y)$ defined on a polygon domain $K$. And I want to numerically expand it to the following form $$ p(x, y) = c_0 + c_1 x + c_2 y + c_3 x^2 + c_4 xy + ...
1
vote
0answers
51 views

Numerical Method for Equation System of two depending Equation Systems

I am searching a solution method for the following equation system of equation systems: Let $A \in \mathbb{R}^{n \times n}$ be an invertible Matrix, $f, b_1, b_2 \in\mathbb{R}^n$ given vectors and $ ...
1
vote
2answers
47 views

Numerical integral with symbolic integral in exponent

Many times in fourier approximation we come across integrals such as $$\int_0^1 e^{-\gamma\int_0^xu_0(\eta)d\eta}dx$$ where $\gamma$ is a constant and the data for $u_0$ is provided as a discretely ...
6
votes
1answer
112 views

Computing square root of diag(u)-uu'?

I need an efficient way to take square root of a matrix which is a sum of diagonal matrix and rank-1 matrix. More specifically it's the following matrix $$A=D-uu'=\text{diag}(u)-uu'$$ Where entries ...
3
votes
1answer
52 views

Bounding error of float32 matrix multiplication

Some numerical debugging led me to the minimal example below. I'm observing relative error of 0.75 on individual elements. Is there a way to estimate/bound this error without resorting to higher ...
2
votes
1answer
46 views

Passing data as arguments in ODE45

I need to import data from file in order to describe the structure of a network. I used the following: weights = readtable('weights192.txt'); W = weights{:,:}; ...
2
votes
0answers
51 views

Numerical integration of SDE: choice of $dt$ and algorithm

I am working on the following Stochastic Differential Equation (SDE) in the Quantum Mechanics context: $$dX_{t} = a X_{t} dt + b X_{t} dW$$ where $X_{t}$ is my stochastic varible, $dt$ is my ...
1
vote
1answer
32 views

Weighted moving variance

i have a time-series and, in analogy with exponentially weighted moving average, i would like to compute the exponentially weighted moving standard deviation or variance in an efficient, numerically ...
14
votes
1answer
2k views

How to Run MPI-3.0 in shared memory mode like OpenMP

I am parallelizing code to numerically solve a 5 Dimensional population balance model. Currently I have a very good MPICH2 parallelized code in FORTRAN but as we increase parameter values the arrays ...
2
votes
0answers
37 views

Inverses of many standard subspaces of one large matrix

i have a large rectangular invertible matrix M (about 5000x5000) and i have a loop in which i do the following for each iteration i (there are about 6000 iterations): i am given a subspace S_i (which ...
1
vote
0answers
66 views

Runge-Kutta for PID and system in separate calculations without filter

I need to calculate a closed-loop system in Python; specifically, obtain the PID response and then use the output to obtain the system response sample-by-sample with my own loop. For this, I am ...
0
votes
0answers
64 views

How to implement the following Finite Element method for Burgers' equation?

I am trying to replicate this result. It involves using the Galerkin finite element approach onto the viscous Burgers' equation. However, my implementation (in R) seems to be giving me wrong results....
0
votes
1answer
85 views

Well-posedness of Navier-Stokes equation

Before running a simulation for turbulence (e.g Rayleigh-Benard Convection), how do we check for well-posedness of Navier-Stokes with other equations for a given boundary condition?? Can someone ...
1
vote
1answer
348 views

Difficult bug in my 2D Compressible Euler solver

For the past few days, I have been writing a numerical solver for the 2D compressible Euler equations for an ideal gas. My numerical method has been the Local Lax Friedrichs or "Rusanov's method." ...
2
votes
1answer
642 views

Local truncation error of Dufort Frankel Scheme

The scheme is given by $$\frac{v_m^{n+1}-v_m^{n-1}}{2k} + b\frac{v_m^{n+1}+v_m^{n-1}-v_{m-1}^n-v_{m+1}^n}{h^2} = 0$$ where $v_m^n$ is the numerical solution at the $m^\text{th}$ spatial coordinate ...
1
vote
0answers
87 views

How to compute the following Crank-Nicolson scheme for the viscous Burgers' Equation?

I am attempting to replicate results from this article. I'm not sure why but my results are completely different and wrong. For example, the exact solution with parameters ($x=0.1$, $T=0.01$, $Re=0....
5
votes
0answers
48 views

Evaluate Nth root of a rational to a correctly rounded float

Excuse my lack of vocabulary for I have no formal training in this field, which is also why I ask this question - it may be trivial or it may be impossible. I want to evaluate an expression in the ...
0
votes
2answers
264 views

Boundary conditions for streamlines in enclosed flow

I am trying to solve Lid driven square cavity flow problem of Stokes equation using finite element method. I have boundary conditions for velocity as zeros on every boundary but u=1 on top boundary. ...
7
votes
1answer
533 views

Time discretization of the variational formulation of the Navier-Stokes equation

I've asked this question on mathoverflow too. Let $T>0$ $I:=(0,T]$ $d\in\mathbb N$ $\Lambda\subseteq\mathbb R^d$ be nonempty and open, $$\mathcal V:=\left\{\phi\in C_c^\infty(\Lambda,\mathbb R^d):...
10
votes
1answer
100 views

Benchmark problems for eigenvalue reordering algorithms sought

Every real matrix $A$ can be reduce to real Schur form $T = U^T A U$ using an orthogonal similiary transform $U$. Here the matrix $T$ is quasi-triangular form with 1 by 1 or 2 by 2 blocks on the main ...
0
votes
2answers
337 views

(FEM) 1D time-dependent heat equation convergence problem

I'm simulating a simple 3-node bar with convection BCs at the edges to validate my FEM code. The following data was used: Initial temperature = 25 ºC Temperature surrounding the rod = 10 ºC Thermal ...
1
vote
0answers
79 views

What's the more efficient way to solve this matrix equation?

This is intended to be a more generic question not about a specific system. Given a hermitian matrix $H(x_1,\dots,x_n)$ depending non-linearly on some real parameters $x_1,\dots,x_n$. We want these to ...