
(FPCore (x y) :precision binary64 (/ (* (sin x) (sinh y)) x))
double code(double x, double y) {
return (sin(x) * sinh(y)) / x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (sin(x) * sinh(y)) / x
end function
public static double code(double x, double y) {
return (Math.sin(x) * Math.sinh(y)) / x;
}
def code(x, y): return (math.sin(x) * math.sinh(y)) / x
function code(x, y) return Float64(Float64(sin(x) * sinh(y)) / x) end
function tmp = code(x, y) tmp = (sin(x) * sinh(y)) / x; end
code[x_, y_] := N[(N[(N[Sin[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin x \cdot \sinh y}{x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* (sin x) (sinh y)) x))
double code(double x, double y) {
return (sin(x) * sinh(y)) / x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (sin(x) * sinh(y)) / x
end function
public static double code(double x, double y) {
return (Math.sin(x) * Math.sinh(y)) / x;
}
def code(x, y): return (math.sin(x) * math.sinh(y)) / x
function code(x, y) return Float64(Float64(sin(x) * sinh(y)) / x) end
function tmp = code(x, y) tmp = (sin(x) * sinh(y)) / x; end
code[x_, y_] := N[(N[(N[Sin[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin x \cdot \sinh y}{x}
\end{array}
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) x)))
double code(double x, double y) {
return sin(x) * (sinh(y) / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / x)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / x);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / x)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / x)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / x); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{x}
\end{array}
Initial program 92.2%
associate-/l*99.9%
Simplified99.9%
(FPCore (x y) :precision binary64 (if (<= y 8500000000.0) (/ y (/ x (sin x))) (log1p (expm1 y))))
double code(double x, double y) {
double tmp;
if (y <= 8500000000.0) {
tmp = y / (x / sin(x));
} else {
tmp = log1p(expm1(y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= 8500000000.0) {
tmp = y / (x / Math.sin(x));
} else {
tmp = Math.log1p(Math.expm1(y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 8500000000.0: tmp = y / (x / math.sin(x)) else: tmp = math.log1p(math.expm1(y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 8500000000.0) tmp = Float64(y / Float64(x / sin(x))); else tmp = log1p(expm1(y)); end return tmp end
code[x_, y_] := If[LessEqual[y, 8500000000.0], N[(y / N[(x / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Log[1 + N[(Exp[y] - 1), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8500000000:\\
\;\;\;\;\frac{y}{\frac{x}{\sin x}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(y\right)\right)\\
\end{array}
\end{array}
if y < 8.5e9Initial program 89.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 55.8%
associate-/l*66.0%
Simplified66.0%
clear-num66.0%
un-div-inv66.0%
Applied egg-rr66.0%
if 8.5e9 < y Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 4.1%
associate-/l*4.1%
Simplified4.1%
associate-*r/4.1%
clear-num4.1%
*-commutative4.1%
Applied egg-rr4.1%
Taylor expanded in x around 0 3.6%
remove-double-div3.6%
log1p-expm1-u71.7%
Applied egg-rr71.7%
(FPCore (x y) :precision binary64 (if (<= x 4.5e-94) (/ (/ y x) (/ 1.0 x)) (* y (/ (sin x) x))))
double code(double x, double y) {
double tmp;
if (x <= 4.5e-94) {
tmp = (y / x) / (1.0 / x);
} else {
tmp = y * (sin(x) / x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 4.5d-94) then
tmp = (y / x) / (1.0d0 / x)
else
tmp = y * (sin(x) / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 4.5e-94) {
tmp = (y / x) / (1.0 / x);
} else {
tmp = y * (Math.sin(x) / x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 4.5e-94: tmp = (y / x) / (1.0 / x) else: tmp = y * (math.sin(x) / x) return tmp
function code(x, y) tmp = 0.0 if (x <= 4.5e-94) tmp = Float64(Float64(y / x) / Float64(1.0 / x)); else tmp = Float64(y * Float64(sin(x) / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 4.5e-94) tmp = (y / x) / (1.0 / x); else tmp = y * (sin(x) / x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 4.5e-94], N[(N[(y / x), $MachinePrecision] / N[(1.0 / x), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.5 \cdot 10^{-94}:\\
\;\;\;\;\frac{\frac{y}{x}}{\frac{1}{x}}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\end{array}
\end{array}
if x < 4.5000000000000002e-94Initial program 88.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 35.4%
*-commutative35.4%
associate-/l*66.5%
Applied egg-rr66.5%
associate-*r/35.4%
clear-num35.3%
associate-/r*46.5%
clear-num46.5%
div-inv46.5%
associate-/r*66.5%
Applied egg-rr66.5%
Taylor expanded in x around 0 56.3%
if 4.5000000000000002e-94 < x Initial program 98.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 60.0%
associate-/l*61.0%
Simplified61.0%
(FPCore (x y) :precision binary64 (* (sin x) (/ y x)))
double code(double x, double y) {
return sin(x) * (y / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (y / x)
end function
public static double code(double x, double y) {
return Math.sin(x) * (y / x);
}
def code(x, y): return math.sin(x) * (y / x)
function code(x, y) return Float64(sin(x) * Float64(y / x)) end
function tmp = code(x, y) tmp = sin(x) * (y / x); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{y}{x}
\end{array}
Initial program 92.2%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 43.7%
*-commutative43.7%
associate-/l*64.7%
Applied egg-rr64.7%
(FPCore (x y) :precision binary64 (if (<= x 4e-10) y (/ 1.0 (/ x (* x y)))))
double code(double x, double y) {
double tmp;
if (x <= 4e-10) {
tmp = y;
} else {
tmp = 1.0 / (x / (x * y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 4d-10) then
tmp = y
else
tmp = 1.0d0 / (x / (x * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 4e-10) {
tmp = y;
} else {
tmp = 1.0 / (x / (x * y));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 4e-10: tmp = y else: tmp = 1.0 / (x / (x * y)) return tmp
function code(x, y) tmp = 0.0 if (x <= 4e-10) tmp = y; else tmp = Float64(1.0 / Float64(x / Float64(x * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 4e-10) tmp = y; else tmp = 1.0 / (x / (x * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 4e-10], y, N[(1.0 / N[(x / N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4 \cdot 10^{-10}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{x}{x \cdot y}}\\
\end{array}
\end{array}
if x < 4.00000000000000015e-10Initial program 88.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 37.9%
associate-/l*49.0%
Simplified49.0%
Taylor expanded in x around 0 31.6%
if 4.00000000000000015e-10 < x Initial program 99.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 57.2%
associate-/l*57.2%
Simplified57.2%
associate-*r/57.2%
clear-num56.3%
*-commutative56.3%
Applied egg-rr56.3%
Taylor expanded in x around 0 15.0%
*-commutative15.0%
Simplified15.0%
Final simplification26.6%
(FPCore (x y) :precision binary64 (if (<= y 3e-56) (/ 1.0 (/ 1.0 y)) (/ (* x y) x)))
double code(double x, double y) {
double tmp;
if (y <= 3e-56) {
tmp = 1.0 / (1.0 / y);
} else {
tmp = (x * y) / x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 3d-56) then
tmp = 1.0d0 / (1.0d0 / y)
else
tmp = (x * y) / x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 3e-56) {
tmp = 1.0 / (1.0 / y);
} else {
tmp = (x * y) / x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 3e-56: tmp = 1.0 / (1.0 / y) else: tmp = (x * y) / x return tmp
function code(x, y) tmp = 0.0 if (y <= 3e-56) tmp = Float64(1.0 / Float64(1.0 / y)); else tmp = Float64(Float64(x * y) / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 3e-56) tmp = 1.0 / (1.0 / y); else tmp = (x * y) / x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 3e-56], N[(1.0 / N[(1.0 / y), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3 \cdot 10^{-56}:\\
\;\;\;\;\frac{1}{\frac{1}{y}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{x}\\
\end{array}
\end{array}
if y < 2.99999999999999989e-56Initial program 89.1%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 54.0%
associate-/l*64.8%
Simplified64.8%
associate-*r/54.0%
clear-num53.6%
*-commutative53.6%
Applied egg-rr53.6%
Taylor expanded in x around 0 29.2%
if 2.99999999999999989e-56 < y Initial program 99.9%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 17.4%
Taylor expanded in x around 0 16.7%
*-commutative16.7%
Simplified16.7%
Final simplification25.7%
(FPCore (x y) :precision binary64 (/ (/ y x) (/ 1.0 x)))
double code(double x, double y) {
return (y / x) / (1.0 / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (y / x) / (1.0d0 / x)
end function
public static double code(double x, double y) {
return (y / x) / (1.0 / x);
}
def code(x, y): return (y / x) / (1.0 / x)
function code(x, y) return Float64(Float64(y / x) / Float64(1.0 / x)) end
function tmp = code(x, y) tmp = (y / x) / (1.0 / x); end
code[x_, y_] := N[(N[(y / x), $MachinePrecision] / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{y}{x}}{\frac{1}{x}}
\end{array}
Initial program 92.2%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 43.7%
*-commutative43.7%
associate-/l*64.7%
Applied egg-rr64.7%
associate-*r/43.7%
clear-num43.4%
associate-/r*51.2%
clear-num51.5%
div-inv51.4%
associate-/r*64.6%
Applied egg-rr64.6%
Taylor expanded in x around 0 48.8%
(FPCore (x y) :precision binary64 (/ 1.0 (/ 1.0 y)))
double code(double x, double y) {
return 1.0 / (1.0 / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 / (1.0d0 / y)
end function
public static double code(double x, double y) {
return 1.0 / (1.0 / y);
}
def code(x, y): return 1.0 / (1.0 / y)
function code(x, y) return Float64(1.0 / Float64(1.0 / y)) end
function tmp = code(x, y) tmp = 1.0 / (1.0 / y); end
code[x_, y_] := N[(1.0 / N[(1.0 / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{1}{y}}
\end{array}
Initial program 92.2%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 43.7%
associate-/l*51.5%
Simplified51.5%
associate-*r/43.7%
clear-num43.4%
*-commutative43.4%
Applied egg-rr43.4%
Taylor expanded in x around 0 23.9%
(FPCore (x y) :precision binary64 y)
double code(double x, double y) {
return y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y
end function
public static double code(double x, double y) {
return y;
}
def code(x, y): return y
function code(x, y) return y end
function tmp = code(x, y) tmp = y; end
code[x_, y_] := y
\begin{array}{l}
\\
y
\end{array}
Initial program 92.2%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 43.7%
associate-/l*51.5%
Simplified51.5%
Taylor expanded in x around 0 23.7%
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) x)))
double code(double x, double y) {
return sin(x) * (sinh(y) / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / x)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / x);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / x)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / x)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / x); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{x}
\end{array}
herbie shell --seed 2024089
(FPCore (x y)
:name "Linear.Quaternion:$ccosh from linear-1.19.1.3"
:precision binary64
:alt
(* (sin x) (/ (sinh y) x))
(/ (* (sin x) (sinh y)) x))