I haven't touched this in a while.
[frac.git] / famous_test.c
blob6f9b95194f93d7483b0b8d8a85c72d64fb0acd40
1 // Test famous continued fraction expansions are correct.
2 // as well as expansions based on Taylor series.
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include <gmp.h>
8 #include "cf.h"
9 #include "test.h"
11 int main() {
12 CF_NEW_EXPECT_DEC(cf_new_sqrt2, "1.41421356237309504880");
13 CF_NEW_EXPECT_DEC(cf_new_e, "2.71828182845904523536");
14 CF_NEW_EXPECT_DEC(cf_new_pi, "3.1415926535897932384");
15 CF_NEW_EXPECT_DEC(cf_new_tan1, "1.5574077246549022305");
16 CF_NEW_EXPECT_DEC(cf_new_sin1, "0.8414709848078965066");
17 CF_NEW_EXPECT_DEC(cf_new_cos1, "0.5403023058681397174");
19 mpz_t z;
20 mpz_init(z);
21 cf_t x;
23 mpz_set_si(z, 3);
24 x = cf_new_tanh(z);
25 CF_EXPECT_DEC(x, "0.99505475368673045133188018525548847509781385470028");
26 cf_free(x);
28 mpz_set_ui(z, 2);
29 x = cf_new_epow(z);
30 CF_EXPECT_DEC(x, "7.38905609893065022723042746057500781318031557055184");
31 cf_free(x);
33 mpz_clear(z);
34 return 0;