
(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 y)) (+ (* y y) (* x x))))
double code(double x, double y) {
return ((x - y) * (x + y)) * ((y * y) + (x * x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x - y) * (x + y)) * ((y * y) + (x * x))
end function
public static double code(double x, double y) {
return ((x - y) * (x + y)) * ((y * y) + (x * x));
}
def code(x, y): return ((x - y) * (x + y)) * ((y * y) + (x * x))
function code(x, y) return Float64(Float64(Float64(x - y) * Float64(x + y)) * Float64(Float64(y * y) + Float64(x * x))) end
function tmp = code(x, y) tmp = ((x - y) * (x + y)) * ((y * y) + (x * x)); end
code[x_, y_] := N[(N[(N[(x - y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(y * y), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - y\right) \cdot \left(x + y\right)\right) \cdot \left(y \cdot y + x \cdot x\right)
\end{array}
Initial program 85.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-rr92.8%
difference-of-squaresN/A
*-commutativeN/A
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f6499.9%
Applied egg-rr99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y (- 0.0 (* y y)))))
(t_1 (* (* y y) (- (* x x) (* y y)))))
(if (<= y -1.75e+195)
t_0
(if (<= y -3.9e-52)
t_1
(if (<= y 1.22e-69)
(* x (* x (* x x)))
(if (<= y 2.2e+116) t_1 t_0))))))
double code(double x, double y) {
double t_0 = y * (y * (0.0 - (y * y)));
double t_1 = (y * y) * ((x * x) - (y * y));
double tmp;
if (y <= -1.75e+195) {
tmp = t_0;
} else if (y <= -3.9e-52) {
tmp = t_1;
} else if (y <= 1.22e-69) {
tmp = x * (x * (x * x));
} else if (y <= 2.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 = y * (y * (0.0d0 - (y * y)))
t_1 = (y * y) * ((x * x) - (y * y))
if (y <= (-1.75d+195)) then
tmp = t_0
else if (y <= (-3.9d-52)) then
tmp = t_1
else if (y <= 1.22d-69) then
tmp = x * (x * (x * x))
else if (y <= 2.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 = y * (y * (0.0 - (y * y)));
double t_1 = (y * y) * ((x * x) - (y * y));
double tmp;
if (y <= -1.75e+195) {
tmp = t_0;
} else if (y <= -3.9e-52) {
tmp = t_1;
} else if (y <= 1.22e-69) {
tmp = x * (x * (x * x));
} else if (y <= 2.2e+116) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = y * (y * (0.0 - (y * y))) t_1 = (y * y) * ((x * x) - (y * y)) tmp = 0 if y <= -1.75e+195: tmp = t_0 elif y <= -3.9e-52: tmp = t_1 elif y <= 1.22e-69: tmp = x * (x * (x * x)) elif y <= 2.2e+116: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(y * Float64(y * Float64(0.0 - Float64(y * y)))) t_1 = Float64(Float64(y * y) * Float64(Float64(x * x) - Float64(y * y))) tmp = 0.0 if (y <= -1.75e+195) tmp = t_0; elseif (y <= -3.9e-52) tmp = t_1; elseif (y <= 1.22e-69) tmp = Float64(x * Float64(x * Float64(x * x))); elseif (y <= 2.2e+116) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = y * (y * (0.0 - (y * y))); t_1 = (y * y) * ((x * x) - (y * y)); tmp = 0.0; if (y <= -1.75e+195) tmp = t_0; elseif (y <= -3.9e-52) tmp = t_1; elseif (y <= 1.22e-69) tmp = x * (x * (x * x)); elseif (y <= 2.2e+116) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * N[(0.0 - N[(y * y), $MachinePrecision]), $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, -1.75e+195], t$95$0, If[LessEqual[y, -3.9e-52], t$95$1, If[LessEqual[y, 1.22e-69], N[(x * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.2e+116], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot \left(0 - 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 -1.75 \cdot 10^{+195}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -3.9 \cdot 10^{-52}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.22 \cdot 10^{-69}:\\
\;\;\;\;x \cdot \left(x \cdot \left(x \cdot x\right)\right)\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{+116}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.7500000000000001e195 or 2.2e116 < y Initial program 61.4%
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-rr74.3%
difference-of-squaresN/A
*-commutativeN/A
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f64100.0%
Applied egg-rr100.0%
*-commutativeN/A
difference-of-squaresN/A
flip--N/A
associate-*r*N/A
associate-*r*N/A
+-commutativeN/A
remove-double-divN/A
associate-/r*N/A
associate-/l/N/A
+-commutativeN/A
+-commutativeN/A
flip-+N/A
Applied egg-rr74.3%
Taylor expanded in x around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
metadata-evalN/A
pow-plusN/A
*-commutativeN/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6490.0%
Simplified90.0%
if -1.7500000000000001e195 < y < -3.90000000000000018e-52 or 1.22000000000000002e-69 < y < 2.2e116Initial program 87.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-rr99.8%
Taylor expanded in y around inf
unpow2N/A
*-lowering-*.f6487.8%
Simplified87.8%
if -3.90000000000000018e-52 < y < 1.22000000000000002e-69Initial program 100.0%
Taylor expanded in x around inf
pow-lowering-pow.f6496.7%
Simplified96.7%
metadata-evalN/A
pow-plusN/A
cube-unmultN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6496.6%
Applied egg-rr96.6%
Final simplification91.8%
(FPCore (x y) :precision binary64 (let* ((t_0 (* y (* y (- 0.0 (* y y)))))) (if (<= y -6e+78) t_0 (if (<= y 1.15e+86) (* x (* x (* x x))) t_0))))
double code(double x, double y) {
double t_0 = y * (y * (0.0 - (y * y)));
double tmp;
if (y <= -6e+78) {
tmp = t_0;
} else if (y <= 1.15e+86) {
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 = y * (y * (0.0d0 - (y * y)))
if (y <= (-6d+78)) then
tmp = t_0
else if (y <= 1.15d+86) 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 = y * (y * (0.0 - (y * y)));
double tmp;
if (y <= -6e+78) {
tmp = t_0;
} else if (y <= 1.15e+86) {
tmp = x * (x * (x * x));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = y * (y * (0.0 - (y * y))) tmp = 0 if y <= -6e+78: tmp = t_0 elif y <= 1.15e+86: tmp = x * (x * (x * x)) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(y * Float64(y * Float64(0.0 - Float64(y * y)))) tmp = 0.0 if (y <= -6e+78) tmp = t_0; elseif (y <= 1.15e+86) tmp = Float64(x * Float64(x * Float64(x * x))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = y * (y * (0.0 - (y * y))); tmp = 0.0; if (y <= -6e+78) tmp = t_0; elseif (y <= 1.15e+86) tmp = x * (x * (x * x)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * N[(0.0 - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -6e+78], t$95$0, If[LessEqual[y, 1.15e+86], N[(x * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot \left(0 - y \cdot y\right)\right)\\
\mathbf{if}\;y \leq -6 \cdot 10^{+78}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.15 \cdot 10^{+86}:\\
\;\;\;\;x \cdot \left(x \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -5.99999999999999964e78 or 1.14999999999999995e86 < y Initial program 66.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-rr82.4%
difference-of-squaresN/A
*-commutativeN/A
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f64100.0%
Applied egg-rr100.0%
*-commutativeN/A
difference-of-squaresN/A
flip--N/A
associate-*r*N/A
associate-*r*N/A
+-commutativeN/A
remove-double-divN/A
associate-/r*N/A
associate-/l/N/A
+-commutativeN/A
+-commutativeN/A
flip-+N/A
Applied egg-rr82.4%
Taylor expanded in x around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
metadata-evalN/A
pow-plusN/A
*-commutativeN/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6489.2%
Simplified89.2%
if -5.99999999999999964e78 < y < 1.14999999999999995e86Initial program 97.4%
Taylor expanded in x around inf
pow-lowering-pow.f6482.1%
Simplified82.1%
metadata-evalN/A
pow-plusN/A
cube-unmultN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6482.1%
Applied egg-rr82.1%
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 85.2%
Taylor expanded in x around inf
pow-lowering-pow.f6454.0%
Simplified54.0%
metadata-evalN/A
pow-plusN/A
cube-unmultN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6454.0%
Applied egg-rr54.0%
Final simplification54.0%
(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 85.2%
Taylor expanded in x around inf
pow-lowering-pow.f6454.0%
Simplified54.0%
metadata-evalN/A
pow-sqrN/A
pow2N/A
pow2N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6453.9%
Applied egg-rr53.9%
herbie shell --seed 2024144
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))