diff --git a/SCE/SCE/SCE.cpp b/SCE/SCE/SCE.cpp index 1069232..5dae522 100644 --- a/SCE/SCE/SCE.cpp +++ b/SCE/SCE/SCE.cpp @@ -5,6 +5,7 @@ using namespace std; void cylinder(); void lgs(); +void nlgs(); int main() { @@ -14,6 +15,7 @@ int main() cout << "Was wollen Sie tun ?" << endl; cout << "1 Berechungen an einem Zylinder" << endl; cout << "2 LGS loesen" << endl; + cout << "3 n.LGS loesen" << endl; cout << "e Beenden" << endl; @@ -22,6 +24,7 @@ int main() { case '1': cylinder(); break; case '2': lgs(); break; + case '3': nlgs(); break; default: cout << "Okay, bye" << endl; break; } @@ -44,3 +47,7 @@ void lgs() cout << lgs.cramer(); cout << endl; } +void nlgs() +{ + +} diff --git a/SCE/SCE/nlgs.cpp b/SCE/SCE/nlgs.cpp new file mode 100644 index 0000000..811cba6 --- /dev/null +++ b/SCE/SCE/nlgs.cpp @@ -0,0 +1,34 @@ +#include "nlgs.h" +#include "math.h" +#include +using namespace std; + + +long double nlgs::function(long double x) +{ + return (pow(x, 4) - x - 10); +} + +long double nlgs::round(long double x, int acc) +{ + x = x * pow(10, acc); + int temp = x; + x = temp; + x = x / pow(10, acc); + return x; +} + +float nlgs::bisektion(long double A, long double B , int limit, int acc) +{ + long double a = A; + long double b = B; + long double c; + for (int i = limit; i--;) + { + c = (a + b) / 2; + c = round(c, acc); + if (function(a)*function(c) > 0) { a = c; } + if (function(c)*function(b) > 0) { b = c; } + } +} + diff --git a/SCE/SCE/nlgs.h b/SCE/SCE/nlgs.h new file mode 100644 index 0000000..0381292 --- /dev/null +++ b/SCE/SCE/nlgs.h @@ -0,0 +1,15 @@ +#pragma once +class nlgs +{ +private: + long double function(long double); + long double round(long double, int); +public: + float bisektion(long double, long double, int, int ); //a, b, number of iterations, accuracy + float fixedpoint(); + float newton(); + float secant(); + nlgs(){}; + ~nlgs(){}; +}; +