This commit is contained in:
2020-11-03 21:41:30 +01:00
parent db4a3ea3d6
commit a1624d6c29
2 changed files with 10 additions and 8 deletions
@@ -21,15 +21,17 @@ public:
// Funktionsauswertung // Funktionsauswertung
void F (const hdnum::Vector<N>& x, hdnum::Vector<N>& result) const void F (const hdnum::Vector<N>& x, hdnum::Vector<N>& result) const
{ {
result[0] = pow(x[0], 2) + pow(x[1], 2) - 4; result[0] = x[0] * x[1] + 2*x[0] - x[1] - 2;
result[1] = pow(x[0], 2)/9 + pow(x[1], 2) - 1; result[1] = x[0] * x[1] - x[0] + x[1] -3;
} }
// Jacobimatrix // Jacobimatrix
void F_x (const hdnum::Vector<N>& x, hdnum::DenseMatrix<N>& result) const void F_x (const hdnum::Vector<N>& x, hdnum::DenseMatrix<N>& result) const
{ {
result[0][0] = 2*x[0]; result[0][1] = 2*x[1]; result[0][0] = x[1] + 2;
result[1][0] = 2*x[0]/9; result[1][1] = 2*x[1]; result[0][1] = x[0] - 1;
result[1][0] = x[1] - 1;
result[1][1] = x[0] + 1;
} }
}; };
@@ -48,13 +50,13 @@ int main ()
// Newton // Newton
hdnum::Newton newton; hdnum::Newton newton;
newton.set_maxit(20); newton.set_maxit(20);
newton.set_verbosity(2); newton.set_verbosity(10);
newton.set_reduction(1e-10); newton.set_reduction(1e-10);
newton.set_abslimit(1e-20); newton.set_abslimit(1e-20);
newton.set_linesearchsteps(3); newton.set_linesearchsteps(2);
// 1. Quadrant // 1. Quadrant
u[0] = 2.0; u[1] = 1.0; u[0] = 0.0; u[1] = 1.0;
newton.solve(problem,u); newton.solve(problem,u);
std::cout << "Nullstelle im 1. Quadrant: " << std::setprecision(15) << u << std::endl; std::cout << "Nullstelle im 1. Quadrant: " << std::setprecision(15) << u << std::endl;
problem.F(u, result); problem.F(u, result);