13 votes
Accepted

How Jacobian matrix helps optimization faster?

You haven't told us exactly what optimization routine you're using, so it's difficult to provide a very specific answer to your question. However, if you don't supply your own Jacobian function ...
Brian Borchers's user avatar
11 votes
Accepted

How to calculate/derive analytic FEM Newton Jacobian

Your example is a pretty good indication that the two derivatives (with respect to $x$ and with respect to $u$) do not commute :) (In fact, they're very different beasts -- one is a Fr├ęchet derivative,...
Christian Clason's user avatar
9 votes
Accepted

Number of function calls and jacobian calls in scipy.root

At the point where you print out the Jacobian, adding traceback.print_stack() reveals that the first evaluation comes from ...
jdgleeson's user avatar
  • 376
7 votes
Accepted

Sanity checking jacobians for Finite Element code

Like with any other thing you want to test, you need to come up with a list of situations where you know that something is true, and then check this. In many cases, knowing that something is true does ...
Wolfgang Bangerth's user avatar
7 votes

Specifying ode solver options to speed up compute time

Julia's DifferentialEquations.jl has a lot of tooling for automatically deriving (sparse) matrices. For more information, see the JuliaCon 2020 video on Auto-Optimization and Parallelism in ...
Chris Rackauckas's user avatar
6 votes
Accepted

Why can bad jacobians sometimes works better for implicit ODE method?

Finite difference approximations of the Jacobian are really only good if the step lengths are chosen appropriately for each coordinate. But a black-box solver like CVODE has no way of knowing what ...
Wolfgang Bangerth's user avatar
6 votes

Does the limit of $\frac{\partial f}{\partial u}$ at $u=0$ exist?

Given that $u \frac{\tau^2}{2} \ll 1$, one way of tackling the numerical oscillations, even before the actual term emerges, is a Taylor approximation in $u$ of the sine term (Thanks to Kirill for the ...
Max Herrmann's user avatar
6 votes

Implementation of the Jacobian-free Newton method

Not sure where you get your equation for $\epsilon$, but ultimately your approximation for the Jacobian matvec operation is a finite difference approximation to the directed derivative of $F(\cdot)$. ...
spektr's user avatar
  • 4,238
5 votes
Accepted

How to verify solution to pre-conditioned linear systems solver?

You've started with a singular linear system of equations $Ax=b$. As a practical matter, it's unlikely that $b$ lies exactly in the range of $A$, so at best you can find a least squares solution that ...
Brian Borchers's user avatar
5 votes

Sanity checking jacobians for Finite Element code

Well, the first obvious test is to check if the determinant of the Jacobian matrix is positive. If it not, it means that your element has inverted and your answer is going to be invalid. Otherwise, I ...
BlaB's user avatar
  • 1,157
5 votes

Solving stiff ODEs: Dealing with Jacobian terms which take too long to compute with finite differences

My first question: Will split ODE solvers likely work for my problem? From your description, this sounds like a textbook use-case for a split ODE solver. Neither an implicit method nor an explicit ...
Steven Roberts's user avatar
5 votes

Spot redundant equations within nonlinear system of equations

In the example you give, the two equations are not redundant. Each of the two equations describes a set of lines in the 2d plane, and the lines happen to be tangential at a specific point -- which is ...
Wolfgang Bangerth's user avatar
4 votes

Specifying ode solver options to speed up compute time

It looks like you have a advection diffusion PDE discretized with finite differences. This gives an ODE of the form $$ y' = f(y) = A y + D y, $$ where $A$ is the discretized advection operator and $D$...
Steven Roberts's user avatar
4 votes

Step size constraint in Euler backward

This answer is about illustrating the comments on the structure of the Jacobian, the resulting Lipschitz constant and its consequences on the step size. There are only two non-zero entries per row ...
Lutz Lehmann's user avatar
  • 6,064
3 votes

Calculating the Jacobian for a function containing a derivative

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 $\...
spektr's user avatar
  • 4,238
3 votes
Accepted

solving differential equations with jacobian pattern

This problem is too small to actually be sparse. Sparse handling has a big overhead because the indexing is not "direct", i.e. you don't necessarily know where the next value will be without ...
Chris Rackauckas's user avatar
3 votes
Accepted

Method of Lines: How to simplify Jacobian with periodic BCs?

If your advection problem had Dirichlet of Neumann boundary conditions, the linear system would be tridiagonal and you could apply the Thomas algorithm. With periodic boundary conditions, however, we ...
Steven Roberts's user avatar
3 votes

Implementation of the Jacobi iteration to find the solution to $Ax = b$

In your case (line 12 in your code) $$A = D-R.$$ Then $$ \begin{aligned} A\mathbf{x} {}&{}= D\mathbf{x}-R\mathbf{x}\\ {}&{}= \mathbf{b}\,, \end{aligned}$$ which rearranges to $$\...
Steve's user avatar
  • 541
3 votes

How to calculate/derive analytic FEM Newton Jacobian

You need to understand how to actually compute derivatives when you want to take the derivative with respect to a function. I've recorded a lengthy example in lecture 31.55 here: http://www.math....
Wolfgang Bangerth's user avatar
2 votes

How to verify solution to pre-conditioned linear systems solver?

If you don't care too much about which $b$ you're working with (say just for linear algebra), then you can use the Method of Manufactured Solutions (MMS) in Linear Algebra much like we differential ...
Bill Barth's user avatar
  • 10.9k
2 votes
Accepted

Confusion about determining the jacobian in a rootfinding algorithm

If you look at the full output of your script, sol has fields ipvt and qtf. Both of these ...
Kirill's user avatar
  • 11.4k
2 votes
Accepted

Debugging Newton-method used in a CG-approach

You're using a backward Euler finite difference time stepping method. This is stable, but only first order accurate, so I suspect explains the discrepancy in the reduction factor. More explicitly, ...
origimbo's user avatar
  • 2,249
2 votes
Accepted

Does the k-th approximate solution of a stationary iteration belong to the k-th Krylov subspace?

Taking $x_0 = 0$, we have that $x_1 \in <M^{-1}b>$. For the next iteration, we get $x_2 \in <M^{-1}b, M^{-1}AM^{-1}b>$. For the next iteration, we get $x_3 \in <M^{-1}b, (M^{-1}A)^2M^{...
Thijs Steel's user avatar
  • 1,693
2 votes
Accepted

Calculating the jacobian of norm and square root terms in the Finite Element Method

You can arrive at the Jacobian analytically it just takes a few steps So assuming we have our typical FE field values: $$ u_i = \sum_j \phi^j u_i^j $$ Where $i$ represents coordinate direction, $\...
wwfe's user avatar
  • 66
2 votes
Accepted

Solving differential equation by specifying jacobian pattern

odenumjac calls your function in a vectorized manner it seems, and your function is not vectorized. You can easily change that by changing the second index of f in ...
Laurent90's user avatar
  • 1,868
2 votes

Number of function calls and jacobian calls in scipy.root

Studying your code and comparing it with the provided system of nonlinear equations, there is an error in the following code snippet. ...
Carllos Limma's user avatar
2 votes
Accepted

Jacobian for 6-noded triangle in 3D to calculate the area

Assuming an isoparametric formulation and using the shape functions you show in your post, you can write $x=N_ix_i, y=N_iy_i$, and $x=N_iz_i$ where $x_i, y_i$, and $z_i$ are the coordinates of the six ...
Bill Greene's user avatar
  • 6,064
1 vote

Calculating Lyapunov exponent (LE) for pendulum using ellipsoid growth - code yields negative LEs

In this second part, I reuse the first code inserted above to calculate the Lyapunov exponents (Graph 1) and the sensitivity of the system regarding the imposed conditions (Graph 2). In this code, I ...
Carllos Limma's user avatar
1 vote

Calculating Lyapunov exponent (LE) for pendulum using ellipsoid growth - code yields negative LEs

Good morning, good afternoon or good night :-). I made two programs in octave on the subject of forced pendulum, as described in my physics lab (website, Chaotic Pendulum: https://www.myphysicslab.com/...
Carllos Limma's user avatar

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