-
Notifications
You must be signed in to change notification settings - Fork 0
/
random_grid_methB.py
executable file
·70 lines (61 loc) · 2.85 KB
/
random_grid_methB.py
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
#!/usr/bin/python
# Copyright (C) 2012 Mehmet Atakan Gürkan
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program (probably in a file named COPYING).
# If not, see <http://www.gnu.org/licenses/>.
from random import seed, uniform
seed(18)
print '''restart;
# setting step_function(0) = 0
NumericEventHandler(invalid_operation = `Heaviside/EventHandler`(value_at_zero = 0));
c[1] := 0;
c[6] := 1;
eq1 := sum(b[i], i=1..6) = 1;
eq2 := sum(b[i]*c[i], i=1..6) = 1/2;
eq3 := sum(b[i]*c[i]*c[i], i=1..6) = 1/3;
eq4 := sum(sum(b[i]*b[j]*(c[i]-c[j])*Heaviside(i-j), j=1..6), i=1..6) = 1/6;
eq5 := sum(b[i]*c[i]*c[i]*c[i], i=1..6) = 1/4;
eq6 := sum(sum(b[i]*b[j]*c[i]*(c[i]-c[j])*Heaviside(i-j), j=1..6), i=1..6) = 1/8;
eq7 := sum(b[i]*c[i]*c[i]*c[i]*c[i], i=1..6) = 1/5;
eq8 := sum(sum(b[i]*b[j]*c[i]*c[i]*(c[i]-c[j])*Heaviside(i-j), j=1..6), i=1..6) = 1/10;
eq9 := sum(sum(sum(b[i]*b[j]*b[l]*(c[i]-c[j])*(c[i]-c[l])*Heaviside(i-j)*Heaviside(i-l), l=1..6), j=1..6), i=1..6) = 1/20;
eq10 := sum(sum(b[i]*b[j]*c[i]*c[j]*(c[i]-c[j])*Heaviside(i-j), j=1..6), i=1..6) = 1/30;
interface(printbytes=false);
currentdir():
writeto( "ord_cond_search_methB_seed18.mw" ):'''
for i in range(40) :
b1lx, b1ly = uniform(-2.0, 2.0), uniform(-2.0, 2.0)
b2lx, b2ly = uniform(-2.0, 2.0), uniform(-2.0, 2.0)
b3lx, b3ly = uniform(-2.0, 2.0), uniform(-2.0, 2.0)
b4lx, b4ly = uniform(-2.0, 2.0), uniform(-2.0, 2.0)
b5lx, b5ly = uniform(-2.0, 2.0), uniform(-2.0, 2.0)
b6lx, b6ly = uniform(-2.0, 2.0), uniform(-2.0, 2.0)
c2lx, c2ly = uniform(-2.0, 2.0), uniform(-2.0, 2.0)
c3lx, c3ly = uniform(-2.0, 2.0), uniform(-2.0, 2.0)
c4lx, c4ly = uniform(-2.0, 2.0), uniform(-2.0, 2.0)
c5lx, c5ly = uniform(-2.0, 2.0), uniform(-2.0, 2.0)
print 'lprint(fsolve({eq1, eq2, eq3, eq4, eq5,',
print 'eq6, eq7, eq8, eq9, eq10},',
limits = 'b[1] = %g+I*(%g), ' % (b1lx, b1ly)
limits += 'b[2] = %g+I*(%g), ' % (b2lx, b2ly)
limits += 'b[3] = %g+I*(%g), ' % (b3lx, b3ly)
limits += 'b[4] = %g+I*(%g), ' % (b4lx, b4ly)
limits += 'b[5] = %g+I*(%g), ' % (b5lx, b5ly)
limits += 'b[6] = %g+I*(%g), ' % (b6lx, b6ly)
limits += 'c[2] = %g+I*(%g), ' % (c2lx, c2ly)
limits += 'c[3] = %g+I*(%g), ' % (c3lx, c3ly)
limits += 'c[4] = %g+I*(%g), ' % (c4lx, c4ly)
limits += 'c[5] = %g+I*(%g)' % (c5lx, c5ly)
print '{%s}, complex)):' % (limits,)
print '''writeto(terminal);
interface(printbytes=true);'''