
(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) 5e-289) (/ (/ x y) y) (- (/ x (* y y)) 3.0)))
double code(double x, double y) {
double tmp;
if ((y * y) <= 5e-289) {
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) <= 5d-289) 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) <= 5e-289) {
tmp = (x / y) / y;
} else {
tmp = (x / (y * y)) - 3.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (y * y) <= 5e-289: tmp = (x / y) / y else: tmp = (x / (y * y)) - 3.0 return tmp
function code(x, y) tmp = 0.0 if (Float64(y * y) <= 5e-289) 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) <= 5e-289) 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], 5e-289], 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 5 \cdot 10^{-289}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot y} - 3\\
\end{array}
\end{array}
if (*.f64 y y) < 5.00000000000000029e-289Initial program 78.4%
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
sqrt-prodN/A
rem-square-sqrtN/A
sqrt-unprodN/A
rem-sqrt-square-revN/A
neg-fabsN/A
rem-sqrt-squareN/A
sqrt-prodN/A
rem-square-sqrtN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
Applied rewrites37.5%
Taylor expanded in x around -inf
associate-*r/N/A
mul-1-negN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
mul-1-negN/A
remove-double-negN/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
if 5.00000000000000029e-289 < (*.f64 y y) Initial program 99.9%
(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 88.0%
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
sqrt-prodN/A
rem-square-sqrtN/A
sqrt-unprodN/A
rem-sqrt-square-revN/A
neg-fabsN/A
rem-sqrt-squareN/A
sqrt-prodN/A
rem-square-sqrtN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
Applied rewrites34.5%
Taylor expanded in x around -inf
associate-*r/N/A
mul-1-negN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
mul-1-negN/A
remove-double-negN/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6499.0
Applied rewrites99.0%
Applied rewrites87.2%
if -3 < (/.f64 x (*.f64 y y)) < 3Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites99.2%
Final simplification93.1%
(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.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6499.9
Applied rewrites99.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(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}
Initial program 93.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.9%
Taylor expanded in x around 0
Applied rewrites50.2%
(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 2024320
(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))