
(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 6 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 (- (/ (/ 1.0 y) (/ y x)) 3.0))
double code(double x, double y) {
return ((1.0 / y) / (y / x)) - 3.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((1.0d0 / y) / (y / x)) - 3.0d0
end function
public static double code(double x, double y) {
return ((1.0 / y) / (y / x)) - 3.0;
}
def code(x, y): return ((1.0 / y) / (y / x)) - 3.0
function code(x, y) return Float64(Float64(Float64(1.0 / y) / Float64(y / x)) - 3.0) end
function tmp = code(x, y) tmp = ((1.0 / y) / (y / x)) - 3.0; end
code[x_, y_] := N[(N[(N[(1.0 / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] - 3.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{y}}{\frac{y}{x}} - 3
\end{array}
Initial program 96.2%
associate-/r*99.9%
clear-num99.9%
inv-pow99.9%
Applied egg-rr99.9%
unpow-199.9%
associate-/r/99.9%
*-commutative99.9%
associate-/r*99.9%
Applied egg-rr99.9%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ x (* y y)))) (if (or (<= t_0 -200000000000.0) (not (<= t_0 1e-16))) (/ (/ x y) y) -3.0)))
double code(double x, double y) {
double t_0 = x / (y * y);
double tmp;
if ((t_0 <= -200000000000.0) || !(t_0 <= 1e-16)) {
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) :: t_0
real(8) :: tmp
t_0 = x / (y * y)
if ((t_0 <= (-200000000000.0d0)) .or. (.not. (t_0 <= 1d-16))) then
tmp = (x / y) / y
else
tmp = -3.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (y * y);
double tmp;
if ((t_0 <= -200000000000.0) || !(t_0 <= 1e-16)) {
tmp = (x / y) / y;
} else {
tmp = -3.0;
}
return tmp;
}
def code(x, y): t_0 = x / (y * y) tmp = 0 if (t_0 <= -200000000000.0) or not (t_0 <= 1e-16): tmp = (x / y) / y else: tmp = -3.0 return tmp
function code(x, y) t_0 = Float64(x / Float64(y * y)) tmp = 0.0 if ((t_0 <= -200000000000.0) || !(t_0 <= 1e-16)) tmp = Float64(Float64(x / y) / y); else tmp = -3.0; end return tmp end
function tmp_2 = code(x, y) t_0 = x / (y * y); tmp = 0.0; if ((t_0 <= -200000000000.0) || ~((t_0 <= 1e-16))) tmp = (x / y) / y; else tmp = -3.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -200000000000.0], N[Not[LessEqual[t$95$0, 1e-16]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision], -3.0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y \cdot y}\\
\mathbf{if}\;t\_0 \leq -200000000000 \lor \neg \left(t\_0 \leq 10^{-16}\right):\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\
\mathbf{else}:\\
\;\;\;\;-3\\
\end{array}
\end{array}
if (/.f64 x (*.f64 y y)) < -2e11 or 9.9999999999999998e-17 < (/.f64 x (*.f64 y y)) Initial program 93.2%
Taylor expanded in x around inf 91.5%
*-lft-identity91.5%
associate-*l/90.1%
unpow290.1%
associate-/r*90.2%
*-rgt-identity90.2%
associate-/l*90.0%
unpow-190.0%
unpow-190.0%
pow-sqr90.2%
metadata-eval90.2%
*-commutative90.2%
Simplified90.2%
metadata-eval90.2%
pow-flip90.1%
unpow290.1%
associate-/r*90.2%
Applied egg-rr90.2%
associate-*r/98.0%
div-inv98.1%
Applied egg-rr98.1%
if -2e11 < (/.f64 x (*.f64 y y)) < 9.9999999999999998e-17Initial program 100.0%
Taylor expanded in x around 0 99.5%
Final simplification98.7%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ x (* y y)))) (if (or (<= t_0 -3.0) (not (<= t_0 3.0))) t_0 -3.0)))
double code(double x, double y) {
double t_0 = x / (y * y);
double tmp;
if ((t_0 <= -3.0) || !(t_0 <= 3.0)) {
tmp = t_0;
} else {
tmp = -3.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)
if ((t_0 <= (-3.0d0)) .or. (.not. (t_0 <= 3.0d0))) then
tmp = t_0
else
tmp = -3.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (y * y);
double tmp;
if ((t_0 <= -3.0) || !(t_0 <= 3.0)) {
tmp = t_0;
} else {
tmp = -3.0;
}
return tmp;
}
def code(x, y): t_0 = x / (y * y) tmp = 0 if (t_0 <= -3.0) or not (t_0 <= 3.0): tmp = t_0 else: tmp = -3.0 return tmp
function code(x, y) t_0 = Float64(x / Float64(y * y)) tmp = 0.0 if ((t_0 <= -3.0) || !(t_0 <= 3.0)) tmp = t_0; else tmp = -3.0; end return tmp end
function tmp_2 = code(x, y) t_0 = x / (y * y); tmp = 0.0; if ((t_0 <= -3.0) || ~((t_0 <= 3.0))) tmp = t_0; else tmp = -3.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -3.0], N[Not[LessEqual[t$95$0, 3.0]], $MachinePrecision]], t$95$0, -3.0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y \cdot y}\\
\mathbf{if}\;t\_0 \leq -3 \lor \neg \left(t\_0 \leq 3\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-3\\
\end{array}
\end{array}
if (/.f64 x (*.f64 y y)) < -3 or 3 < (/.f64 x (*.f64 y y)) Initial program 93.2%
Taylor expanded in y around 0 93.2%
unpow293.2%
Applied egg-rr93.2%
Taylor expanded in x around inf 91.5%
if -3 < (/.f64 x (*.f64 y y)) < 3Initial program 100.0%
Taylor expanded in x around 0 99.5%
Final simplification95.1%
(FPCore (x y) :precision binary64 (if (<= (* y y) 2e-222) (/ (/ x y) y) (- (/ x (* y y)) 3.0)))
double code(double x, double y) {
double tmp;
if ((y * y) <= 2e-222) {
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) <= 2d-222) 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) <= 2e-222) {
tmp = (x / y) / y;
} else {
tmp = (x / (y * y)) - 3.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (y * y) <= 2e-222: tmp = (x / y) / y else: tmp = (x / (y * y)) - 3.0 return tmp
function code(x, y) tmp = 0.0 if (Float64(y * y) <= 2e-222) 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) <= 2e-222) 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], 2e-222], 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 2 \cdot 10^{-222}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot y} - 3\\
\end{array}
\end{array}
if (*.f64 y y) < 2.0000000000000001e-222Initial program 89.5%
Taylor expanded in x around inf 89.5%
*-lft-identity89.5%
associate-*l/87.3%
unpow287.3%
associate-/r*87.4%
*-rgt-identity87.4%
associate-/l*87.3%
unpow-187.3%
unpow-187.3%
pow-sqr87.4%
metadata-eval87.4%
*-commutative87.4%
Simplified87.4%
metadata-eval87.4%
pow-flip87.3%
unpow287.3%
associate-/r*87.4%
Applied egg-rr87.4%
associate-*r/99.8%
div-inv99.9%
Applied egg-rr99.9%
if 2.0000000000000001e-222 < (*.f64 y y) Initial program 99.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}
Initial program 96.2%
associate-/r*99.9%
clear-num99.9%
inv-pow99.9%
Applied egg-rr99.9%
unpow-199.9%
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 96.2%
Taylor expanded in x around 0 45.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 2024139
(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))