People who code: we want your input. Take the Survey

New answers tagged

3

There are some unknowns in what you are doing but for simplicity, suppose we want to find $u(t)$ as discrete times $t_1, t_2, \cdots, t_n$. Let $\textbf{F} = [F(t_1), F(t_2), \cdots, F(t_n)]^T$ and $\textbf{u} = [u(t_1), u(t_2), \cdots, u(t_n)]^T$ be column vectors representing $F$ and $u$ evaluated at the desired times. From your problem statement, you wish ...


2

This is a (FDM) supplement to VoB's answer. You could write an extremely vectorized and optimized solver for your problem, but that is not a good first idea. Writing a for loop is easier, and once you identify the opportunities for optimization, you can implement them. Here is how I would go about it (in pseudo-code): Assume $0\leq i\leq n$ and $0\leq j\leq ...


3

Probably not what OP was waiting for, but I think it could be pretty instructive and useful. FEM codes use a much different approach to build the so-called stiffness matrix. In practice, they loop over elements and compute for each element small matrices (in your case if you use linear elements 3by3) which are distributed to the right entries of the global ...


0

Consider a scheme written on paper $$ u^{n+1} = H(u^n) $$ On a computer we have finite precision and round off error, so a computer computes $$ v^{n+1} = \bar H (v^n) $$ Note that $H$ and $\bar H$ are different. let $$ u = v + \epsilon $$ Then roundoff error $\epsilon$ satisfies $$ \epsilon^{n+1} = u^{n+1} - v^{n+1} = H(u^n) - \bar H(v^n) = [H(v^n) - \bar H(...


1

The stability analysis is made considering two close trajectories, if the difference between the state is guaranteed to reduce after one iteration, it means that the method is stable, the numerical errors introduced in one iteration (rounding errros) will not accumulate. The numerical solutions satisfy the equation $$ u_i^{k+1} = r\,(u_{i+1}^k + u_{i+1}^k) + ...


3

Indeed, the roundoff error is much lower with the complex step approach, because all the derivative terms are handled in the imaginary part, without direct interaction with the real part, as opposed to a finite difference calculation. The advantage of complex step is that you can take a very low perturbation size $h$ (I usually use $10^{-50}$), whereas you ...


Top 50 recent answers are included