# Newton Stopping criteria

Hi,

I am trying to implement a Newton method with the stopping criterium as the l2 norm of the residual from the non-linear form. However, when the norm of the residual is computed in each iteration

```a.Apply(gfu.vec, res) print("\t||res||_l2 = {:}".format(sqrt(InnerProduct(res,res))))```
this does not converge to zero, even though the method converges (in the dual norm) and the update disappears. I have attached a MWE, (minimal adaptation of the iTutorial 3.7 on Nonlinear Problems).

As we are trying to solve a(u[sub]h[/sub],v[sub]h[/sub])=0, the residual ||a(u[sub]h[/sub][sup]i[/sup], v[sub]h[/sub]) ||[sub]l2[/sub] = ||res ||[sub]l2[/sub] should converge towards zero. Doe anyone know, what is going wrong here?

Best wishes,
Henry

Attachment: NewtonResiualMWE.py

Hi Henry,

The application of the bilinearform does not care about dirichlet dofs. Hence, your res-vector may have (has) non-zero entries which however have no impact on your iterate. This is what you see in your MWE. You should Project the dirichlet dofs out.

Best,
Christoph

Thank you Christoph!

Is there a better way for projecting out the Dirichlet Dofs than going for

``res.FV().NumPy()[V.FreeDofs()]``

?

Best wishes,
Henry

Hi,

You can use the Projector object. You provide a BitArray (in your case the freedofs-array) and a flag true/false. The result is a linear operator (basematrix). You can then apply the projector on a vector as any other basematrix object. The result will set the entries to zero wherever the BitArray is true/flase (depending on the flag you provided).

Best,
Christoph

Hi,

Thank you! I wasnâ€™t aware of this object before. Using the projector has also resulted in the whole script running slightly faster !

Best wishes,
Henry