Commit 836e82fe authored by Taddeüs Kroes's avatar Taddeüs Kroes

Corrected derivatives.

parent c9d726c9
......@@ -14,7 +14,7 @@ double f1(double x) {
}
double df1(double x) {
return x / 2 - 1;
return 2 * x - 1;
}
double f2(double x) {
......@@ -22,7 +22,7 @@ double f2(double x) {
}
double df2(double x) {
return (x * x) / 3 - 3;
return 3 * x * x - 3;
}
double f3(double x) {
......@@ -30,11 +30,9 @@ double f3(double x) {
}
double df3(double x) {
return (x * x + 1) + (x / 2) * (x - 4);
return (x * x + 1) + 2 * x * (x - 4);
}
#define TEST(i) (printf("f1: %.11f\n", &f(i), &df(i), 1))
int main(void) {
printf("f1: %.11f\n", newton(&f1, &df1, 1));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment