newton solver for polynomial

This commit is contained in:
2021-06-12 17:49:43 +02:00
parent f03953ba2d
commit 73aed62650
3 changed files with 51 additions and 12 deletions

View File

@@ -142,6 +142,22 @@ return p;
}
template <typename T>
T Polynomial<T>::newton(const T x0, const typename LA_traits<T>::normtype thr, const int maxit) const
{
Polynomial<T> d=derivative(1);
T x=x0;
for(int i=0; i<maxit; ++i)
{
T v=value(*this,x);
if(abs(v)<thr) break;
x -= v/value(d,x);
}
return x;
}
/***************************************************************************//**