
(FPCore (x y) :precision binary64 (* x (/ (sin y) y)))
double code(double x, double y) {
return x * (sin(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (sin(y) / y)
end function
public static double code(double x, double y) {
return x * (Math.sin(y) / y);
}
def code(x, y): return x * (math.sin(y) / y)
function code(x, y) return Float64(x * Float64(sin(y) / y)) end
function tmp = code(x, y) tmp = x * (sin(y) / y); end
code[x_, y_] := N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{\sin y}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (* x (/ (sin y) y)))
double code(double x, double y) {
return x * (sin(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (sin(y) / y)
end function
public static double code(double x, double y) {
return x * (Math.sin(y) / y);
}
def code(x, y): return x * (math.sin(y) / y)
function code(x, y) return Float64(x * Float64(sin(y) / y)) end
function tmp = code(x, y) tmp = x * (sin(y) / y); end
code[x_, y_] := N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{\sin y}{y}
\end{array}
(FPCore (x y) :precision binary64 (* x (/ (sin y) y)))
double code(double x, double y) {
return x * (sin(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (sin(y) / y)
end function
public static double code(double x, double y) {
return x * (Math.sin(y) / y);
}
def code(x, y): return x * (math.sin(y) / y)
function code(x, y) return Float64(x * Float64(sin(y) / y)) end
function tmp = code(x, y) tmp = x * (sin(y) / y); end
code[x_, y_] := N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{\sin y}{y}
\end{array}
Initial program 99.8%
(FPCore (x y) :precision binary64 (if (<= y 4100000.0) (* x (+ 1.0 (* (* y y) -0.16666666666666666))) (* x (/ 6.0 (* y y)))))
double code(double x, double y) {
double tmp;
if (y <= 4100000.0) {
tmp = x * (1.0 + ((y * y) * -0.16666666666666666));
} else {
tmp = x * (6.0 / (y * y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 4100000.0d0) then
tmp = x * (1.0d0 + ((y * y) * (-0.16666666666666666d0)))
else
tmp = x * (6.0d0 / (y * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 4100000.0) {
tmp = x * (1.0 + ((y * y) * -0.16666666666666666));
} else {
tmp = x * (6.0 / (y * y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 4100000.0: tmp = x * (1.0 + ((y * y) * -0.16666666666666666)) else: tmp = x * (6.0 / (y * y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 4100000.0) tmp = Float64(x * Float64(1.0 + Float64(Float64(y * y) * -0.16666666666666666))); else tmp = Float64(x * Float64(6.0 / Float64(y * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 4100000.0) tmp = x * (1.0 + ((y * y) * -0.16666666666666666)); else tmp = x * (6.0 / (y * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 4100000.0], N[(x * N[(1.0 + N[(N[(y * y), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(6.0 / N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4100000:\\
\;\;\;\;x \cdot \left(1 + \left(y \cdot y\right) \cdot -0.16666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{6}{y \cdot y}\\
\end{array}
\end{array}
if y < 4.1e6Initial program 99.9%
Taylor expanded in y around 0
*-rgt-identityN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
distribute-lft-inN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6469.7%
Simplified69.7%
if 4.1e6 < y Initial program 99.5%
Taylor expanded in y around 0
*-rgt-identityN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
distribute-lft-inN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f642.1%
Simplified2.1%
flip-+N/A
/-lowering-/.f64N/A
Applied egg-rr1.1%
Taylor expanded in y around 0
Simplified28.4%
Taylor expanded in y around inf
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6428.4%
Simplified28.4%
Final simplification61.0%
(FPCore (x y) :precision binary64 (if (<= y 2.4) x (* x (/ 6.0 (* y y)))))
double code(double x, double y) {
double tmp;
if (y <= 2.4) {
tmp = x;
} else {
tmp = x * (6.0 / (y * y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 2.4d0) then
tmp = x
else
tmp = x * (6.0d0 / (y * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 2.4) {
tmp = x;
} else {
tmp = x * (6.0 / (y * y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2.4: tmp = x else: tmp = x * (6.0 / (y * y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 2.4) tmp = x; else tmp = Float64(x * Float64(6.0 / Float64(y * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 2.4) tmp = x; else tmp = x * (6.0 / (y * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2.4], x, N[(x * N[(6.0 / N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.4:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{6}{y \cdot y}\\
\end{array}
\end{array}
if y < 2.39999999999999991Initial program 99.9%
Taylor expanded in y around 0
Simplified70.1%
if 2.39999999999999991 < y Initial program 99.5%
Taylor expanded in y around 0
*-rgt-identityN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
distribute-lft-inN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f642.3%
Simplified2.3%
flip-+N/A
/-lowering-/.f64N/A
Applied egg-rr1.2%
Taylor expanded in y around 0
Simplified27.9%
Taylor expanded in y around inf
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6427.9%
Simplified27.9%
(FPCore (x y) :precision binary64 (* x (/ 1.0 (+ 1.0 (* (* y y) 0.16666666666666666)))))
double code(double x, double y) {
return x * (1.0 / (1.0 + ((y * y) * 0.16666666666666666)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (1.0d0 / (1.0d0 + ((y * y) * 0.16666666666666666d0)))
end function
public static double code(double x, double y) {
return x * (1.0 / (1.0 + ((y * y) * 0.16666666666666666)));
}
def code(x, y): return x * (1.0 / (1.0 + ((y * y) * 0.16666666666666666)))
function code(x, y) return Float64(x * Float64(1.0 / Float64(1.0 + Float64(Float64(y * y) * 0.16666666666666666)))) end
function tmp = code(x, y) tmp = x * (1.0 / (1.0 + ((y * y) * 0.16666666666666666))); end
code[x_, y_] := N[(x * N[(1.0 / N[(1.0 + N[(N[(y * y), $MachinePrecision] * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{1}{1 + \left(y \cdot y\right) \cdot 0.16666666666666666}
\end{array}
Initial program 99.8%
Taylor expanded in y around 0
*-rgt-identityN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
distribute-lft-inN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6455.5%
Simplified55.5%
flip-+N/A
/-lowering-/.f64N/A
Applied egg-rr55.0%
Taylor expanded in y around 0
Simplified68.2%
(FPCore (x y) :precision binary64 (/ x (+ 1.0 (* (* y y) 0.16666666666666666))))
double code(double x, double y) {
return x / (1.0 + ((y * y) * 0.16666666666666666));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x / (1.0d0 + ((y * y) * 0.16666666666666666d0))
end function
public static double code(double x, double y) {
return x / (1.0 + ((y * y) * 0.16666666666666666));
}
def code(x, y): return x / (1.0 + ((y * y) * 0.16666666666666666))
function code(x, y) return Float64(x / Float64(1.0 + Float64(Float64(y * y) * 0.16666666666666666))) end
function tmp = code(x, y) tmp = x / (1.0 + ((y * y) * 0.16666666666666666)); end
code[x_, y_] := N[(x / N[(1.0 + N[(N[(y * y), $MachinePrecision] * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{1 + \left(y \cdot y\right) \cdot 0.16666666666666666}
\end{array}
Initial program 99.8%
Taylor expanded in y around 0
*-rgt-identityN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
distribute-lft-inN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6455.5%
Simplified55.5%
flip-+N/A
/-lowering-/.f64N/A
Applied egg-rr55.0%
Taylor expanded in y around 0
Simplified68.2%
Taylor expanded in x around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6468.2%
Simplified68.2%
Final simplification68.2%
(FPCore (x y) :precision binary64 (if (<= y 7e+84) x 0.0))
double code(double x, double y) {
double tmp;
if (y <= 7e+84) {
tmp = x;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 7d+84) then
tmp = x
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 7e+84) {
tmp = x;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 7e+84: tmp = x else: tmp = 0.0 return tmp
function code(x, y) tmp = 0.0 if (y <= 7e+84) tmp = x; else tmp = 0.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 7e+84) tmp = x; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 7e+84], x, 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7 \cdot 10^{+84}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if y < 6.9999999999999998e84Initial program 99.8%
Taylor expanded in y around 0
Simplified66.2%
if 6.9999999999999998e84 < y Initial program 99.5%
Applied egg-rr34.6%
(FPCore (x y) :precision binary64 0.0)
double code(double x, double y) {
return 0.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.0d0
end function
public static double code(double x, double y) {
return 0.0;
}
def code(x, y): return 0.0
function code(x, y) return 0.0 end
function tmp = code(x, y) tmp = 0.0; end
code[x_, y_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 99.8%
Applied egg-rr15.8%
herbie shell --seed 2024161
(FPCore (x y)
:name "Linear.Quaternion:$cexp from linear-1.19.1.3"
:precision binary64
(* x (/ (sin y) y)))