
(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 6 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 x) (* y y)) (+ x y)) (- x y)))
double code(double x, double y) {
return (((x * x) + (y * y)) * (x + y)) * (x - y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (((x * x) + (y * y)) * (x + y)) * (x - y)
end function
public static double code(double x, double y) {
return (((x * x) + (y * y)) * (x + y)) * (x - y);
}
def code(x, y): return (((x * x) + (y * y)) * (x + y)) * (x - y)
function code(x, y) return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) * Float64(x + y)) * Float64(x - y)) end
function tmp = code(x, y) tmp = (((x * x) + (y * y)) * (x + y)) * (x - y); end
code[x_, y_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot x + y \cdot y\right) \cdot \left(x + y\right)\right) \cdot \left(x - y\right)
\end{array}
Initial program 86.3%
sqr-powN/A
sqr-powN/A
difference-of-squaresN/A
metadata-evalN/A
unpow2N/A
fmm-defN/A
metadata-evalN/A
unpow2N/A
*-commutativeN/A
*-lowering-*.f64N/A
Applied egg-rr93.1%
*-commutativeN/A
difference-of-squaresN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
--lowering--.f6499.9%
Applied egg-rr99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (- x y) (* y (* y y)))) (t_1 (* (* y y) (- (* x x) (* y y)))))
(if (<= y -4.5e+177)
t_0
(if (<= y -4.8e-50)
t_1
(if (<= y 2.3e-101)
(* x (* x (* x x)))
(if (<= y 8.2e+116) t_1 t_0))))))
double code(double x, double y) {
double t_0 = (x - y) * (y * (y * y));
double t_1 = (y * y) * ((x * x) - (y * y));
double tmp;
if (y <= -4.5e+177) {
tmp = t_0;
} else if (y <= -4.8e-50) {
tmp = t_1;
} else if (y <= 2.3e-101) {
tmp = x * (x * (x * x));
} else if (y <= 8.2e+116) {
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 - y) * (y * (y * y))
t_1 = (y * y) * ((x * x) - (y * y))
if (y <= (-4.5d+177)) then
tmp = t_0
else if (y <= (-4.8d-50)) then
tmp = t_1
else if (y <= 2.3d-101) then
tmp = x * (x * (x * x))
else if (y <= 8.2d+116) 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 - y) * (y * (y * y));
double t_1 = (y * y) * ((x * x) - (y * y));
double tmp;
if (y <= -4.5e+177) {
tmp = t_0;
} else if (y <= -4.8e-50) {
tmp = t_1;
} else if (y <= 2.3e-101) {
tmp = x * (x * (x * x));
} else if (y <= 8.2e+116) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x - y) * (y * (y * y)) t_1 = (y * y) * ((x * x) - (y * y)) tmp = 0 if y <= -4.5e+177: tmp = t_0 elif y <= -4.8e-50: tmp = t_1 elif y <= 2.3e-101: tmp = x * (x * (x * x)) elif y <= 8.2e+116: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x - y) * Float64(y * Float64(y * y))) t_1 = Float64(Float64(y * y) * Float64(Float64(x * x) - Float64(y * y))) tmp = 0.0 if (y <= -4.5e+177) tmp = t_0; elseif (y <= -4.8e-50) tmp = t_1; elseif (y <= 2.3e-101) tmp = Float64(x * Float64(x * Float64(x * x))); elseif (y <= 8.2e+116) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x - y) * (y * (y * y)); t_1 = (y * y) * ((x * x) - (y * y)); tmp = 0.0; if (y <= -4.5e+177) tmp = t_0; elseif (y <= -4.8e-50) tmp = t_1; elseif (y <= 2.3e-101) tmp = x * (x * (x * x)); elseif (y <= 8.2e+116) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] * N[(y * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(y * y), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.5e+177], t$95$0, If[LessEqual[y, -4.8e-50], t$95$1, If[LessEqual[y, 2.3e-101], N[(x * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8.2e+116], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - y\right) \cdot \left(y \cdot \left(y \cdot y\right)\right)\\
t_1 := \left(y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)\\
\mathbf{if}\;y \leq -4.5 \cdot 10^{+177}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -4.8 \cdot 10^{-50}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{-101}:\\
\;\;\;\;x \cdot \left(x \cdot \left(x \cdot x\right)\right)\\
\mathbf{elif}\;y \leq 8.2 \cdot 10^{+116}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -4.4999999999999997e177 or 8.1999999999999996e116 < y Initial program 58.2%
sqr-powN/A
sqr-powN/A
difference-of-squaresN/A
metadata-evalN/A
unpow2N/A
fmm-defN/A
metadata-evalN/A
unpow2N/A
*-commutativeN/A
*-lowering-*.f64N/A
Applied egg-rr69.1%
*-commutativeN/A
difference-of-squaresN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
--lowering--.f64100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6496.4%
Simplified96.4%
if -4.4999999999999997e177 < y < -4.80000000000000004e-50 or 2.2999999999999999e-101 < y < 8.1999999999999996e116Initial program 87.5%
sqr-powN/A
sqr-powN/A
difference-of-squaresN/A
metadata-evalN/A
unpow2N/A
fmm-defN/A
metadata-evalN/A
unpow2N/A
*-commutativeN/A
*-lowering-*.f64N/A
Applied egg-rr99.7%
Taylor expanded in y around inf
unpow2N/A
*-lowering-*.f6486.6%
Simplified86.6%
if -4.80000000000000004e-50 < y < 2.2999999999999999e-101Initial program 100.0%
Taylor expanded in x around inf
pow-lowering-pow.f6498.6%
Simplified98.6%
metadata-evalN/A
pow-plusN/A
cube-unmultN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6498.4%
Applied egg-rr98.4%
Final simplification93.6%
(FPCore (x y) :precision binary64 (let* ((t_0 (* (- x y) (* y (* y y))))) (if (<= y -7.5e+62) t_0 (if (<= y 180000.0) (* x (* x (* x x))) t_0))))
double code(double x, double y) {
double t_0 = (x - y) * (y * (y * y));
double tmp;
if (y <= -7.5e+62) {
tmp = t_0;
} else if (y <= 180000.0) {
tmp = x * (x * (x * x));
} 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 - y) * (y * (y * y))
if (y <= (-7.5d+62)) then
tmp = t_0
else if (y <= 180000.0d0) then
tmp = x * (x * (x * x))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x - y) * (y * (y * y));
double tmp;
if (y <= -7.5e+62) {
tmp = t_0;
} else if (y <= 180000.0) {
tmp = x * (x * (x * x));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x - y) * (y * (y * y)) tmp = 0 if y <= -7.5e+62: tmp = t_0 elif y <= 180000.0: tmp = x * (x * (x * x)) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x - y) * Float64(y * Float64(y * y))) tmp = 0.0 if (y <= -7.5e+62) tmp = t_0; elseif (y <= 180000.0) tmp = Float64(x * Float64(x * Float64(x * x))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x - y) * (y * (y * y)); tmp = 0.0; if (y <= -7.5e+62) tmp = t_0; elseif (y <= 180000.0) tmp = x * (x * (x * x)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] * N[(y * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -7.5e+62], t$95$0, If[LessEqual[y, 180000.0], N[(x * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - y\right) \cdot \left(y \cdot \left(y \cdot y\right)\right)\\
\mathbf{if}\;y \leq -7.5 \cdot 10^{+62}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 180000:\\
\;\;\;\;x \cdot \left(x \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -7.49999999999999998e62 or 1.8e5 < y Initial program 65.7%
sqr-powN/A
sqr-powN/A
difference-of-squaresN/A
metadata-evalN/A
unpow2N/A
fmm-defN/A
metadata-evalN/A
unpow2N/A
*-commutativeN/A
*-lowering-*.f64N/A
Applied egg-rr83.3%
*-commutativeN/A
difference-of-squaresN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
--lowering--.f64100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6490.2%
Simplified90.2%
if -7.49999999999999998e62 < y < 1.8e5Initial program 100.0%
Taylor expanded in x around inf
pow-lowering-pow.f6486.6%
Simplified86.6%
metadata-evalN/A
pow-plusN/A
cube-unmultN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6486.5%
Applied egg-rr86.5%
Final simplification88.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* x (* x (* x x)))))
(if (<= x -2.5e-62)
t_0
(if (<= x 1.5e+19) (* y (* y (* y (- 0.0 y)))) t_0))))
double code(double x, double y) {
double t_0 = x * (x * (x * x));
double tmp;
if (x <= -2.5e-62) {
tmp = t_0;
} else if (x <= 1.5e+19) {
tmp = y * (y * (y * (0.0 - 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 <= (-2.5d-62)) then
tmp = t_0
else if (x <= 1.5d+19) then
tmp = y * (y * (y * (0.0d0 - 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 <= -2.5e-62) {
tmp = t_0;
} else if (x <= 1.5e+19) {
tmp = y * (y * (y * (0.0 - y)));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x * (x * (x * x)) tmp = 0 if x <= -2.5e-62: tmp = t_0 elif x <= 1.5e+19: tmp = y * (y * (y * (0.0 - 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 <= -2.5e-62) tmp = t_0; elseif (x <= 1.5e+19) tmp = Float64(y * Float64(y * Float64(y * Float64(0.0 - 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 <= -2.5e-62) tmp = t_0; elseif (x <= 1.5e+19) tmp = y * (y * (y * (0.0 - 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, -2.5e-62], t$95$0, If[LessEqual[x, 1.5e+19], N[(y * N[(y * N[(y * N[(0.0 - 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 -2.5 \cdot 10^{-62}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{+19}:\\
\;\;\;\;y \cdot \left(y \cdot \left(y \cdot \left(0 - y\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -2.5000000000000001e-62 or 1.5e19 < x Initial program 75.0%
Taylor expanded in x around inf
pow-lowering-pow.f6480.5%
Simplified80.5%
metadata-evalN/A
pow-plusN/A
cube-unmultN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6480.4%
Applied egg-rr80.4%
if -2.5000000000000001e-62 < x < 1.5e19Initial program 100.0%
sqr-powN/A
sqr-powN/A
difference-of-squaresN/A
metadata-evalN/A
unpow2N/A
fmm-defN/A
metadata-evalN/A
unpow2N/A
*-commutativeN/A
*-lowering-*.f64N/A
Applied egg-rr99.7%
*-commutativeN/A
difference-of-squaresN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
--lowering--.f6499.8%
Applied egg-rr99.8%
Taylor expanded in x around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
metadata-evalN/A
pow-sqrN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6490.3%
Simplified90.3%
associate-*r*N/A
sub0-negN/A
neg-lowering-neg.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6490.4%
Applied egg-rr90.4%
Final simplification84.9%
(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 86.3%
Taylor expanded in x around inf
pow-lowering-pow.f6461.8%
Simplified61.8%
metadata-evalN/A
pow-plusN/A
cube-unmultN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6461.7%
Applied egg-rr61.7%
Final simplification61.7%
(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(Float64(x * x) * Float64(x * x)) end
function tmp = code(x, y) tmp = (x * x) * (x * x); end
code[x_, y_] := N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot x\right) \cdot \left(x \cdot x\right)
\end{array}
Initial program 86.3%
Taylor expanded in x around inf
pow-lowering-pow.f6461.8%
Simplified61.8%
metadata-evalN/A
pow-prod-upN/A
pow2N/A
pow2N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6461.7%
Applied egg-rr61.7%
herbie shell --seed 2024161
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))