Skip to main content
Share Your Experience: Take the 2024 Developer Survey
11 votes

Is using iterative methods to solve a linear system always superior to inversing the matrix?

First off, there are basically no scenarios where one would ever actually compute and store $A^{-1}$ in memory, even for small problems. An LU factorization offers both superior efficiency and ...
whpowell96's user avatar
  • 2,548
6 votes
Accepted

Can this finite difference dispersion be eliminated somehow?

It isn't the spike that's causing the dispersion. The scheme you use has a dispersion relationship whereby waves of different frequency travel at different speeds. Every numerical scheme has such a ...
Wolfgang Bangerth's user avatar
6 votes

Stability of Euler forward method

The solution of $\frac{du}{dt} = Au$ is $u(t) = \exp(tA)u(0)$, and explicit Euler approximates $\exp(tA)$ using $\lim_{n\to\infty} \left(I+\frac{t}{n}A\right)^n$. Of course in practice you cannot ...
lightxbulb's user avatar
  • 2,162
5 votes
Accepted

Burger's equation (PDE) does not work with downwind difference?

The qualitative difference between upwind and downwind flux (note that both are first order accurate for twice continuously differentiable solutions) lies in the fact that the upwind flux (in the ...
Dan Doe's user avatar
  • 1,083
5 votes

Finite difference problem

Since this is apparently a homework problem, let's just illustrate the idea on a simple small example. Let's take the domain [0,1], with the discontinuity at $x=0.5$, and assume $\alpha$=1 to the left ...
Maxim Umansky's user avatar
5 votes

Factorize laplacian in terms of first derivative matrix

It is sufficient if you consider a $D$ that uses forward or backward differences with reflecting boundaries: \begin{equation} D_f = \frac{1}{h}\begin{bmatrix} -1 & 1 & & \\ & \ddots &...
lightxbulb's user avatar
  • 2,162
4 votes
Accepted

Generalized eigenvalue problem for large, potentially ill-conditioned systems

For large systems, any direct solver methods tend to be a dead end as what often starts as a sparse system ends up becoming dense. In fact, just storing all eigenvectors is itself typically impossibly ...
Mikael Öhman's user avatar
4 votes
Accepted

Automatic Differentiation In the Presence of Jump Points

Finite differences, when applied to a function from $\mathbb{R}$ to $\mathbb{R}$ with a discontinuity, will do a better job of capturing the nature of the derivative, which is no longer a function but ...
MSMommer's user avatar
4 votes
Accepted

My toy Laplace equation solver using finite-difference is unstable and I'm not sure why

The iteration could be blowing up. You can see this by looking at your iteration $|u_{i+1}|\le \frac{1}{4} \omega(\epsilon, 2h) |u_i|_{\infty} + |\epsilon|_{\infty} |u_i|_{\infty}$ where $\omega(\...
Yimin's user avatar
  • 188
4 votes
Accepted

When can I use finite differences for differentiation?

Whenever the differential is well defined. Note that by definition $$ \lim_{\Delta x \rightarrow 0} \frac{f(x) - f(x-\Delta x)}{\Delta x} = \frac{d f(x)}{dx} $$ If this quantity exists and is finite, ...
helloworld922's user avatar
4 votes

When can I use finite differences for differentiation?

There is a field of numerical analysis called numerical differentiation which studies this kind of problem using various methods, though often things like finite differences. In general, any ...
Andrew Krause's user avatar
4 votes
Accepted

Best finite difference scheme in 2D for the mixed derivative

There are two main ways to see finite differences. One way is to see it as taking linear combinations of the Taylor expansions of the points and choosing the coefficients so that you get a desired ...
lightxbulb's user avatar
  • 2,162
4 votes
Accepted

How to evaluate the points near/at the boundary when using Richardson extrapolation for improved accuracy of a derivative

Your question was quite interesting - I haven't seen it addressed in any of the books on FDM that I have read (LeVeque, Morton, Lapidus, Thomas). I had never thought about this, so I tried to come up ...
lightxbulb's user avatar
  • 2,162
4 votes

"Cleanest, most professional" approach to implement a finite differences scheme in dimension greater than two

Finite differences are implemented by fitting a (multivariate) interpolating polynomial through a set of points and taking the derivatives of said interpolating polynomial. Contrary to popular belief (...
lightxbulb's user avatar
  • 2,162
3 votes
Accepted

Where am I making a mistake in solving the heat equation using the spectral method (Chebyshev's differentiation matrix)?

The answer is quite simple: You have to set the Neumann boundary condition $u_x(-1,x)=0$ explicitly Add following line (fifth line): ...
ConvexHull's user avatar
  • 1,335
3 votes
Accepted

Solving Poisson's Equation with Periodic Boundary Conditions

Here's what I think the problem is. You have the equation: $$\Delta u(x) = f(x), \, x\in \Omega.$$ where $\Omega$ is a circle/torus. First you have some compatibility constraints you have to satisfy. ...
lightxbulb's user avatar
  • 2,162
3 votes

Modeling contamination diffusion in a draining container, part 2

In case this helps anyone in the future, I wanted to finish off the problem by showing how I actually implemented it numerically. Forget Newton's method; I just solved the matrix equation for ...
HiddenBabel's user avatar
3 votes

Factorize laplacian in terms of first derivative matrix

@lightxbulb's answer gives the correct factorization already, but since you mention failed attempts with the Cholesky factorization, let me describe a method to discover the factorization numerically, ...
Federico Poloni's user avatar
3 votes

Isolating decaying solutions to nonlinear second-order ode

Eliminating the constants, the approximation close to $x=0$ is $y(x)=\pi+xy'(x)$ with $y'$ nearly constant. Or one could multiply the leading terms with $2x^2y'$ and integrate $$ 2x^2y'y''+2xy'^2-2\...
Lutz Lehmann's user avatar
  • 6,109
3 votes

Crank Nicolson Method with closed boundary conditions

I tried to run your code and I guess there might be a small mistake in your derivation, When you impose $u_{-1}^{j+1} = u_1^{j+1}$ into the equations at the ends, you have to equate $u_{-1}^{j+1} = ...
RandomElasticity's user avatar
3 votes
Accepted

Can the Runge-Kuta algorithm help in reducing numerical dispersion and anisotropy when using the FDM to solve the 2D wave equation?

Question 1 The temporal accuracy can probably be improved by using a fourth order Runge-Kuta algorithm instead of a standard three-point central difference approximation for the second order time ...
lightxbulb's user avatar
  • 2,162
3 votes
Accepted

Why does the FDM give a correct solution to a PDE with a discontinuous initial condition?

Looking at the plots of the errors, it seems that there is not much difference between the oscillations that you have in this case with respect to those that you had in your previous post (Can this ...
Rigel's user avatar
  • 419
2 votes

Oscillation in non-linear porous flow solved by finite difference

Thank you for the tip whpowell96, I did as you suggested and it works fine. I also got inspired by this question. Here is exactly what I've done: recast the two equations as one: $$\frac{\partial\rho}...
MaximeMaurice's user avatar
2 votes

Numerical artefacts in solution of spherical heat equation using FDM

You may simply change ...
ConvexHull's user avatar
  • 1,335
2 votes

Solving simplified 1D plasma fluid equations with finite difference

Your equations can be rewritten as $$ \frac{\partial \bf{U}}{\partial t} + \frac{\partial \left(u \bf{U}\right)}{\partial x} = \bf{F} $$ where ${\bf U} = \left[n, nu\right]^T$ and ${\bf F} = \left[0, ...
Sthavishtha Bhopalam's user avatar
2 votes
Accepted

Modeling contamination diffusion in a draining container

If you are negleting the fact the the level of the flow gets lower as the bottle drains, then you are implicitly assuming that new water comes into the domain at speed $v$. Since the analyte inflows ...
Rigel's user avatar
  • 419
2 votes
Accepted

Modeling contamination diffusion in a draining container, part 2

The condition you need for the top boundary is a Neumann condition, because the contaminant is entering into the domain at a prescribed rate. The condition is obtained be equating the diffusive flow ...
Rigel's user avatar
  • 419
2 votes

Automatic Differentiation In the Presence of Jump Points

What you call Automatic Differentiation is apparently a method for evaluating the derivative (gradient) of Ef(x), where E is mathematical expectation, by intechanging the order of differentiation and ...
Mark L. Stone's user avatar
2 votes
Accepted

How to address the element face adjacent to boundaries when the finite difference method and marker-and-cell scheme are used to solve the Stokes flow?

The paper is not specifying a Dirichlet $v=0$ at $y=1$, but $u=u_D$ at $y=1$. This could be used as a wall slip condition: for $u_D=0$, you have a no slip boundary wall; that is, the flow tangential ...
helloworld922's user avatar
2 votes

Finite Difference method, ADI Scheme of Douglas and Rachford

The purpose of ADI schemes is to separate some differential operators in order to make it easier to advance the solution in time with respect to what it would be with a fully implicit scheme, while ...
Rigel's user avatar
  • 419

Only top scored, non community-wiki answers of a minimum length are eligible