delete secant method - it is identical to regula falsi

This commit is contained in:
Krishna Vedala 2020-05-28 22:48:52 -04:00
parent 29bdf4438b
commit 68cf8540a1
No known key found for this signature in database
GPG Key ID: BA19ACF8FC8792F7

View File

@ -1,37 +0,0 @@
#include <cmath>
#include <iostream>
static float eq(float i) {
return (pow(i, 3) - (4 * i) - 9); // original equation
}
int main() {
float a, b, z, c, m, n;
for (int i = 0; i < 100; i++) {
z = eq(i);
if (z >= 0) {
b = i;
a = --i;
break;
}
}
std::cout << "\nFirst initial: " << a;
std::cout << "\nSecond initial: " << b;
for (int i = 0; i < 100; i++) {
float h, d;
m = eq(a);
n = eq(b);
c = ((a * n) - (b * m)) / (n - m);
a = b;
b = c;
z = eq(c);
if (z > 0 && z < 0.09) // stoping criteria
break;
}
std::cout << "\n\nRoot: " << c;
return 0;
}