| Alternative 1 | |
|---|---|
| Accuracy | 96.8% |
| Cost | 1225 |

(FPCore (x y) :precision binary64 (- (pow x 4.0) (pow y 4.0)))
(FPCore (x y) :precision binary64 (if (or (<= y -2e+190) (not (<= y 4.8e+149))) (* (* y y) (* y (- y))) (* (+ (* y y) (* x x)) (- (* x x) (* y y)))))
double code(double x, double y) {
return pow(x, 4.0) - pow(y, 4.0);
}
double code(double x, double y) {
double tmp;
if ((y <= -2e+190) || !(y <= 4.8e+149)) {
tmp = (y * y) * (y * -y);
} else {
tmp = ((y * y) + (x * x)) * ((x * x) - (y * y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x ** 4.0d0) - (y ** 4.0d0)
end function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-2d+190)) .or. (.not. (y <= 4.8d+149))) then
tmp = (y * y) * (y * -y)
else
tmp = ((y * y) + (x * x)) * ((x * x) - (y * y))
end if
code = tmp
end function
public static double code(double x, double y) {
return Math.pow(x, 4.0) - Math.pow(y, 4.0);
}
public static double code(double x, double y) {
double tmp;
if ((y <= -2e+190) || !(y <= 4.8e+149)) {
tmp = (y * y) * (y * -y);
} else {
tmp = ((y * y) + (x * x)) * ((x * x) - (y * y));
}
return tmp;
}
def code(x, y): return math.pow(x, 4.0) - math.pow(y, 4.0)
def code(x, y): tmp = 0 if (y <= -2e+190) or not (y <= 4.8e+149): tmp = (y * y) * (y * -y) else: tmp = ((y * y) + (x * x)) * ((x * x) - (y * y)) return tmp
function code(x, y) return Float64((x ^ 4.0) - (y ^ 4.0)) end
function code(x, y) tmp = 0.0 if ((y <= -2e+190) || !(y <= 4.8e+149)) tmp = Float64(Float64(y * y) * Float64(y * Float64(-y))); else tmp = Float64(Float64(Float64(y * y) + Float64(x * x)) * Float64(Float64(x * x) - Float64(y * y))); end return tmp end
function tmp = code(x, y) tmp = (x ^ 4.0) - (y ^ 4.0); end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -2e+190) || ~((y <= 4.8e+149))) tmp = (y * y) * (y * -y); else tmp = ((y * y) + (x * x)) * ((x * x) - (y * y)); end tmp_2 = tmp; end
code[x_, y_] := N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision]
code[x_, y_] := If[Or[LessEqual[y, -2e+190], N[Not[LessEqual[y, 4.8e+149]], $MachinePrecision]], N[(N[(y * y), $MachinePrecision] * N[(y * (-y)), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y * y), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
{x}^{4} - {y}^{4}
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{+190} \lor \neg \left(y \leq 4.8 \cdot 10^{+149}\right):\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot y + x \cdot x\right) \cdot \left(x \cdot x - y \cdot y\right)\\
\end{array}
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
if y < -2.0000000000000001e190 or 4.80000000000000024e149 < y Initial program 65.4%
Applied egg-rr75.0%
[Start]65.4% | \[ {x}^{4} - {y}^{4}
\] |
|---|---|
sqr-pow [=>]65.4% | \[ \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4}
\] |
sqr-pow [=>]65.4% | \[ {x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)} - \color{blue}{{y}^{\left(\frac{4}{2}\right)} \cdot {y}^{\left(\frac{4}{2}\right)}}
\] |
difference-of-squares [=>]75.0% | \[ \color{blue}{\left({x}^{\left(\frac{4}{2}\right)} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right)}
\] |
metadata-eval [=>]75.0% | \[ \left({x}^{\color{blue}{2}} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right)
\] |
pow2 [<=]75.0% | \[ \left(\color{blue}{x \cdot x} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right)
\] |
metadata-eval [=>]75.0% | \[ \left(x \cdot x + {y}^{\color{blue}{2}}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right)
\] |
pow2 [<=]75.0% | \[ \left(x \cdot x + \color{blue}{y \cdot y}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right)
\] |
metadata-eval [=>]75.0% | \[ \left(x \cdot x + y \cdot y\right) \cdot \left({x}^{\color{blue}{2}} - {y}^{\left(\frac{4}{2}\right)}\right)
\] |
pow2 [<=]75.0% | \[ \left(x \cdot x + y \cdot y\right) \cdot \left(\color{blue}{x \cdot x} - {y}^{\left(\frac{4}{2}\right)}\right)
\] |
metadata-eval [=>]75.0% | \[ \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - {y}^{\color{blue}{2}}\right)
\] |
pow2 [<=]75.0% | \[ \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right)
\] |
Taylor expanded in x around 0 75.0%
Simplified75.0%
[Start]75.0% | \[ {y}^{2} \cdot \left(x \cdot x - y \cdot y\right)
\] |
|---|---|
unpow2 [=>]75.0% | \[ \color{blue}{\left(y \cdot y\right)} \cdot \left(x \cdot x - y \cdot y\right)
\] |
Taylor expanded in x around 0 90.4%
Simplified90.4%
[Start]90.4% | \[ \left(y \cdot y\right) \cdot \left(-1 \cdot {y}^{2}\right)
\] |
|---|---|
unpow2 [=>]90.4% | \[ \left(y \cdot y\right) \cdot \left(-1 \cdot \color{blue}{\left(y \cdot y\right)}\right)
\] |
mul-1-neg [=>]90.4% | \[ \left(y \cdot y\right) \cdot \color{blue}{\left(-y \cdot y\right)}
\] |
distribute-rgt-neg-out [<=]90.4% | \[ \left(y \cdot y\right) \cdot \color{blue}{\left(y \cdot \left(-y\right)\right)}
\] |
if -2.0000000000000001e190 < y < 4.80000000000000024e149Initial program 91.7%
Applied egg-rr99.7%
[Start]91.7% | \[ {x}^{4} - {y}^{4}
\] |
|---|---|
sqr-pow [=>]91.5% | \[ \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4}
\] |
sqr-pow [=>]91.4% | \[ {x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)} - \color{blue}{{y}^{\left(\frac{4}{2}\right)} \cdot {y}^{\left(\frac{4}{2}\right)}}
\] |
difference-of-squares [=>]99.7% | \[ \color{blue}{\left({x}^{\left(\frac{4}{2}\right)} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right)}
\] |
metadata-eval [=>]99.7% | \[ \left({x}^{\color{blue}{2}} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right)
\] |
pow2 [<=]99.7% | \[ \left(\color{blue}{x \cdot x} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right)
\] |
metadata-eval [=>]99.7% | \[ \left(x \cdot x + {y}^{\color{blue}{2}}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right)
\] |
pow2 [<=]99.7% | \[ \left(x \cdot x + \color{blue}{y \cdot y}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right)
\] |
metadata-eval [=>]99.7% | \[ \left(x \cdot x + y \cdot y\right) \cdot \left({x}^{\color{blue}{2}} - {y}^{\left(\frac{4}{2}\right)}\right)
\] |
pow2 [<=]99.7% | \[ \left(x \cdot x + y \cdot y\right) \cdot \left(\color{blue}{x \cdot x} - {y}^{\left(\frac{4}{2}\right)}\right)
\] |
metadata-eval [=>]99.7% | \[ \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - {y}^{\color{blue}{2}}\right)
\] |
pow2 [<=]99.7% | \[ \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right)
\] |
Final simplification97.8%
| Alternative 1 | |
|---|---|
| Accuracy | 96.8% |
| Cost | 1225 |
| Alternative 2 | |
|---|---|
| Accuracy | 90.8% |
| Cost | 1232 |
| Alternative 3 | |
|---|---|
| Accuracy | 71.8% |
| Cost | 969 |
| Alternative 4 | |
|---|---|
| Accuracy | 66.2% |
| Cost | 777 |
| Alternative 5 | |
|---|---|
| Accuracy | 32.4% |
| Cost | 448 |
herbie shell --seed 2023271
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))