-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheuler-q.C
141 lines (117 loc) · 3.19 KB
/
euler-q.C
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
* euler-q.C
*
* FUNCTION:
* Display euler q-series aka dedekind eta,
*
* HISTORY:
* quick hack -- Linas Vepstas October 1989
* modernize -- Linas Vepstas March 1996
* more stuff -- January 2000
* more stuff -- October 2004
*/
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "brat.h"
#include "coord-xforms.h"
#include "modular.h"
double bernoulli_zeta (double re_q, double im_q)
{
double rep, imp;
int n;
rep = 0.0;
imp = 0.0;
double nre = re_q;
double nim = im_q;
double tp = 0.5;
for (n=1; n<1000; n++)
{
rep += nre / (1.0-tp);
imp += nim / (1.0-tp);
tp *= 0.5;
double tmp = nre * re_q - nim * im_q;
nim = nre * im_q + nim * re_q;
nre = tmp;
if (nre*nre+nim*nim < 1.0e-14) break;
}
return sqrt (rep*rep+imp*imp);
}
double euler_prod (double re_q, double im_q)
{
double rep, imp;
euler_prod_c (re_q, im_q, &rep, &imp);
return sqrt (rep*rep+imp*imp);
}
double dedekind_eta (double re_q, double im_q)
{
double rep, imp;
dedekind_eta_c (re_q, im_q, &rep, &imp);
return sqrt (rep*rep+imp*imp);
}
double discriminant (double re_q, double im_q)
{
double rep, imp;
discriminant_c (re_q, im_q, &rep, &imp);
// return sqrt (rep*rep+imp*imp);
return rep;
// return imp;
}
/*-------------------------------------------------------------------*/
/* This routine fills in the interior of the the convergent area of the
* Euler q-series (dedekind eta function) in a simple way
*/
void
MakeHisto (
char *name,
float *glob,
int sizex,
int sizey,
double re_center,
double im_center,
double width,
double height,
int itermax,
double renorm)
{
int i,j, globlen;
double re_start, im_start, delta;
double re_position, im_position;
delta = width / (double) sizex;
re_start = re_center - width / 2.0;
im_start = im_center + width * ((double) sizey) / (2.0 * (double) sizex);
globlen = sizex*sizey;
for (i=0; i<globlen; i++) glob [i] = 0.0;
im_position = im_start;
for (i=0; i<sizey; i++)
{
if (i%10==0) printf(" start row %d\n", i);
re_position = re_start;
for (j=0; j<sizex; j++)
{
double re_c = re_position;
double im_c = im_position;
#define Q_SERIES_MOBIUS
#ifdef Q_SERIES_MOBIUS
/* First, make a map from q-series coords to the
* upper half-plane, then apply the mobius x-form,
* and then go back to the q-series coords */
double tau_re, tau_im;
// poincare_disk_to_plane_coords (re_c, im_c, &tau_re, &tau_im);
q_disk_to_plane_coords (re_c, im_c, &tau_re, &tau_im);
mobius_xform (1, 0, 6, 1, tau_re, tau_im, &tau_re, &tau_im);
// mobius_xform (1, 7, 0, 1, tau_re, tau_im, &tau_re, &tau_im);
// mobius_xform (0, -1, 1, 0, tau_re, tau_im, &tau_re, &tau_im);
plane_to_q_disk_coords (tau_re, tau_im, &re_c, &im_c);
#endif /* Q_SERIES_MOBIUS */
// double phi = euler_prod (re_c, im_c);
double phi = dedekind_eta (re_c, im_c);
// double phi = discriminant (re_c, im_c);
// double phi = bernoulli_zeta (re_c, im_c);
glob [i*sizex +j] = phi;
re_position += delta;
}
im_position -= delta; /*top to bottom, not bottom to top */
}
}
/* --------------------------- END OF LIFE ------------------------- */