summaryrefslogtreecommitdiff
path: root/test/roots.t.c
blob: 632832adfba5b3f7d1a5a285c502a9e016e8629a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "lizfcm.test.h"
#include <stdio.h>

double g(double x) { return x * x - 9; }

UTEST(ivt, find_interval) {
  double *range = find_ivt_range(&g, -100.0, 1.0, 200);
  EXPECT_LT(g(range[0]) * g(range[1]), 0);

  free(range);
}

UTEST(root, bisection_with_error_assumption) {
  double root = bisect_find_root_with_error_assumption(&g, -5, 0, 0.01);

  EXPECT_NEAR(-3, root, 0.01);
}