38 "(y + x / y) * (x - y / x)",
39 "x / ((x + y) * (x - y)) / y",
40 "1 - ((x * y) + (y / x)) - 3",
41 "sin(2 * x) + cos(pi / y)",
42 "1 - sin(2 * x) + cos(pi / y)",
43 "sqrt(1 - sin(2 * x) + cos(pi / y) / 3)",
44 "(x^2 / sin(2 * pi / y)) -x / 2",
45 "x + (cos(y - sin(2 / x * pi)) - sin(x - cos(2 * y / pi))) - y",
46 "clamp(-1.0, sin(2 * pi * x) + cos(y / 2 * pi), +1.0)",
47 "iclamp(-1.0, sin(2 * pi * x) + cos(y / 2 * pi), +1.0)",
48 "max(3.33, min(sqrt(1 - sin(2 * x) + cos(pi / y) / 3), 1.11))",
49 "if(avg(x,y) <= x + y, x - y, x * y) + 2 * pi / x",
50 "1.1x^1 + 2.2y^2 - 3.3x^3 + 4.4y^4 - 5.5x^5 + 6.6y^6 - 7.7x^27 + 8.8y^55",
54 "(yy + xx / yy) * (xx - yy / xx)",
55 "xx / ((xx + yy) * (xx - yy)) / yy",
56 "1 - ((xx * yy) + (yy / xx)) - 3",
57 "sin(2 * xx) + cos(pi / yy)",
58 "1 - sin(2 * xx) + cos(pi / yy)",
59 "sqrt(1 - sin(2 * xx) + cos(pi / yy) / 3)",
60 "(xx^2 / sin(2 * pi / yy)) -xx / 2",
61 "xx + (cos(yy - sin(2 / xx * pi)) - sin(xx - cos(2 * yy / pi))) - yy",
62 "clamp(-1.0, sin(2 * pi * xx) + cos(yy / 2 * pi), +1.0)",
63 "max(3.33, min(sqrt(1 - sin(2 * xx) + cos(pi / yy) / 3), 1.11))",
64 "if(avg(xx,yy) <= xx + yy, xx - yy, xx * yy) + 2 * pi / xx",
65 "1.1xx^1 + 2.2yy^2 - 3.3xx^3 + 4.4yy^4 - 5.5xx^5 + 6.6yy^6 - 7.7xx^27 + 8.8yy^55",
66 "(1.1*(2.2*(3.3*(4.4*(5.5*(6.6*(7.7*(8.8*(9.9+x)))))))))",
67 "(((((((((x+9.9)*8.8)*7.7)*6.6)*5.5)*4.4)*3.3)*2.2)*1.1)",
68 "(x + y) * z",
"x + (y * z)",
"(x + y) * 7",
"x + (y * 7)",
69 "(x + 7) * y",
"x + (7 * y)",
"(7 + x) * y",
"7 + (x * y)",
70 "(2 + x) * 3",
"2 + (x * 3)",
"(2 + 3) * x",
"2 + (3 * x)",
71 "(x + 2) * 3",
"x + (2 * 3)",
72 "(x + y) * (z / w)",
"(x + y) * (z / 7)",
"(x + y) * (7 / z)",
"(x + 7) * (y / z)",
73 "(7 + x) * (y / z)",
"(2 + x) * (y / z)",
"(x + 2) * (y / 3)",
"(2 + x) * (y / 3)",
74 "(x + 2) * (3 / y)",
"x + (y * (z / w))",
"x + (y * (z / 7))",
"x + (y * (7 / z))",
75 "x + (7 * (y / z))",
"7 + (x * (y / z))",
"2 + (x * (3 / y))",
"x + (2 * (y / 4))",
76 "2 + (x * (y / 3))",
"x + (2 * (3 / y))",
77 "x + ((y * z) / w)",
"x + ((y * z) / 7)",
"x + ((y * 7) / z)",
"x + ((7 * y) / z)",
78 "7 + ((y * z) / w)",
"2 + ((x * 3) / y)",
"x + ((2 * y) / 3)",
"2 + ((x * y) / 3)",
79 "x + ((2 * 3) / y)",
"(((x + y) * z) / w)",
80 "(((x + y) * z) / 7)",
"(((x + y) * 7) / z)",
"(((x + 7) * y) / z)",
"(((7 + x) * y) / z)",
81 "(((2 + x) * 3) / y)",
"(((x + 2) * y) / 3)",
"(((2 + x) * y) / 3)",
"(((x + 2) * 3) / y)",
82 "((x + (y * z)) / w)",
"((x + (y * z)) / 7)",
"((x + (y * 7)) / y)",
"((x + (7 * y)) / z)",
83 "((7 + (x * y)) / z)",
"((2 + (x * 3)) / y)",
"((x + (2 * y)) / 3)",
"((2 + (x * y)) / 3)",
84 "((x + (2 * 3)) / y)",
85 "(xx + yy) * zz",
"xx + (yy * zz)",
86 "(xx + yy) * 7",
"xx + (yy * 7)",
87 "(xx + 7) * yy",
"xx + (7 * yy)",
88 "(7 + xx) * yy",
"7 + (xx * yy)",
89 "(2 + x) * 3",
"2 + (x * 3)",
90 "(2 + 3) * x",
"2 + (3 * x)",
91 "(x + 2) * 3",
"x + (2 * 3)",
92 "(xx + yy) * (zz / ww)",
"(xx + yy) * (zz / 7)",
93 "(xx + yy) * (7 / zz)",
"(xx + 7) * (yy / zz)",
94 "(7 + xx) * (yy / zz)",
"(2 + xx) * (yy / zz)",
95 "(xx + 2) * (yy / 3)",
"(2 + xx) * (yy / 3)",
96 "(xx + 2) * (3 / yy)",
"xx + (yy * (zz / ww))",
97 "xx + (yy * (zz / 7))",
"xx + (yy * (7 / zz))",
98 "xx + (7 * (yy / zz))",
"7 + (xx * (yy / zz))",
99 "2 + (xx * (3 / yy))",
"xx + (2 * (yy / 4))",
100 "2 + (xx * (yy / 3))",
"xx + (2 * (3 / yy))",
101 "xx + ((yy * zz) / ww)",
"xx + ((yy * zz) / 7)",
102 "xx + ((yy * 7) / zz)",
"xx + ((7 * yy) / zz)",
103 "7 + ((yy * zz) / ww)",
"2 + ((xx * 3) / yy)",
104 "xx + ((2 * yy) / 3)",
"2 + ((xx * yy) / 3)",
105 "xx + ((2 * 3) / yy)",
"(((xx + yy) * zz) / ww)",
106 "(((xx + yy) * zz) / 7)",
"(((xx + yy) * 7) / zz)",
107 "(((xx + 7) * yy) / zz)",
"(((7 + xx) * yy) / zz)",
108 "(((2 + xx) * 3) / yy)",
"(((xx + 2) * yy) / 3)",
109 "(((2 + xx) * yy) / 3)",
"(((xx + 2) * 3) / yy)",
110 "((xx + (yy * zz)) / ww)",
"((xx + (yy * zz)) / 7)",
111 "((xx + (yy * 7)) / yy)",
"((xx + (7 * yy)) / zz)",
112 "((7 + (xx * yy)) / zz)",
"((2 + (xx * 3)) / yy)",
113 "((xx + (2 * yy)) / 3)",
"((2 + (xx * yy)) / 3)",
114 "((xx + (2 * 3)) / yy)"
128 symbol_table_t symbol_table;
129 symbol_table.add_constants();
130 symbol_table.add_variable(
"x", x);
131 symbol_table.add_variable(
"y", y);
132 symbol_table.add_variable(
"z", z);
133 symbol_table.add_variable(
"w", w);
134 symbol_table.add_variable(
"xx",xx);
135 symbol_table.add_variable(
"yy",yy);
136 symbol_table.add_variable(
"zz",zz);
137 symbol_table.add_variable(
"ww",ww);
139 typedef typename std::deque<expression_t> expr_list_t;
140 expr_list_t expr_list;
142 const std::size_t
rounds = 50;
145 for (std::size_t r = 0; r <
rounds; ++r)
152 expression_t expression;
153 expression.register_symbol_table(symbol_table);
160 expr_list.push_back(expression);
167 static inline T process(T& x, T& y, expression_t& expression)
169 static const T lower_bound = T(-20);
170 static const T upper_bound = T(+20);
171 static const T
delta = T(0.1);
175 for (x = lower_bound; x <= upper_bound; x +=
delta)
177 for (y = lower_bound; y <= upper_bound; y +=
delta)
179 total += expression.value();
187 for (std::size_t i = 0; i < expr_list.size(); ++i)
189 execute::process( x, y, expr_list[i]);
190 execute::process(xx, yy, expr_list[i]);
196 for (std::size_t i = 0; i < 10000; ++i)
198 const T v = T(123.456 + i);
203 #define else_stmt(N) \
204 else if (details::is_true(details::numeric::nequal(details::numeric::fast_exp<T,N>::result(v),details::numeric::pow(v,T(N))))) \