
(FPCore (x y) :precision binary64 (- (pow x 4.0) (pow y 4.0)))
double code(double x, double y) {
return pow(x, 4.0) - pow(y, 4.0);
}
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
public static double code(double x, double y) {
return Math.pow(x, 4.0) - Math.pow(y, 4.0);
}
def code(x, y): return math.pow(x, 4.0) - math.pow(y, 4.0)
function code(x, y) return Float64((x ^ 4.0) - (y ^ 4.0)) end
function tmp = code(x, y) tmp = (x ^ 4.0) - (y ^ 4.0); end
code[x_, y_] := N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{x}^{4} - {y}^{4}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (- (pow x 4.0) (pow y 4.0)))
double code(double x, double y) {
return pow(x, 4.0) - pow(y, 4.0);
}
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
public static double code(double x, double y) {
return Math.pow(x, 4.0) - Math.pow(y, 4.0);
}
def code(x, y): return math.pow(x, 4.0) - math.pow(y, 4.0)
function code(x, y) return Float64((x ^ 4.0) - (y ^ 4.0)) end
function tmp = code(x, y) tmp = (x ^ 4.0) - (y ^ 4.0); end
code[x_, y_] := N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{x}^{4} - {y}^{4}
\end{array}
(FPCore (x y) :precision binary64 (/ (* (- x y) (+ (* x x) (* y y))) (/ 1.0 (+ x y))))
double code(double x, double y) {
return ((x - y) * ((x * x) + (y * y))) / (1.0 / (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x - y) * ((x * x) + (y * y))) / (1.0d0 / (x + y))
end function
public static double code(double x, double y) {
return ((x - y) * ((x * x) + (y * y))) / (1.0 / (x + y));
}
def code(x, y): return ((x - y) * ((x * x) + (y * y))) / (1.0 / (x + y))
function code(x, y) return Float64(Float64(Float64(x - y) * Float64(Float64(x * x) + Float64(y * y))) / Float64(1.0 / Float64(x + y))) end
function tmp = code(x, y) tmp = ((x - y) * ((x * x) + (y * y))) / (1.0 / (x + y)); end
code[x_, y_] := N[(N[(N[(x - y), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x - y\right) \cdot \left(x \cdot x + y \cdot y\right)}{\frac{1}{x + y}}
\end{array}
Initial program 83.2%
sqr-powN/A
sqr-powN/A
difference-of-squaresN/A
*-commutativeN/A
*-lowering-*.f64N/A
--lowering--.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f6494.0%
Applied egg-rr94.0%
*-commutativeN/A
flip-+N/A
associate-*l/N/A
div-invN/A
*-lowering-*.f64N/A
Applied egg-rr42.8%
*-commutativeN/A
difference-of-squaresN/A
associate-*l*N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6442.8%
Applied egg-rr42.8%
associate-*l*N/A
*-commutativeN/A
/-rgt-identityN/A
clear-numN/A
un-div-invN/A
associate-*l*N/A
div-invN/A
associate-*r*N/A
flip-+N/A
+-commutativeN/A
Applied egg-rr99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* x (* x (* x x))))
(t_1 (/ (- (* x x) (* y y)) (/ 1.0 (* x x)))))
(if (<= x -1.4e+160)
t_0
(if (<= x -6.6e-58)
t_1
(if (<= x 1.26e-10)
(- 0.0 (* y (* y (* y y))))
(if (<= x 1.35e+154) t_1 t_0))))))
double code(double x, double y) {
double t_0 = x * (x * (x * x));
double t_1 = ((x * x) - (y * y)) / (1.0 / (x * x));
double tmp;
if (x <= -1.4e+160) {
tmp = t_0;
} else if (x <= -6.6e-58) {
tmp = t_1;
} else if (x <= 1.26e-10) {
tmp = 0.0 - (y * (y * (y * y)));
} else if (x <= 1.35e+154) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x * (x * (x * x))
t_1 = ((x * x) - (y * y)) / (1.0d0 / (x * x))
if (x <= (-1.4d+160)) then
tmp = t_0
else if (x <= (-6.6d-58)) then
tmp = t_1
else if (x <= 1.26d-10) then
tmp = 0.0d0 - (y * (y * (y * y)))
else if (x <= 1.35d+154) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x * (x * (x * x));
double t_1 = ((x * x) - (y * y)) / (1.0 / (x * x));
double tmp;
if (x <= -1.4e+160) {
tmp = t_0;
} else if (x <= -6.6e-58) {
tmp = t_1;
} else if (x <= 1.26e-10) {
tmp = 0.0 - (y * (y * (y * y)));
} else if (x <= 1.35e+154) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x * (x * (x * x)) t_1 = ((x * x) - (y * y)) / (1.0 / (x * x)) tmp = 0 if x <= -1.4e+160: tmp = t_0 elif x <= -6.6e-58: tmp = t_1 elif x <= 1.26e-10: tmp = 0.0 - (y * (y * (y * y))) elif x <= 1.35e+154: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x * Float64(x * Float64(x * x))) t_1 = Float64(Float64(Float64(x * x) - Float64(y * y)) / Float64(1.0 / Float64(x * x))) tmp = 0.0 if (x <= -1.4e+160) tmp = t_0; elseif (x <= -6.6e-58) tmp = t_1; elseif (x <= 1.26e-10) tmp = Float64(0.0 - Float64(y * Float64(y * Float64(y * y)))); elseif (x <= 1.35e+154) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x * (x * (x * x)); t_1 = ((x * x) - (y * y)) / (1.0 / (x * x)); tmp = 0.0; if (x <= -1.4e+160) tmp = t_0; elseif (x <= -6.6e-58) tmp = t_1; elseif (x <= 1.26e-10) tmp = 0.0 - (y * (y * (y * y))); elseif (x <= 1.35e+154) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision] / N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.4e+160], t$95$0, If[LessEqual[x, -6.6e-58], t$95$1, If[LessEqual[x, 1.26e-10], N[(0.0 - N[(y * N[(y * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.35e+154], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(x \cdot \left(x \cdot x\right)\right)\\
t_1 := \frac{x \cdot x - y \cdot y}{\frac{1}{x \cdot x}}\\
\mathbf{if}\;x \leq -1.4 \cdot 10^{+160}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -6.6 \cdot 10^{-58}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.26 \cdot 10^{-10}:\\
\;\;\;\;0 - y \cdot \left(y \cdot \left(y \cdot y\right)\right)\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.4e160 or 1.35000000000000003e154 < x Initial program 59.3%
sqr-powN/A
sqr-powN/A
difference-of-squaresN/A
*-commutativeN/A
*-lowering-*.f64N/A
--lowering--.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f6474.6%
Applied egg-rr74.6%
Taylor expanded in x around inf
metadata-evalN/A
pow-sqrN/A
unpow2N/A
associate-*r*N/A
unpow2N/A
cube-multN/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6488.1%
Simplified88.1%
if -1.4e160 < x < -6.60000000000000052e-58 or 1.26000000000000004e-10 < x < 1.35000000000000003e154Initial program 75.9%
sqr-powN/A
sqr-powN/A
difference-of-squaresN/A
*-commutativeN/A
*-lowering-*.f64N/A
--lowering--.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f6499.8%
Applied egg-rr99.8%
flip3-+N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
remove-double-divN/A
clear-numN/A
flip3-+N/A
Applied egg-rr99.7%
Taylor expanded in x around inf
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6495.1%
Simplified95.1%
if -6.60000000000000052e-58 < x < 1.26000000000000004e-10Initial program 100.0%
Taylor expanded in x around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
pow-lowering-pow.f6496.8%
Simplified96.8%
sub0-negN/A
neg-lowering-neg.f64N/A
metadata-evalN/A
pow-plusN/A
cube-unmultN/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6496.8%
Applied egg-rr96.8%
Final simplification94.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* x (* x (* x x)))))
(if (<= x -1.4e+160)
t_0
(if (<= x 1.35e+154) (* (+ (* x x) (* y y)) (- (* x x) (* y y))) t_0))))
double code(double x, double y) {
double t_0 = x * (x * (x * x));
double tmp;
if (x <= -1.4e+160) {
tmp = t_0;
} else if (x <= 1.35e+154) {
tmp = ((x * x) + (y * y)) * ((x * x) - (y * y));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x * (x * (x * x))
if (x <= (-1.4d+160)) then
tmp = t_0
else if (x <= 1.35d+154) then
tmp = ((x * x) + (y * y)) * ((x * x) - (y * y))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x * (x * (x * x));
double tmp;
if (x <= -1.4e+160) {
tmp = t_0;
} else if (x <= 1.35e+154) {
tmp = ((x * x) + (y * y)) * ((x * x) - (y * y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x * (x * (x * x)) tmp = 0 if x <= -1.4e+160: tmp = t_0 elif x <= 1.35e+154: tmp = ((x * x) + (y * y)) * ((x * x) - (y * y)) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x * Float64(x * Float64(x * x))) tmp = 0.0 if (x <= -1.4e+160) tmp = t_0; elseif (x <= 1.35e+154) tmp = Float64(Float64(Float64(x * x) + Float64(y * y)) * Float64(Float64(x * x) - Float64(y * y))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x * (x * (x * x)); tmp = 0.0; if (x <= -1.4e+160) tmp = t_0; elseif (x <= 1.35e+154) tmp = ((x * x) + (y * y)) * ((x * x) - (y * y)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.4e+160], t$95$0, If[LessEqual[x, 1.35e+154], N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(x \cdot \left(x \cdot x\right)\right)\\
\mathbf{if}\;x \leq -1.4 \cdot 10^{+160}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.4e160 or 1.35000000000000003e154 < x Initial program 59.3%
sqr-powN/A
sqr-powN/A
difference-of-squaresN/A
*-commutativeN/A
*-lowering-*.f64N/A
--lowering--.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f6474.6%
Applied egg-rr74.6%
Taylor expanded in x around inf
metadata-evalN/A
pow-sqrN/A
unpow2N/A
associate-*r*N/A
unpow2N/A
cube-multN/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6488.1%
Simplified88.1%
if -1.4e160 < x < 1.35000000000000003e154Initial program 90.4%
sqr-powN/A
sqr-powN/A
difference-of-squaresN/A
*-commutativeN/A
*-lowering-*.f64N/A
--lowering--.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f6499.8%
Applied egg-rr99.8%
Final simplification97.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* x (* x (* x x)))))
(if (<= x -1.3e-51)
t_0
(if (<= x 2.25e+85) (- 0.0 (* y (* y (* y y)))) t_0))))
double code(double x, double y) {
double t_0 = x * (x * (x * x));
double tmp;
if (x <= -1.3e-51) {
tmp = t_0;
} else if (x <= 2.25e+85) {
tmp = 0.0 - (y * (y * (y * y)));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x * (x * (x * x))
if (x <= (-1.3d-51)) then
tmp = t_0
else if (x <= 2.25d+85) then
tmp = 0.0d0 - (y * (y * (y * y)))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x * (x * (x * x));
double tmp;
if (x <= -1.3e-51) {
tmp = t_0;
} else if (x <= 2.25e+85) {
tmp = 0.0 - (y * (y * (y * y)));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x * (x * (x * x)) tmp = 0 if x <= -1.3e-51: tmp = t_0 elif x <= 2.25e+85: tmp = 0.0 - (y * (y * (y * y))) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x * Float64(x * Float64(x * x))) tmp = 0.0 if (x <= -1.3e-51) tmp = t_0; elseif (x <= 2.25e+85) tmp = Float64(0.0 - Float64(y * Float64(y * Float64(y * y)))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x * (x * (x * x)); tmp = 0.0; if (x <= -1.3e-51) tmp = t_0; elseif (x <= 2.25e+85) tmp = 0.0 - (y * (y * (y * y))); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.3e-51], t$95$0, If[LessEqual[x, 2.25e+85], N[(0.0 - N[(y * N[(y * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(x \cdot \left(x \cdot x\right)\right)\\
\mathbf{if}\;x \leq -1.3 \cdot 10^{-51}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.25 \cdot 10^{+85}:\\
\;\;\;\;0 - y \cdot \left(y \cdot \left(y \cdot y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.3e-51 or 2.25000000000000003e85 < x Initial program 65.9%
sqr-powN/A
sqr-powN/A
difference-of-squaresN/A
*-commutativeN/A
*-lowering-*.f64N/A
--lowering--.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f6487.7%
Applied egg-rr87.7%
Taylor expanded in x around inf
metadata-evalN/A
pow-sqrN/A
unpow2N/A
associate-*r*N/A
unpow2N/A
cube-multN/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6475.6%
Simplified75.6%
if -1.3e-51 < x < 2.25000000000000003e85Initial program 99.2%
Taylor expanded in x around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
pow-lowering-pow.f6492.1%
Simplified92.1%
sub0-negN/A
neg-lowering-neg.f64N/A
metadata-evalN/A
pow-plusN/A
cube-unmultN/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6492.0%
Applied egg-rr92.0%
Final simplification84.1%
(FPCore (x y) :precision binary64 (* x (* x (* x x))))
double code(double x, double y) {
return x * (x * (x * x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (x * (x * x))
end function
public static double code(double x, double y) {
return x * (x * (x * x));
}
def code(x, y): return x * (x * (x * x))
function code(x, y) return Float64(x * Float64(x * Float64(x * x))) end
function tmp = code(x, y) tmp = x * (x * (x * x)); end
code[x_, y_] := N[(x * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(x \cdot \left(x \cdot x\right)\right)
\end{array}
Initial program 83.2%
sqr-powN/A
sqr-powN/A
difference-of-squaresN/A
*-commutativeN/A
*-lowering-*.f64N/A
--lowering--.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f6494.0%
Applied egg-rr94.0%
Taylor expanded in x around inf
metadata-evalN/A
pow-sqrN/A
unpow2N/A
associate-*r*N/A
unpow2N/A
cube-multN/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6457.7%
Simplified57.7%
herbie shell --seed 2024193
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))