
(FPCore (x y) :precision binary64 (- (/ x (* y y)) 3.0))
double code(double x, double y) {
return (x / (y * y)) - 3.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x / (y * y)) - 3.0d0
end function
public static double code(double x, double y) {
return (x / (y * y)) - 3.0;
}
def code(x, y): return (x / (y * y)) - 3.0
function code(x, y) return Float64(Float64(x / Float64(y * y)) - 3.0) end
function tmp = code(x, y) tmp = (x / (y * y)) - 3.0; end
code[x_, y_] := N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] - 3.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y \cdot y} - 3
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (- (/ x (* y y)) 3.0))
double code(double x, double y) {
return (x / (y * y)) - 3.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x / (y * y)) - 3.0d0
end function
public static double code(double x, double y) {
return (x / (y * y)) - 3.0;
}
def code(x, y): return (x / (y * y)) - 3.0
function code(x, y) return Float64(Float64(x / Float64(y * y)) - 3.0) end
function tmp = code(x, y) tmp = (x / (y * y)) - 3.0; end
code[x_, y_] := N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] - 3.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y \cdot y} - 3
\end{array}
(FPCore (x y) :precision binary64 (if (<= (* y y) 1e-315) (/ (/ x y) y) (- (/ x (* y y)) 3.0)))
double code(double x, double y) {
double tmp;
if ((y * y) <= 1e-315) {
tmp = (x / y) / y;
} else {
tmp = (x / (y * y)) - 3.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y * y) <= 1d-315) then
tmp = (x / y) / y
else
tmp = (x / (y * y)) - 3.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y * y) <= 1e-315) {
tmp = (x / y) / y;
} else {
tmp = (x / (y * y)) - 3.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (y * y) <= 1e-315: tmp = (x / y) / y else: tmp = (x / (y * y)) - 3.0 return tmp
function code(x, y) tmp = 0.0 if (Float64(y * y) <= 1e-315) tmp = Float64(Float64(x / y) / y); else tmp = Float64(Float64(x / Float64(y * y)) - 3.0); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y * y) <= 1e-315) tmp = (x / y) / y; else tmp = (x / (y * y)) - 3.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(y * y), $MachinePrecision], 1e-315], N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision], N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] - 3.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot y \leq 10^{-315}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot y} - 3\\
\end{array}
\end{array}
if (*.f64 y y) < 9.999999985e-316Initial program 73.1%
Taylor expanded in x around inf 73.1%
*-rgt-identity73.1%
associate-*r/71.4%
unpow271.4%
associate-/r*71.4%
*-rgt-identity71.4%
associate-/l*71.4%
unpow-171.4%
unpow-171.4%
pow-sqr71.4%
metadata-eval71.4%
Simplified71.4%
metadata-eval71.4%
pow-sqr71.4%
inv-pow71.4%
inv-pow71.4%
un-div-inv71.4%
Applied egg-rr71.4%
associate-*r/99.8%
div-inv99.9%
Applied egg-rr99.9%
if 9.999999985e-316 < (*.f64 y y) Initial program 99.9%
(FPCore (x y) :precision binary64 (if (<= y 1.55e+64) (/ (/ x y) y) -3.0))
double code(double x, double y) {
double tmp;
if (y <= 1.55e+64) {
tmp = (x / y) / y;
} else {
tmp = -3.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.55d+64) then
tmp = (x / y) / y
else
tmp = -3.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1.55e+64) {
tmp = (x / y) / y;
} else {
tmp = -3.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.55e+64: tmp = (x / y) / y else: tmp = -3.0 return tmp
function code(x, y) tmp = 0.0 if (y <= 1.55e+64) tmp = Float64(Float64(x / y) / y); else tmp = -3.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.55e+64) tmp = (x / y) / y; else tmp = -3.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.55e+64], N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision], -3.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.55 \cdot 10^{+64}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\
\mathbf{else}:\\
\;\;\;\;-3\\
\end{array}
\end{array}
if y < 1.55e64Initial program 91.9%
Taylor expanded in x around inf 55.0%
*-rgt-identity55.0%
associate-*r/54.4%
unpow254.4%
associate-/r*54.4%
*-rgt-identity54.4%
associate-/l*54.3%
unpow-154.3%
unpow-154.3%
pow-sqr54.5%
metadata-eval54.5%
Simplified54.5%
metadata-eval54.5%
pow-sqr54.3%
inv-pow54.3%
inv-pow54.3%
un-div-inv54.4%
Applied egg-rr54.4%
associate-*r/62.9%
div-inv62.9%
Applied egg-rr62.9%
if 1.55e64 < y Initial program 100.0%
Taylor expanded in x around 0 96.0%
(FPCore (x y) :precision binary64 (- (/ (/ x y) y) 3.0))
double code(double x, double y) {
return ((x / y) / y) - 3.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x / y) / y) - 3.0d0
end function
public static double code(double x, double y) {
return ((x / y) / y) - 3.0;
}
def code(x, y): return ((x / y) / y) - 3.0
function code(x, y) return Float64(Float64(Float64(x / y) / y) - 3.0) end
function tmp = code(x, y) tmp = ((x / y) / y) - 3.0; end
code[x_, y_] := N[(N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision] - 3.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{x}{y}}{y} - 3
\end{array}
Initial program 93.4%
associate-/r*99.9%
clear-num99.8%
inv-pow99.8%
Applied egg-rr99.8%
unpow-199.8%
clear-num99.9%
Applied egg-rr99.9%
(FPCore (x y) :precision binary64 -3.0)
double code(double x, double y) {
return -3.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -3.0d0
end function
public static double code(double x, double y) {
return -3.0;
}
def code(x, y): return -3.0
function code(x, y) return -3.0 end
function tmp = code(x, y) tmp = -3.0; end
code[x_, y_] := -3.0
\begin{array}{l}
\\
-3
\end{array}
Initial program 93.4%
Taylor expanded in x around 0 49.9%
(FPCore (x y) :precision binary64 (- (/ (/ x y) y) 3.0))
double code(double x, double y) {
return ((x / y) / y) - 3.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x / y) / y) - 3.0d0
end function
public static double code(double x, double y) {
return ((x / y) / y) - 3.0;
}
def code(x, y): return ((x / y) / y) - 3.0
function code(x, y) return Float64(Float64(Float64(x / y) / y) - 3.0) end
function tmp = code(x, y) tmp = ((x / y) / y) - 3.0; end
code[x_, y_] := N[(N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision] - 3.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{x}{y}}{y} - 3
\end{array}
herbie shell --seed 2024170
(FPCore (x y)
:name "Statistics.Sample:$skurtosis from math-functions-0.1.5.2"
:precision binary64
:alt
(! :herbie-platform default (- (/ (/ x y) y) 3))
(- (/ x (* y y)) 3.0))