
(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 (- (/ 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 94.6%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ x (* y y)))) (if (<= t_0 -2000.0) t_0 (if (<= t_0 1.0) (- (* y y) 3.0) t_0))))
double code(double x, double y) {
double t_0 = x / (y * y);
double tmp;
if (t_0 <= -2000.0) {
tmp = t_0;
} else if (t_0 <= 1.0) {
tmp = (y * y) - 3.0;
} else {
tmp = t_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 <= (-2000.0d0)) then
tmp = t_0
else if (t_0 <= 1.0d0) then
tmp = (y * y) - 3.0d0
else
tmp = t_0
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 <= -2000.0) {
tmp = t_0;
} else if (t_0 <= 1.0) {
tmp = (y * y) - 3.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x / (y * y) tmp = 0 if t_0 <= -2000.0: tmp = t_0 elif t_0 <= 1.0: tmp = (y * y) - 3.0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x / Float64(y * y)) tmp = 0.0 if (t_0 <= -2000.0) tmp = t_0; elseif (t_0 <= 1.0) tmp = Float64(Float64(y * y) - 3.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x / (y * y); tmp = 0.0; if (t_0 <= -2000.0) tmp = t_0; elseif (t_0 <= 1.0) tmp = (y * y) - 3.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2000.0], t$95$0, If[LessEqual[t$95$0, 1.0], N[(N[(y * y), $MachinePrecision] - 3.0), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y \cdot y}\\
\mathbf{if}\;t\_0 \leq -2000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;y \cdot y - 3\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (/.f64 x (*.f64 y y)) < -2e3 or 1 < (/.f64 x (*.f64 y y)) Initial program 89.3%
Taylor expanded in x around 0
Applied rewrites87.6%
if -2e3 < (/.f64 x (*.f64 y y)) < 1Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites13.1%
(FPCore (x y) :precision binary64 (- (* y y) 3.0))
double code(double x, double y) {
return (y * y) - 3.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (y * y) - 3.0d0
end function
public static double code(double x, double y) {
return (y * y) - 3.0;
}
def code(x, y): return (y * y) - 3.0
function code(x, y) return Float64(Float64(y * y) - 3.0) end
function tmp = code(x, y) tmp = (y * y) - 3.0; end
code[x_, y_] := N[(N[(y * y), $MachinePrecision] - 3.0), $MachinePrecision]
\begin{array}{l}
\\
y \cdot y - 3
\end{array}
Initial program 94.6%
Taylor expanded in x around 0
Applied rewrites7.8%
(FPCore (x y) :precision binary64 (* y y))
double code(double x, double y) {
return y * y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y * y
end function
public static double code(double x, double y) {
return y * y;
}
def code(x, y): return y * y
function code(x, y) return Float64(y * y) end
function tmp = code(x, y) tmp = y * y; end
code[x_, y_] := N[(y * y), $MachinePrecision]
\begin{array}{l}
\\
y \cdot y
\end{array}
Initial program 94.6%
Taylor expanded in x around 0
Applied rewrites46.1%
Taylor expanded in x around 0
Applied rewrites1.8%
(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 2024313
(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))