-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappendix.tex
151 lines (151 loc) · 6.18 KB
/
appendix.tex
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
142
143
144
145
146
147
148
149
150
151
\newpage
\appendix
\section{Program to look for counter-examples}
\label{appendix:section:algorithm}
The following algorithm has the following structure:
\begin{enumerate}
\item Generate $\alpha, \beta$ and $u$.
\item Determine the optimal value of $t$:
\begin{enumerate}
\item if $\alpha \leq t_{1}$, we can choose $t = \alpha$.
\item else, i.e., if $\alpha > t_{1}$ then $t = t_{1}$.
\end{enumerate}
\item Calculate $\lambda_{\alpha, \beta} = \lambda(t; \alpha, \beta, u)$.
\item Repeat step $2$ and $3$ interchanging $\alpha$ by $\beta$ and $\beta$ by $\alpha$. The result will be the $\lambda_{\beta, \alpha} = \lambda(t; \beta, \alpha, u)$.
\item If $\lambda_{\alpha,\beta} = \lambda_{\beta, \alpha} $, go again to step 1. Else, we have our examples.
\end{enumerate}
{\small\begin{verbatim}
from math import sqrt, ceil;
#Definition of the formula for the eigenvalues.
#There is an optional parameter, mode,
#which one can change to give us only the
#+-solutions or the maximum of both eigenvalues.
#By default it is set to max.
def eig(alpha,beta,t,u,mode = 'max'):
#calculate the part with and
#without the square root of the formula.
no_sqrt = (alpha - t + 2 - beta)/2;
yes_sqrt = (sqrt((beta+alpha-t)**2-4*beta*(alpha-t)*u**2))/2;
#cases considering the different values of the mode parameter.
if mode == 'plus':
value = no_sqrt+yes_sqrt;
return value;
elif mode == 'minus':
value = no_sqrt-yes_sqrt;
return value;
elif mode == 'max':
#this will return the norm, i.e. the maximum of the eigenvalues.
value = max(no_sqrt+yes_sqrt, no_sqrt-yes_sqrt);
return value;
else:
return False;
def t1(c, u):
if u==0:
return 1;
else:
return (1-c)/(1-c + c*u**2);
#This is to calculate the constraint,
#we just compare t1(beta) and alpha
def tconstraint(alpha,beta,u):
t1ab = t1(beta,u);
t1ba = t1(alpha,u);
if alpha <=t1ab:
constraint_ab = alpha;
else:
constraint_ab = t1ab;
if beta <= t1ba:
constraint_ba = beta;
else:
constraint_ba = t1ba;
#We return the values in the format of a dictionary
return {'constraint_ab':constraint_ab,
'constraint_ba':constraint_ba};
#This function will look for suitable points for
# which the norm varies in dependence of
#the permutation of alpha and beta.
#If count is set to true then we will count the
#numbers that are in the different
#sets M<<, M<> or M>>
def look_for_points(N,all = False, count = False):
#we create a grid in (0,1) of N-2 points.
#The precision we will use is 5 decimal places
precision = 5;
#the number of total points (alpha,beta,u) which are looked
total_points = (N+1)*(N+1)*N;
#help variable for the percentage process
perc_step = 0;
count_total = 0;
count_dif =0;
count_great_great=0;
count_great_less=0;
count_less_less=0;
count_less_great=0;
eq_count_great_great=0;
eq_count_great_less=0;
eq_count_less_less=0;
eq_count_less_great=0;
for i in range(0,N+1):
for j in range(0,N+1):
#u is in [0,1)
for k in range(1,N+1):
alpha = round((1-i/N)*1 + (i/N)*0,precision);
beta = round((1-j/N)*1 + (j/N)*0,precision);
u =round((1-k/N)*1 + (k/N)*0,precision);
constraint = tconstraint(alpha,beta,u);
tab = round(constraint['constraint_ab'],precision);
tba = round(constraint['constraint_ba'],precision);
ab = round(eig(alpha, beta, tab,u),precision);
ba = round(eig(beta,alpha,tba,u),precision);
count_total+=1;
#Percentage process
if count_total/total_points >= perc_step:
print(str(ceil(100*perc_step))+'%');
perc_step += .1;
if ab != ba:
count_dif+=1;
points = {'alpha':alpha, 'beta':beta, 'u':u,
'tab':tab, 'tba':tba, 'ab':ab, 'ba':ba};
if all:
if alpha > t1(beta,u):
if beta > t1(alpha,u):
count_great_great+=1;
elif beta < t1(alpha,u):
count_great_less+=1;
elif alpha < t1(beta,u):
if beta > t1(alpha,u):
count_less_great+=1;
elif beta < t1(alpha,u):
count_less_less+=1;
else:
#When we only want a suitable point,
#we get the first suitable point.
return points;
else:
if all:
if alpha > t1(beta,u):
if beta > t1(alpha,u):
eq_count_great_great+=1;
elif beta < t1(alpha,u):
eq_count_great_less+=1;
elif alpha < t1(beta,u):
if beta > t1(alpha,u):
eq_count_less_great+=1;
elif beta < t1(alpha,u):
eq_count_less_less+=1;
if(count and all):
print('---------------------');
print('total points = '+str(count_total));
print('\ntotal suitable points = '+str(count_dif));
print(' total great great points = '+str(count_great_great));
print(' total great less points = '+str(count_great_less));
print(' total less great points = '+str(count_less_great));
print(' total less less points = '+str(count_less_less));
print('\ntotal nonsuitable points = '+str(count_total-count_dif));
print(' total great great points = '+str(eq_count_great_great));
print(' total great less points = '+str(eq_count_great_less));
print(' total less great points = '+str(eq_count_less_great));
print(' total less less points = '+str(eq_count_less_less));
return False;
look_for_points(10,all=True, count = True)
\end{verbatim}
}