41 lines
968 B
C++
Executable File
41 lines
968 B
C++
Executable File
#include <math.h>
|
|
#include "CMyVektor.h"
|
|
#include "CMyMatrix.h"
|
|
|
|
using namespace std;
|
|
|
|
// f( [x,y] ) = sin(x * y) + sin(x) + cos(y)
|
|
double ff(CMyVektor X) {
|
|
double x = X[0];
|
|
double y = X[1];
|
|
|
|
return (sin(x * y) + sin(x) + cos(y));
|
|
}
|
|
|
|
// g( [x,y,z] ) = -(2x^2 - 2xy + y^2 + z^2 - 2x - 4z)
|
|
double gg(CMyVektor X) {
|
|
double x = X[0];
|
|
double y = X[1];
|
|
double z = X[2];
|
|
|
|
return -(2 * pow(x, 2) - 2 * x * y + pow(y, 2) + pow(z, 2) - 2 * x - 4 * z);
|
|
}
|
|
|
|
CMyVektor f(CMyVektor x) {
|
|
CMyVektor result(3); // da f: R^4 -> R^3
|
|
result[0] = x[0] * x[1] * exp(x[2]);
|
|
result[1] = x[1] * x[2] * x[3];
|
|
result[2] = x[3];
|
|
return result;
|
|
}
|
|
|
|
int main() {
|
|
|
|
cout << "Aufgabe_2 :\n" << jacobi(CMyVektor{ {1, 2, 0, 3} },
|
|
[](CMyVektor x) -> CMyVektor { return { {x[0] * x[1] * exp(x[2]), x[1] * x[2] * x[3], x[3]} }; })
|
|
<< endl;
|
|
|
|
newtonverfahren({ {1, 1} },
|
|
[](CMyVektor x) -> CMyVektor { return { {pow(x[0], 3) * pow(x[1], 3) - 2 * x[1], x[0] - 2} }; });
|
|
return 0;
|
|
} |