flavis 5 lat temu
rodzic
commit
a1624d6c29
2 zmienionych plików z 10 dodań i 8 usunięć
  1. +1
    -1
      sose2020/ana/lectures
  2. +9
    -7
      sose2020/num/uebungen/prog_nonlinear_solvers_methods.cc

+ 1
- 1
sose2020/ana/lectures

@@ -1 +1 @@
Subproject commit 4a8568092d61277a96481f294464fd68434f90a5
Subproject commit 12c3f170e2da580b7037c48fa9a84dfe481ea40a

+ 9
- 7
sose2020/num/uebungen/prog_nonlinear_solvers_methods.cc Wyświetl plik

@@ -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[1] = pow(x[0], 2)/9 + pow(x[1], 2) - 1;
result[0] = x[0] * x[1] + 2*x[0] - x[1] - 2;
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[1][0] = 2*x[0]/9; result[1][1] = 2*x[1];
result[0][0] = x[1] + 2;
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);


Ładowanie…
Anuluj
Zapisz