
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / y)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / y)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / y)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
Initial program 100.0%
(FPCore (x y) :precision binary64 (if (<= (/ (sinh y) y) 1.000000001) (sin x) (/ (* x (sinh y)) y)))
double code(double x, double y) {
double tmp;
if ((sinh(y) / y) <= 1.000000001) {
tmp = sin(x);
} else {
tmp = (x * sinh(y)) / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((sinh(y) / y) <= 1.000000001d0) then
tmp = sin(x)
else
tmp = (x * sinh(y)) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((Math.sinh(y) / y) <= 1.000000001) {
tmp = Math.sin(x);
} else {
tmp = (x * Math.sinh(y)) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if (math.sinh(y) / y) <= 1.000000001: tmp = math.sin(x) else: tmp = (x * math.sinh(y)) / y return tmp
function code(x, y) tmp = 0.0 if (Float64(sinh(y) / y) <= 1.000000001) tmp = sin(x); else tmp = Float64(Float64(x * sinh(y)) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((sinh(y) / y) <= 1.000000001) tmp = sin(x); else tmp = (x * sinh(y)) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision], 1.000000001], N[Sin[x], $MachinePrecision], N[(N[(x * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sinh y}{y} \leq 1.000000001:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \sinh y}{y}\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 y) y) < 1.0000000010000001Initial program 100.0%
Taylor expanded in y around 0 99.7%
if 1.0000000010000001 < (/.f64 (sinh.f64 y) y) Initial program 100.0%
Taylor expanded in x around 0 76.3%
associate-*r/76.3%
Applied egg-rr76.3%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ (sinh y) y))) (if (<= t_0 1.000000001) (sin x) (* x t_0))))
double code(double x, double y) {
double t_0 = sinh(y) / y;
double tmp;
if (t_0 <= 1.000000001) {
tmp = sin(x);
} else {
tmp = x * 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 = sinh(y) / y
if (t_0 <= 1.000000001d0) then
tmp = sin(x)
else
tmp = x * t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.sinh(y) / y;
double tmp;
if (t_0 <= 1.000000001) {
tmp = Math.sin(x);
} else {
tmp = x * t_0;
}
return tmp;
}
def code(x, y): t_0 = math.sinh(y) / y tmp = 0 if t_0 <= 1.000000001: tmp = math.sin(x) else: tmp = x * t_0 return tmp
function code(x, y) t_0 = Float64(sinh(y) / y) tmp = 0.0 if (t_0 <= 1.000000001) tmp = sin(x); else tmp = Float64(x * t_0); end return tmp end
function tmp_2 = code(x, y) t_0 = sinh(y) / y; tmp = 0.0; if (t_0 <= 1.000000001) tmp = sin(x); else tmp = x * t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[t$95$0, 1.000000001], N[Sin[x], $MachinePrecision], N[(x * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sinh y}{y}\\
\mathbf{if}\;t\_0 \leq 1.000000001:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot t\_0\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 y) y) < 1.0000000010000001Initial program 100.0%
Taylor expanded in y around 0 99.7%
if 1.0000000010000001 < (/.f64 (sinh.f64 y) y) Initial program 100.0%
Taylor expanded in x around 0 76.3%
(FPCore (x y) :precision binary64 (if (<= y 620000.0) (sin x) (* x (+ 1.0 (* (/ (* x (* x y)) y) -0.16666666666666666)))))
double code(double x, double y) {
double tmp;
if (y <= 620000.0) {
tmp = sin(x);
} else {
tmp = x * (1.0 + (((x * (x * y)) / y) * -0.16666666666666666));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 620000.0d0) then
tmp = sin(x)
else
tmp = x * (1.0d0 + (((x * (x * y)) / y) * (-0.16666666666666666d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 620000.0) {
tmp = Math.sin(x);
} else {
tmp = x * (1.0 + (((x * (x * y)) / y) * -0.16666666666666666));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 620000.0: tmp = math.sin(x) else: tmp = x * (1.0 + (((x * (x * y)) / y) * -0.16666666666666666)) return tmp
function code(x, y) tmp = 0.0 if (y <= 620000.0) tmp = sin(x); else tmp = Float64(x * Float64(1.0 + Float64(Float64(Float64(x * Float64(x * y)) / y) * -0.16666666666666666))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 620000.0) tmp = sin(x); else tmp = x * (1.0 + (((x * (x * y)) / y) * -0.16666666666666666)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 620000.0], N[Sin[x], $MachinePrecision], N[(x * N[(1.0 + N[(N[(N[(x * N[(x * y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 620000:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + \frac{x \cdot \left(x \cdot y\right)}{y} \cdot -0.16666666666666666\right)\\
\end{array}
\end{array}
if y < 6.2e5Initial program 100.0%
Taylor expanded in y around 0 63.8%
if 6.2e5 < y Initial program 100.0%
Taylor expanded in y around 0 2.7%
Taylor expanded in x around 0 16.2%
*-commutative16.2%
Simplified16.2%
unpow216.2%
*-un-lft-identity16.2%
associate-*r*16.2%
*-inverses16.2%
associate-/l*17.5%
associate-*l/18.8%
*-commutative18.8%
Applied egg-rr18.8%
Final simplification51.7%
(FPCore (x y) :precision binary64 (if (<= x 5.1e+218) (* x (+ 1.0 (* (/ (* x (* x y)) y) -0.16666666666666666))) (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (x <= 5.1e+218) {
tmp = x * (1.0 + (((x * (x * y)) / y) * -0.16666666666666666));
} else {
tmp = (x * y) / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 5.1d+218) then
tmp = x * (1.0d0 + (((x * (x * y)) / y) * (-0.16666666666666666d0)))
else
tmp = (x * y) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 5.1e+218) {
tmp = x * (1.0 + (((x * (x * y)) / y) * -0.16666666666666666));
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 5.1e+218: tmp = x * (1.0 + (((x * (x * y)) / y) * -0.16666666666666666)) else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (x <= 5.1e+218) tmp = Float64(x * Float64(1.0 + Float64(Float64(Float64(x * Float64(x * y)) / y) * -0.16666666666666666))); else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 5.1e+218) tmp = x * (1.0 + (((x * (x * y)) / y) * -0.16666666666666666)); else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 5.1e+218], N[(x * N[(1.0 + N[(N[(N[(x * N[(x * y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.1 \cdot 10^{+218}:\\
\;\;\;\;x \cdot \left(1 + \frac{x \cdot \left(x \cdot y\right)}{y} \cdot -0.16666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if x < 5.0999999999999999e218Initial program 100.0%
Taylor expanded in y around 0 47.4%
Taylor expanded in x around 0 34.4%
*-commutative34.4%
Simplified34.4%
unpow234.4%
*-un-lft-identity34.4%
associate-*r*34.4%
*-inverses34.4%
associate-/l*34.8%
associate-*l/35.6%
*-commutative35.6%
Applied egg-rr35.6%
if 5.0999999999999999e218 < x Initial program 100.0%
Taylor expanded in x around 0 35.7%
associate-*r/35.7%
Applied egg-rr35.7%
Taylor expanded in y around 0 31.1%
Final simplification35.2%
(FPCore (x y) :precision binary64 (if (<= x 5.1e+218) (* x (+ 1.0 (* -0.16666666666666666 (* x x)))) (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (x <= 5.1e+218) {
tmp = x * (1.0 + (-0.16666666666666666 * (x * x)));
} else {
tmp = (x * y) / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 5.1d+218) then
tmp = x * (1.0d0 + ((-0.16666666666666666d0) * (x * x)))
else
tmp = (x * y) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 5.1e+218) {
tmp = x * (1.0 + (-0.16666666666666666 * (x * x)));
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 5.1e+218: tmp = x * (1.0 + (-0.16666666666666666 * (x * x))) else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (x <= 5.1e+218) tmp = Float64(x * Float64(1.0 + Float64(-0.16666666666666666 * Float64(x * x)))); else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 5.1e+218) tmp = x * (1.0 + (-0.16666666666666666 * (x * x))); else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 5.1e+218], N[(x * N[(1.0 + N[(-0.16666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.1 \cdot 10^{+218}:\\
\;\;\;\;x \cdot \left(1 + -0.16666666666666666 \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if x < 5.0999999999999999e218Initial program 100.0%
Taylor expanded in y around 0 47.4%
Taylor expanded in x around 0 34.4%
*-commutative34.4%
Simplified34.4%
unpow234.4%
Applied egg-rr34.4%
if 5.0999999999999999e218 < x Initial program 100.0%
Taylor expanded in x around 0 35.7%
associate-*r/35.7%
Applied egg-rr35.7%
Taylor expanded in y around 0 31.1%
Final simplification34.1%
(FPCore (x y) :precision binary64 (if (<= x 5e+102) x (/ (* x y) y)))
double code(double x, double y) {
double tmp;
if (x <= 5e+102) {
tmp = x;
} else {
tmp = (x * y) / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 5d+102) then
tmp = x
else
tmp = (x * y) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 5e+102) {
tmp = x;
} else {
tmp = (x * y) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 5e+102: tmp = x else: tmp = (x * y) / y return tmp
function code(x, y) tmp = 0.0 if (x <= 5e+102) tmp = x; else tmp = Float64(Float64(x * y) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 5e+102) tmp = x; else tmp = (x * y) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 5e+102], x, N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{+102}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\end{array}
\end{array}
if x < 5e102Initial program 100.0%
Taylor expanded in y around 0 47.1%
Taylor expanded in x around 0 31.0%
if 5e102 < x Initial program 100.0%
Taylor expanded in x around 0 28.7%
associate-*r/28.7%
Applied egg-rr28.7%
Taylor expanded in y around 0 18.6%
(FPCore (x y) :precision binary64 x)
double code(double x, double y) {
return x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x
end function
public static double code(double x, double y) {
return x;
}
def code(x, y): return x
function code(x, y) return x end
function tmp = code(x, y) tmp = x; end
code[x_, y_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 100.0%
Taylor expanded in y around 0 47.4%
Taylor expanded in x around 0 25.9%
herbie shell --seed 2024110
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))