diff --git a/ca.h b/ca.h
index 0a12216..60af7e7 100644
--- a/ca.h
+++ b/ca.h
@@ -317,6 +317,8 @@ void ca_pi(ca_t res, ca_ctx_t ctx);
void ca_pi_i(ca_t res, ca_ctx_t ctx);
void ca_euler(ca_t res, ca_ctx_t ctx);
+void ca_tribonacci_constant(ca_t res, ca_ctx_t ctx);
+
void ca_unknown(ca_t x, ca_ctx_t ctx);
void ca_undefined(ca_t x, ca_ctx_t ctx);
diff --git a/ca/set_fexpr.c b/ca/set_fexpr.c
index b103a59..79f5a6e 100644
--- a/ca/set_fexpr.c
+++ b/ca/set_fexpr.c
@@ -79,6 +79,9 @@ _ca_set_fexpr(ca_t res, fexpr_vec_t inputs, ca_vec_t outputs, const fexpr_t expr
ca_add_ui(res, res, 1, ctx);
ca_div_ui(res, res, 2, ctx);
return 1;
+ case FEXPR_TribonacciConstant:
+ ca_tribonacci_constant(res, ctx);
+ return 1;
case FEXPR_Infinity:
ca_pos_inf(res, ctx);
return 1;
diff --git a/ca/tribonacci.c b/ca/tribonacci.c
new file mode 100644
index 0000000..f9c8fca
--- /dev/null
+++ b/ca/tribonacci.c
@@ -0,0 +1,24 @@
+/*
+ Copyright (C) 2022 Raoul Bourquin
+
+ This file is part of Calcium.
+
+ Calcium is free software: you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License (LGPL) as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version. See .
+*/
+
+#include "ca.h"
+
+void
+ca_tribonacci_constant(ca_t res, ca_ctx_t ctx)
+{
+ qqbar_t tc;
+ qqbar_init(tc);
+ qqbar_tribonacci_constant(tc);
+
+ ca_set_qqbar(res, tc, ctx);
+
+ qqbar_clear(tc);
+}
diff --git a/doc/source/bibliography.rst b/doc/source/bibliography.rst
index 2811a15..5816153 100644
--- a/doc/source/bibliography.rst
+++ b/doc/source/bibliography.rst
@@ -5,7 +5,7 @@ Bibliography
(In the PDF edition, this section is empty. See the bibliography listing at the end of the document.)
-All referenced works: [BBK2014]_, [BF2020]_, [BFSS2006]_, [Boe2020]_, [Car2004]_, [Cho1999]_, [Coh1996]_, [Coh2000]_, [Fie2007]_, [GCL1992]_, [Har2010]_, [Har2015]_, [Har2018]_, [Joh2017]_, [JR1999]_, [Mos1971]_, [MP2006]_, [RF1994]_, [Ric1992]_, [Ric1995]_, [Ric1997]_, [Ric2007]_, [Ric2009]_, [Ste2002]_, [Ste2010]_, [Str1997]_, [Str2012]_, [vdH1995]_, [vdH2006]_, [vHP2012]_, [Zip1985]_.
+All referenced works: [BBK2014]_, [BF2020]_, [BFSS2006]_, [Boe2020]_, [Car2004]_, [Cho1999]_, [Coh1996]_, [Coh2000]_, [Fie2007]_, [GCL1992]_, [Har2010]_, [Har2015]_, [Har2018]_, [Joh2017]_, [JR1999]_, [Mos1971]_, [MP2006]_, [RF1994]_, [Ric1992]_, [Ric1995]_, [Ric1997]_, [Ric2007]_, [Ric2009]_, [Ste2002]_, [Ste2010]_, [Str1997]_, [Str2012]_, [Wol1998]_, [vdH1995]_, [vdH2006]_, [vHP2012]_, [Zip1985]_.
.. [BBK2014] \D. H. Bailey, J. M. Borwein and A. D. Kaiser. "Automated simplification of large symbolic expressions". Journal of Symbolic Computation Volume 60, January 2014, Pages 120-136. https://doi.org/10.1016/j.jsc.2013.09.001
@@ -61,6 +61,8 @@ All referenced works: [BBK2014]_, [BF2020]_, [BFSS2006]_, [Boe2020]_, [Car2004]_
.. [Str2012] \A. Strzebonski. "Real root isolation for exp-log-arctan functions". Journal of Symbolic Computation 47 (2012) 282–314. https://doi.org/10.1016/j.jsc.2011.11.004
+.. [Wol1998] \D. A. Wolfram. "Solving Generalized Fibonacci Recurrences". The Fibonacci Quarterly 36 (1998) 129-145.
+
.. [vHP2012] \M. van Hoeij and V. Pal. "Isomorphisms of algebraic number fields". Journal de Théorie des Nombres de Bordeaux, Vol. 24, No. 2 (2012), pp. 293-305. https://doi.org/10.2307/43973105
.. [vdH1995] \J. van der Hoeven, "Automatic numerical expansions". Proc. of the conference Real numbers and computers (1995), 261-274. https://www.texmacs.org/joris/ane/ane-abs.html
diff --git a/doc/source/ca.rst b/doc/source/ca.rst
index 2cb01dc..ee01c55 100644
--- a/doc/source/ca.rst
+++ b/doc/source/ca.rst
@@ -349,6 +349,11 @@ Special values
Sets *res* to Euler's constant `\gamma`. This creates an element
of the (transcendental?) number field `\mathbb{Q}(\gamma)`.
+.. function:: void ca_tribonacci_constant(ca_t res, ca_ctx_t ctx)
+
+ Sets *res* to the Tribonacci constant `T_c`. This creates an element
+ of the algebraic number field `\mathbb{Q}(T_c)`.
+
.. function:: void ca_unknown(ca_t res, ca_ctx_t ctx)
Sets *res* to the meta-value *Unknown*.
diff --git a/doc/source/fexpr_builtin.rst b/doc/source/fexpr_builtin.rst
index 2a45cc7..13c9542 100644
--- a/doc/source/fexpr_builtin.rst
+++ b/doc/source/fexpr_builtin.rst
@@ -326,6 +326,10 @@ Particular numbers
``GoldenRatio`` is the golden ratio `\varphi`.
+.. macro:: TribonacciConstant
+
+ ``TribonacciConstant`` is the Tribonacci constant `T_c`.
+
.. macro:: Euler
``Euler`` is Euler's constant `\gamma`.
diff --git a/doc/source/qqbar.rst b/doc/source/qqbar.rst
index c4ae89c..4a27dd4 100644
--- a/doc/source/qqbar.rst
+++ b/doc/source/qqbar.rst
@@ -199,6 +199,10 @@ Special values
Sets *res* to the golden ratio `\varphi = \tfrac{1}{2}(\sqrt{5} + 1)`.
+.. function:: void qqbar_tribonacci_constant(qqbar_t res)
+
+ Sets *res* to the Tribonacci constant `T_c = \tfrac{1}{3}(1 + \sqrt[3]{19 + 3\sqrt{33}} + \sqrt[3]{19 - 3\sqrt{33}})`.
+
Input and output
-------------------------------------------------------------------------------
@@ -811,7 +815,7 @@ Symbolic expressions and conversion to radicals
* Arithmetic operations with algebraic operands
* Square roots of algebraic numbers
* Powers with algebraic base and exponent an explicit rational number
- * NumberI, GoldenRatio, RootOfUnity
+ * NumberI, GoldenRatio, TribonacciConstant, RootOfUnity
* Floor, Ceil, Abs, Sign, Csgn, Conjugate, Re, Im, Max, Min
* Trigonometric functions with argument an explicit rational number times Pi
* Exponentials with argument an explicit rational number times Pi * NumberI
diff --git a/examples/tribonacci.c b/examples/tribonacci.c
new file mode 100644
index 0000000..7eeaf8f
--- /dev/null
+++ b/examples/tribonacci.c
@@ -0,0 +1,64 @@
+/* This file is public domain. Author: Raoul Bourquin. */
+
+#include "ca.h"
+
+
+void main_fexpr()
+{
+ fexpr_t T;
+ fexpr_init(T);
+
+ flint_printf("Evaluating Tc as fexpr:\n");
+
+ fexpr_set_symbol_str(T, "TribonacciConstant");
+
+ fexpr_print(T);
+ printf("\n\n");
+
+ fexpr_clear(T);
+}
+
+
+void main_ca()
+{
+ ca_ctx_t ctx;
+ ca_t T;
+ ca_ctx_init(ctx);
+ ca_init(T, ctx);
+
+ flint_printf("Evaluating Tc as ca:\n");
+
+ ca_tribonacci_constant(T, ctx);
+
+ ca_print(T, ctx);
+ printf("\n\n");
+
+ ca_clear(T, ctx);
+}
+
+
+void main_qqbar()
+{
+ qqbar_t T;
+ qqbar_init(T);
+
+ flint_printf("Evaluating Tc as qqbar:\n");
+
+ qqbar_tribonacci_constant(T);
+
+ qqbar_printn(T, 50);
+ printf("\n");
+
+ qqbar_clear(T);
+}
+
+
+int main(int argc, char *argv[])
+{
+ main_fexpr();
+ main_ca();
+ main_qqbar();
+
+ flint_cleanup();
+ return EXIT_SUCCESS;
+}
diff --git a/fexpr/numerical_enclosure.c b/fexpr/numerical_enclosure.c
index e56d4f4..44cdd53 100644
--- a/fexpr/numerical_enclosure.c
+++ b/fexpr/numerical_enclosure.c
@@ -129,6 +129,52 @@ fexpr_get_acb_raw(acb_t res, const fexpr_t expr, slong prec)
return 1;
}
+ if (op == FEXPR_TribonacciConstant)
+ {
+ /* Subexpressions */
+ arb_t r33, r33p, r33m;
+
+ /* Init */
+ arb_init(r33);
+ arb_init(r33p);
+ arb_init(r33m);
+
+ /* r33 := 3*sqrt(33) */
+ arb_sqrt_ui(r33, 33, prec);
+ arb_mul_ui(r33, r33, 3, prec);
+
+ /* r33p := cbrt(19 + r33) */
+ arb_add_ui(r33p, r33, 19, prec);
+ arb_root_ui(r33p, r33p, 3, prec);
+
+ /* r33m := cbrt(19 - r33) */
+ arb_sub_si(r33m, r33, 19, prec);
+ arb_neg(r33m, r33m);
+ arb_root_ui(r33m, r33m, 3, prec);
+
+ /* res := 1 */
+ arb_one(acb_realref(res));
+
+ /* res += r33p */
+ arb_add(acb_realref(res), acb_realref(res), r33p, prec);
+
+ /* res += r33m */
+ arb_add(acb_realref(res), acb_realref(res), r33m, prec);
+
+ /* res /= 3 */
+ arb_div_ui(acb_realref(res), acb_realref(res), 3, prec);
+
+ /* zero imag part */
+ arb_zero(acb_imagref(res));
+
+ /* Free */
+ arb_clear(r33);
+ arb_clear(r33p);
+ arb_clear(r33m);
+
+ return 1;
+ }
+
acb_indeterminate(res);
return 0;
}
diff --git a/fexpr_builtin.h b/fexpr_builtin.h
index 2a7576a..3f7b42e 100644
--- a/fexpr_builtin.h
+++ b/fexpr_builtin.h
@@ -433,6 +433,7 @@ typedef enum
FEXPR_Tanh,
FEXPR_Theta,
FEXPR_Theta_,
+ FEXPR_TribonacciConstant,
FEXPR_True,
FEXPR_Tuple,
FEXPR_Tuples,
diff --git a/fexpr_builtin/table.c b/fexpr_builtin/table.c
index b0546e0..eb12f6c 100644
--- a/fexpr_builtin/table.c
+++ b/fexpr_builtin/table.c
@@ -415,6 +415,7 @@ const fexpr_symbol_info fexpr_builtin_table[FEXPR_BUILTIN_LENGTH] = {
{ FEXPR_Tanh, "Tanh", "\\tanh", NULL, },
{ FEXPR_Theta, "Theta", "\\Theta", NULL },
{ FEXPR_Theta_, "Theta_", "\\Theta", fexpr_write_latex_subscript },
+ { FEXPR_TribonacciConstant, "TribonacciConstant", "T_c", NULL, },
{ FEXPR_True, "True", "\\operatorname{True}", NULL, },
{ FEXPR_Tuple, "Tuple", "", fexpr_write_latex_collection, },
{ FEXPR_Tuples, "Tuples", "", NULL, },
diff --git a/qqbar.h b/qqbar.h
index 29eb581..30c7493 100644
--- a/qqbar.h
+++ b/qqbar.h
@@ -207,6 +207,8 @@ void qqbar_i(qqbar_t res);
void qqbar_phi(qqbar_t res);
+void qqbar_tribonacci_constant(qqbar_t res);
+
/* Random generation */
void qqbar_randtest(qqbar_t res, flint_rand_t state, slong deg, slong bits);
diff --git a/qqbar/set_fexpr.c b/qqbar/set_fexpr.c
index 0fc2152..6fbc6ab 100644
--- a/qqbar/set_fexpr.c
+++ b/qqbar/set_fexpr.c
@@ -598,6 +598,12 @@ qqbar_set_fexpr(qqbar_t res, const fexpr_t expr)
return 1;
}
+ if (fexpr_is_builtin_symbol(expr, FEXPR_TribonacciConstant))
+ {
+ qqbar_tribonacci_constant(res);
+ return 1;
+ }
+
return 0;
}
diff --git a/qqbar/tribonacci.c b/qqbar/tribonacci.c
new file mode 100644
index 0000000..967b1c2
--- /dev/null
+++ b/qqbar/tribonacci.c
@@ -0,0 +1,63 @@
+/*
+ Copyright (C) 2022 Raoul Bourquin
+
+ This file is part of Calcium.
+
+ Calcium is free software: you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License (LGPL) as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version. See .
+*/
+
+#include "qqbar.h"
+
+void
+qqbar_tribonacci_constant(qqbar_t res)
+{
+ /* Subexpressions */
+ arb_t r33, r33p, r33m;
+
+ fmpz_poly_zero(QQBAR_POLY(res));
+ fmpz_poly_set_coeff_si(QQBAR_POLY(res), 3, 1);
+ fmpz_poly_set_coeff_si(QQBAR_POLY(res), 2, -1);
+ fmpz_poly_set_coeff_si(QQBAR_POLY(res), 1, -1);
+ fmpz_poly_set_coeff_si(QQBAR_POLY(res), 0, -1);
+
+ /* Init */
+ arb_init(r33);
+ arb_init(r33p);
+ arb_init(r33m);
+
+ /* r33 := 3*sqrt(33) */
+ arb_sqrt_ui(r33, 33, QQBAR_DEFAULT_PREC);
+ arb_mul_ui(r33, r33, 3, QQBAR_DEFAULT_PREC);
+
+ /* r33p := cbrt(19 + r33) */
+ arb_add_ui(r33p, r33, 19, QQBAR_DEFAULT_PREC);
+ arb_root_ui(r33p, r33p, 3, QQBAR_DEFAULT_PREC);
+
+ /* r33m := cbrt(19 - r33) */
+ arb_sub_si(r33m, r33, 19, QQBAR_DEFAULT_PREC);
+ arb_neg(r33m, r33m);
+ arb_root_ui(r33m, r33m, 3, QQBAR_DEFAULT_PREC);
+
+ /* res := 1 */
+ arb_one(acb_realref(QQBAR_ENCLOSURE(res)));
+
+ /* res += r33p */
+ arb_add(acb_realref(QQBAR_ENCLOSURE(res)), acb_realref(QQBAR_ENCLOSURE(res)), r33p, QQBAR_DEFAULT_PREC);
+
+ /* res += r33m */
+ arb_add(acb_realref(QQBAR_ENCLOSURE(res)), acb_realref(QQBAR_ENCLOSURE(res)), r33m, QQBAR_DEFAULT_PREC);
+
+ /* res /= 3 */
+ arb_div_ui(acb_realref(QQBAR_ENCLOSURE(res)), acb_realref(QQBAR_ENCLOSURE(res)), 3, QQBAR_DEFAULT_PREC);
+
+ /* zero imag part */
+ arb_zero(acb_imagref(QQBAR_ENCLOSURE(res)));
+
+ /* Free */
+ arb_clear(r33);
+ arb_clear(r33p);
+ arb_clear(r33m);
+}