
(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}
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= y 1.7e+151) (* (+ (* x x) (* y y)) (- (* x x) (* y y))) (* (* y y) (- (* y (- y)) (* x x)))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 1.7e+151) {
tmp = ((x * x) + (y * y)) * ((x * x) - (y * y));
} else {
tmp = (y * y) * ((y * -y) - (x * x));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.7d+151) then
tmp = ((x * x) + (y * y)) * ((x * x) - (y * y))
else
tmp = (y * y) * ((y * -y) - (x * x))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 1.7e+151) {
tmp = ((x * x) + (y * y)) * ((x * x) - (y * y));
} else {
tmp = (y * y) * ((y * -y) - (x * x));
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 1.7e+151: tmp = ((x * x) + (y * y)) * ((x * x) - (y * y)) else: tmp = (y * y) * ((y * -y) - (x * x)) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (y <= 1.7e+151) tmp = Float64(Float64(Float64(x * x) + Float64(y * y)) * Float64(Float64(x * x) - Float64(y * y))); else tmp = Float64(Float64(y * y) * Float64(Float64(y * Float64(-y)) - Float64(x * x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.7e+151) tmp = ((x * x) + (y * y)) * ((x * x) - (y * y)); else tmp = (y * y) * ((y * -y) - (x * x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 1.7e+151], N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * y), $MachinePrecision] * N[(N[(y * (-y)), $MachinePrecision] - N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.7 \cdot 10^{+151}:\\
\;\;\;\;\left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right) - x \cdot x\right)\\
\end{array}
\end{array}
if y < 1.7e151Initial program 90.4%
sqr-pow90.3%
sqr-pow90.2%
difference-of-squares96.6%
metadata-eval96.6%
pow296.6%
metadata-eval96.6%
pow296.6%
metadata-eval96.6%
pow296.6%
metadata-eval96.6%
pow296.6%
Applied egg-rr96.6%
if 1.7e151 < y Initial program 71.1%
sqr-pow71.1%
sqr-pow71.1%
difference-of-squares84.2%
metadata-eval84.2%
pow284.2%
metadata-eval84.2%
pow284.2%
metadata-eval84.2%
pow284.2%
metadata-eval84.2%
pow284.2%
Applied egg-rr84.2%
Taylor expanded in x around 0 89.5%
unpow289.5%
mul-1-neg89.5%
Simplified89.5%
Final simplification95.5%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= x 2.7e+26) (* (* y y) (- (* y (- y)) (* x x))) (* (* x x) (+ (* x x) (* y y)))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (x <= 2.7e+26) {
tmp = (y * y) * ((y * -y) - (x * x));
} else {
tmp = (x * x) * ((x * x) + (y * y));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 2.7d+26) then
tmp = (y * y) * ((y * -y) - (x * x))
else
tmp = (x * x) * ((x * x) + (y * y))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (x <= 2.7e+26) {
tmp = (y * y) * ((y * -y) - (x * x));
} else {
tmp = (x * x) * ((x * x) + (y * y));
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if x <= 2.7e+26: tmp = (y * y) * ((y * -y) - (x * x)) else: tmp = (x * x) * ((x * x) + (y * y)) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (x <= 2.7e+26) tmp = Float64(Float64(y * y) * Float64(Float64(y * Float64(-y)) - Float64(x * x))); else tmp = Float64(Float64(x * x) * Float64(Float64(x * x) + Float64(y * y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (x <= 2.7e+26) tmp = (y * y) * ((y * -y) - (x * x)); else tmp = (x * x) * ((x * x) + (y * y)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[x, 2.7e+26], N[(N[(y * y), $MachinePrecision] * N[(N[(y * (-y)), $MachinePrecision] - N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.7 \cdot 10^{+26}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right) - x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\
\end{array}
\end{array}
if x < 2.7e26Initial program 93.6%
sqr-pow93.5%
sqr-pow93.3%
difference-of-squares97.3%
metadata-eval97.3%
pow297.3%
metadata-eval97.3%
pow297.3%
metadata-eval97.3%
pow297.3%
metadata-eval97.3%
pow297.3%
Applied egg-rr97.3%
Taylor expanded in x around 0 70.6%
unpow270.6%
mul-1-neg70.6%
Simplified70.6%
if 2.7e26 < x Initial program 64.8%
sqr-pow64.8%
sqr-pow64.8%
difference-of-squares85.1%
metadata-eval85.1%
pow285.1%
metadata-eval85.1%
pow285.1%
metadata-eval85.1%
pow285.1%
metadata-eval85.1%
pow285.1%
Applied egg-rr85.1%
Taylor expanded in x around inf 79.6%
unpow279.6%
Simplified79.6%
Final simplification72.5%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= y 1.2e+139) (* (* x x) (+ (* x x) (* y y))) (* (* x x) (* y (- y)))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 1.2e+139) {
tmp = (x * x) * ((x * x) + (y * y));
} else {
tmp = (x * x) * (y * -y);
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.2d+139) then
tmp = (x * x) * ((x * x) + (y * y))
else
tmp = (x * x) * (y * -y)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 1.2e+139) {
tmp = (x * x) * ((x * x) + (y * y));
} else {
tmp = (x * x) * (y * -y);
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 1.2e+139: tmp = (x * x) * ((x * x) + (y * y)) else: tmp = (x * x) * (y * -y) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (y <= 1.2e+139) tmp = Float64(Float64(x * x) * Float64(Float64(x * x) + Float64(y * y))); else tmp = Float64(Float64(x * x) * Float64(y * Float64(-y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.2e+139) tmp = (x * x) * ((x * x) + (y * y)); else tmp = (x * x) * (y * -y); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 1.2e+139], N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(y * (-y)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.2 \cdot 10^{+139}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot \left(-y\right)\right)\\
\end{array}
\end{array}
if y < 1.20000000000000004e139Initial program 90.7%
sqr-pow90.7%
sqr-pow90.5%
difference-of-squares96.5%
metadata-eval96.5%
pow296.5%
metadata-eval96.5%
pow296.5%
metadata-eval96.5%
pow296.5%
metadata-eval96.5%
pow296.5%
Applied egg-rr96.5%
Taylor expanded in x around inf 61.8%
unpow261.8%
Simplified61.8%
if 1.20000000000000004e139 < y Initial program 70.0%
sqr-pow70.0%
sqr-pow70.0%
difference-of-squares85.0%
metadata-eval85.0%
pow285.0%
metadata-eval85.0%
pow285.0%
metadata-eval85.0%
pow285.0%
metadata-eval85.0%
pow285.0%
Applied egg-rr85.0%
Taylor expanded in x around 0 87.5%
unpow287.5%
mul-1-neg87.5%
Simplified87.5%
Taylor expanded in x around inf 52.7%
mul-1-neg52.7%
unpow252.7%
unpow252.7%
*-commutative52.7%
Simplified52.7%
Final simplification60.4%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= y 1.05e+137) (* (* x x) (* y y)) (* (* x x) (* y (- y)))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 1.05e+137) {
tmp = (x * x) * (y * y);
} else {
tmp = (x * x) * (y * -y);
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.05d+137) then
tmp = (x * x) * (y * y)
else
tmp = (x * x) * (y * -y)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 1.05e+137) {
tmp = (x * x) * (y * y);
} else {
tmp = (x * x) * (y * -y);
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 1.05e+137: tmp = (x * x) * (y * y) else: tmp = (x * x) * (y * -y) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (y <= 1.05e+137) tmp = Float64(Float64(x * x) * Float64(y * y)); else tmp = Float64(Float64(x * x) * Float64(y * Float64(-y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.05e+137) tmp = (x * x) * (y * y); else tmp = (x * x) * (y * -y); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 1.05e+137], N[(N[(x * x), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(y * (-y)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.05 \cdot 10^{+137}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot \left(-y\right)\right)\\
\end{array}
\end{array}
if y < 1.05e137Initial program 90.7%
sqr-pow90.7%
sqr-pow90.5%
difference-of-squares96.5%
metadata-eval96.5%
pow296.5%
metadata-eval96.5%
pow296.5%
metadata-eval96.5%
pow296.5%
metadata-eval96.5%
pow296.5%
Applied egg-rr96.5%
Taylor expanded in x around inf 61.8%
unpow261.8%
Simplified61.8%
Taylor expanded in x around 0 34.7%
unpow234.7%
unpow234.7%
*-commutative34.7%
Simplified34.7%
if 1.05e137 < y Initial program 70.0%
sqr-pow70.0%
sqr-pow70.0%
difference-of-squares85.0%
metadata-eval85.0%
pow285.0%
metadata-eval85.0%
pow285.0%
metadata-eval85.0%
pow285.0%
metadata-eval85.0%
pow285.0%
Applied egg-rr85.0%
Taylor expanded in x around 0 87.5%
unpow287.5%
mul-1-neg87.5%
Simplified87.5%
Taylor expanded in x around inf 52.7%
mul-1-neg52.7%
unpow252.7%
unpow252.7%
*-commutative52.7%
Simplified52.7%
Final simplification37.5%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (* (* x x) (* y y)))
y = abs(y);
double code(double x, double y) {
return (x * x) * (y * y);
}
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * x) * (y * y)
end function
y = Math.abs(y);
public static double code(double x, double y) {
return (x * x) * (y * y);
}
y = abs(y) def code(x, y): return (x * x) * (y * y)
y = abs(y) function code(x, y) return Float64(Float64(x * x) * Float64(y * y)) end
y = abs(y) function tmp = code(x, y) tmp = (x * x) * (y * y); end
NOTE: y should be positive before calling this function code[x_, y_] := N[(N[(x * x), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y = |y|\\
\\
\left(x \cdot x\right) \cdot \left(y \cdot y\right)
\end{array}
Initial program 87.5%
sqr-pow87.4%
sqr-pow87.3%
difference-of-squares94.7%
metadata-eval94.7%
pow294.7%
metadata-eval94.7%
pow294.7%
metadata-eval94.7%
pow294.7%
metadata-eval94.7%
pow294.7%
Applied egg-rr94.7%
Taylor expanded in x around inf 54.1%
unpow254.1%
Simplified54.1%
Taylor expanded in x around 0 31.3%
unpow231.3%
unpow231.3%
*-commutative31.3%
Simplified31.3%
Final simplification31.3%
herbie shell --seed 2023290
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))