-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbalanced.tex
More file actions
79 lines (68 loc) · 2.35 KB
/
balanced.tex
File metadata and controls
79 lines (68 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage{fancyvrb}
\DefineVerbatimEnvironment{code}{Verbatim}{fontsize=\small}
\DefineVerbatimEnvironment{example}{Verbatim}{fontsize=\small}
\newcommand{\ignore}[1]{}
\title{On general balanced trees}
\author{Slavomir Kaslev}
\begin{document}
\maketitle
\section{Definition}
General balanced trees are trees with all internal nodes having at least one
child and all leafs being equidistant from the root. Using algebraic data types,
one would define them as
\begin{code}
data F a = F0 a | F1 (F (G a))
data G a = G0 a | G1 a (G a)
\end{code}
or equivalently using generalized algebraic data types
\begin{code}
data F a where
F0 :: a -> F a
F1 :: F (G a) -> F a
data G a where
G0 :: a -> G a
G1 :: a -> G a -> G a
\end{code}
\section{Generating function}
The generating function $f(x)$ of general balanced trees satisfies the equations
\begin{align*}
f(x) &= x + f(g(x)) \\
g(x) &= x + x g(x)
\end{align*}
By noticing that $g(x) = \frac{x}{1-x}$ we can rewrite it as a single equation
\begin{equation}
f(x) = x + f(\frac{x}{1-x})\label{eq:eq1}
\end{equation}
The solution to \eqref{eq:eq1} is
\begin{equation}
f(x) = \frac{d}{dx}\ln\Gamma(-\frac{1}{x})\label{eq:eq2}
\end{equation}
or written in terms of the digamma function $\psi(x) = \frac{d}{dx}\ln\Gamma(x)
= \frac{\Gamma^\prime(x)}{\Gamma(x)}$
$$f(x) = \psi(-\frac{1}{x})$$
\section{Proof}
A quick proof starts with the functional equation of the gamma function
$$\Gamma(x+1) = x \Gamma(x)$$
Taking logarithm of both sides of the equation
$$\ln\Gamma(x+1) = \ln(x) + \ln\Gamma(x)$$
and differentiating gives
$$\frac{d}{dx}\ln\Gamma(x+1) = \frac{1}{x} + \frac{d}{dx}\ln\Gamma(x)$$
By substituting $x \to -\frac{1}{x}$ and rearranging terms we obtain
$$\frac{d}{dx}\ln\Gamma(-\frac{1}{x}) = x + \frac{d}{dx}\ln\Gamma(1-\frac{1}{x})$$
Since $g(x) = \frac{x}{1-x}$ we know that $1-\frac{1}{x} = -\frac{1}{g(x)}$ and
therefore we have
$$\frac{d}{dx}\ln\Gamma(-\frac{1}{x}) = x + \frac{d}{dx}\ln\Gamma(-\frac{1}{g(x)})$$
Finally, the substitution $f(x) = \frac{d}{dx}\ln\Gamma(-\frac{1}{x})$ brings us
to our original equation
\begin{align*}
f(x) &= x + f(g(x)) \\
g(x) &= x + x g(x)
\end{align*}
\end{document}