
(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 5 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-296) (/ (/ x y) y) (- (/ x (* y y)) 3.0)))
double code(double x, double y) {
double tmp;
if ((y * y) <= 1e-296) {
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-296) 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-296) {
tmp = (x / y) / y;
} else {
tmp = (x / (y * y)) - 3.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (y * y) <= 1e-296: 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-296) 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-296) 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-296], 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^{-296}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot y} - 3\\
\end{array}
\end{array}
if (*.f64 y y) < 1e-296Initial program 85.0%
Taylor expanded in x around inf 85.0%
*-rgt-identity85.0%
associate-*r/83.5%
unpow283.5%
associate-/r*83.5%
*-rgt-identity83.5%
associate-/l*83.5%
unpow-183.5%
unpow-183.5%
pow-sqr83.5%
metadata-eval83.5%
Simplified83.5%
metadata-eval83.5%
pow-sqr83.5%
inv-pow83.5%
inv-pow83.5%
associate-*r*99.8%
div-inv99.9%
un-div-inv100.0%
Applied egg-rr100.0%
if 1e-296 < (*.f64 y y) Initial program 99.9%
(FPCore (x y) :precision binary64 (- (pow (/ y (/ x y)) -1.0) 3.0))
double code(double x, double y) {
return pow((y / (x / y)), -1.0) - 3.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((y / (x / y)) ** (-1.0d0)) - 3.0d0
end function
public static double code(double x, double y) {
return Math.pow((y / (x / y)), -1.0) - 3.0;
}
def code(x, y): return math.pow((y / (x / y)), -1.0) - 3.0
function code(x, y) return Float64((Float64(y / Float64(x / y)) ^ -1.0) - 3.0) end
function tmp = code(x, y) tmp = ((y / (x / y)) ^ -1.0) - 3.0; end
code[x_, y_] := N[(N[Power[N[(y / N[(x / y), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision] - 3.0), $MachinePrecision]
\begin{array}{l}
\\
{\left(\frac{y}{\frac{x}{y}}\right)}^{-1} - 3
\end{array}
Initial program 96.7%
associate-/r*99.9%
clear-num99.9%
inv-pow99.9%
Applied egg-rr99.9%
(FPCore (x y) :precision binary64 (if (<= y 8100.0) (/ (/ x y) y) -3.0))
double code(double x, double y) {
double tmp;
if (y <= 8100.0) {
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 <= 8100.0d0) 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 <= 8100.0) {
tmp = (x / y) / y;
} else {
tmp = -3.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 8100.0: tmp = (x / y) / y else: tmp = -3.0 return tmp
function code(x, y) tmp = 0.0 if (y <= 8100.0) 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 <= 8100.0) tmp = (x / y) / y; else tmp = -3.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 8100.0], N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision], -3.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8100:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\
\mathbf{else}:\\
\;\;\;\;-3\\
\end{array}
\end{array}
if y < 8100Initial program 95.4%
Taylor expanded in x around inf 56.2%
*-rgt-identity56.2%
associate-*r/55.7%
unpow255.7%
associate-/r*55.8%
*-rgt-identity55.8%
associate-/l*55.7%
unpow-155.7%
unpow-155.7%
pow-sqr55.7%
metadata-eval55.7%
Simplified55.7%
metadata-eval55.7%
pow-sqr55.7%
inv-pow55.7%
inv-pow55.7%
associate-*r*60.5%
div-inv60.6%
un-div-inv60.7%
Applied egg-rr60.7%
if 8100 < y Initial program 100.0%
Taylor expanded in x around 0 88.9%
(FPCore (x y) :precision binary64 (- (* (/ x y) (/ 1.0 y)) 3.0))
double code(double x, double y) {
return ((x / y) * (1.0 / y)) - 3.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x / y) * (1.0d0 / y)) - 3.0d0
end function
public static double code(double x, double y) {
return ((x / y) * (1.0 / y)) - 3.0;
}
def code(x, y): return ((x / y) * (1.0 / y)) - 3.0
function code(x, y) return Float64(Float64(Float64(x / y) * Float64(1.0 / y)) - 3.0) end
function tmp = code(x, y) tmp = ((x / y) * (1.0 / y)) - 3.0; end
code[x_, y_] := N[(N[(N[(x / y), $MachinePrecision] * N[(1.0 / y), $MachinePrecision]), $MachinePrecision] - 3.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y} \cdot \frac{1}{y} - 3
\end{array}
Initial program 96.7%
associate-/r*99.9%
div-inv99.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 96.7%
Taylor expanded in x around 0 54.6%
(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 2024185
(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))