Commit b2012cb0 authored by Taddeüs Kroes's avatar Taddeüs Kroes

Fixed printf() parameter issue.

parent 66f10d33
...@@ -7,10 +7,9 @@ double func(double x) { ...@@ -7,10 +7,9 @@ double func(double x) {
return x * sin(x) - 1; return x * sin(x) - 1;
} }
#define BISEC(exponent) (bisec(&func, 0, 2, pow(10, -1.0 * exponent), &steps))
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
unsigned int steps, i, begin, end; unsigned int steps, i, begin, end;
double bisection;
if( argc != 3 ) { if( argc != 3 ) {
printf("Usage: %s BEGIN END\n", argv[0]); printf("Usage: %s BEGIN END\n", argv[0]);
...@@ -20,8 +19,10 @@ int main(int argc, char *argv[]) { ...@@ -20,8 +19,10 @@ int main(int argc, char *argv[]) {
begin = atoi(argv[1]); begin = atoi(argv[1]);
end = atoi(argv[2]); end = atoi(argv[2]);
for( i = begin; i <= end; i++ ) for( i = begin; i <= end; i++ ) {
printf("zero point: %.30f for epsilon = 1e-%d (%d steps)\n", BISEC(i), i, steps); bisection = bisec(&func, 0, 2, pow(10, -1.0 * i), &steps);
printf("zero point: %.30f for epsilon = 1e-%d (%d steps)\n", bisection, i, steps);
}
return 0; return 0;
} }
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