
(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 8 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) x) (/ 1.0 (sinh y))))
double code(double x, double y) {
return (sin(x) / x) / (1.0 / sinh(y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (sin(x) / x) / (1.0d0 / sinh(y))
end function
public static double code(double x, double y) {
return (Math.sin(x) / x) / (1.0 / Math.sinh(y));
}
def code(x, y): return (math.sin(x) / x) / (1.0 / math.sinh(y))
function code(x, y) return Float64(Float64(sin(x) / x) / Float64(1.0 / sinh(y))) end
function tmp = code(x, y) tmp = (sin(x) / x) / (1.0 / sinh(y)); end
code[x_, y_] := N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] / N[(1.0 / N[Sinh[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\sin x}{x}}{\frac{1}{\sinh y}}
\end{array}
Initial program 88.0%
associate-/l*99.5%
Simplified99.5%
sinh-def67.1%
clear-num67.1%
sinh-undef99.5%
Applied egg-rr99.5%
associate-/l/99.3%
associate-/r*99.3%
metadata-eval99.3%
div-inv99.3%
div-inv99.4%
div-inv99.4%
metadata-eval99.4%
associate-/r*99.4%
associate-/r*99.9%
associate-/r*99.9%
metadata-eval99.9%
Applied egg-rr99.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 1e-5) (/ y (/ x (sin x))) (/ 1.0 (/ 1.0 (sinh y)))))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 1e-5) {
tmp = y / (x / sin(x));
} else {
tmp = 1.0 / (1.0 / sinh(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) <= 1d-5) then
tmp = y / (x / sin(x))
else
tmp = 1.0d0 / (1.0d0 / sinh(y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.sinh(y) <= 1e-5) {
tmp = y / (x / Math.sin(x));
} else {
tmp = 1.0 / (1.0 / Math.sinh(y));
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 1e-5: tmp = y / (x / math.sin(x)) else: tmp = 1.0 / (1.0 / math.sinh(y)) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 1e-5) tmp = Float64(y / Float64(x / sin(x))); else tmp = Float64(1.0 / Float64(1.0 / sinh(y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 1e-5) tmp = y / (x / sin(x)); else tmp = 1.0 / (1.0 / sinh(y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 1e-5], N[(y / N[(x / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 / N[Sinh[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 10^{-5}:\\
\;\;\;\;\frac{y}{\frac{x}{\sin x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{\sinh y}}\\
\end{array}
\end{array}
if (sinh.f64 y) < 1.00000000000000008e-5Initial program 83.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 58.5%
associate-/l*74.8%
Simplified74.8%
clear-num74.7%
un-div-inv74.8%
Applied egg-rr74.8%
if 1.00000000000000008e-5 < (sinh.f64 y) Initial program 100.0%
associate-/l*98.6%
Simplified98.6%
sinh-def98.5%
clear-num98.5%
sinh-undef98.6%
Applied egg-rr98.6%
associate-/l/98.6%
associate-/r*98.6%
metadata-eval98.6%
div-inv98.6%
div-inv98.6%
div-inv98.6%
metadata-eval98.6%
associate-/r*98.6%
associate-/r*100.0%
associate-/r*100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 73.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 1e-5) (* (/ (sin x) x) y) (/ 1.0 (/ 1.0 (sinh y)))))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 1e-5) {
tmp = (sin(x) / x) * y;
} else {
tmp = 1.0 / (1.0 / sinh(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) <= 1d-5) then
tmp = (sin(x) / x) * y
else
tmp = 1.0d0 / (1.0d0 / sinh(y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.sinh(y) <= 1e-5) {
tmp = (Math.sin(x) / x) * y;
} else {
tmp = 1.0 / (1.0 / Math.sinh(y));
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 1e-5: tmp = (math.sin(x) / x) * y else: tmp = 1.0 / (1.0 / math.sinh(y)) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 1e-5) tmp = Float64(Float64(sin(x) / x) * y); else tmp = Float64(1.0 / Float64(1.0 / sinh(y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 1e-5) tmp = (sin(x) / x) * y; else tmp = 1.0 / (1.0 / sinh(y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 1e-5], N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision], N[(1.0 / N[(1.0 / N[Sinh[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 10^{-5}:\\
\;\;\;\;\frac{\sin x}{x} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{\sinh y}}\\
\end{array}
\end{array}
if (sinh.f64 y) < 1.00000000000000008e-5Initial program 83.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 58.5%
associate-/l*74.8%
Simplified74.8%
if 1.00000000000000008e-5 < (sinh.f64 y) Initial program 100.0%
associate-/l*98.6%
Simplified98.6%
sinh-def98.5%
clear-num98.5%
sinh-undef98.6%
Applied egg-rr98.6%
associate-/l/98.6%
associate-/r*98.6%
metadata-eval98.6%
div-inv98.6%
div-inv98.6%
div-inv98.6%
metadata-eval98.6%
associate-/r*98.6%
associate-/r*100.0%
associate-/r*100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 73.9%
Final simplification74.5%
(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 88.0%
associate-/l*99.5%
Simplified99.5%
(FPCore (x y) :precision binary64 (if (<= y 3900000.0) (* (/ (sin x) x) y) (/ (* x y) x)))
double code(double x, double y) {
double tmp;
if (y <= 3900000.0) {
tmp = (sin(x) / x) * 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 <= 3900000.0d0) then
tmp = (sin(x) / x) * y
else
tmp = (x * y) / x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 3900000.0) {
tmp = (Math.sin(x) / x) * y;
} else {
tmp = (x * y) / x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 3900000.0: tmp = (math.sin(x) / x) * y else: tmp = (x * y) / x return tmp
function code(x, y) tmp = 0.0 if (y <= 3900000.0) tmp = Float64(Float64(sin(x) / x) * y); else tmp = Float64(Float64(x * y) / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 3900000.0) tmp = (sin(x) / x) * y; else tmp = (x * y) / x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 3900000.0], N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3900000:\\
\;\;\;\;\frac{\sin x}{x} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{x}\\
\end{array}
\end{array}
if y < 3.9e6Initial program 83.9%
associate-/l*99.4%
Simplified99.4%
Taylor expanded in y around 0 57.8%
associate-/l*73.8%
Simplified73.8%
if 3.9e6 < y Initial program 100.0%
Taylor expanded in y around 0 4.6%
Taylor expanded in x around 0 15.6%
*-commutative15.6%
Simplified15.6%
Final simplification58.8%
(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 88.0%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in y around 0 70.9%
(FPCore (x y) :precision binary64 (if (<= x 4e+22) y (/ (* x y) x)))
double code(double x, double y) {
double tmp;
if (x <= 4e+22) {
tmp = 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 (x <= 4d+22) then
tmp = y
else
tmp = (x * y) / x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 4e+22) {
tmp = y;
} else {
tmp = (x * y) / x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 4e+22: tmp = y else: tmp = (x * y) / x return tmp
function code(x, y) tmp = 0.0 if (x <= 4e+22) tmp = y; else tmp = Float64(Float64(x * y) / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 4e+22) tmp = y; else tmp = (x * y) / x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 4e+22], y, N[(N[(x * y), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4 \cdot 10^{+22}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{x}\\
\end{array}
\end{array}
if x < 4e22Initial program 84.5%
Taylor expanded in y around 0 38.7%
associate-*l/54.1%
div-inv54.1%
associate-*l*73.4%
Applied egg-rr73.4%
Taylor expanded in x around 0 37.1%
if 4e22 < x Initial program 99.8%
Taylor expanded in y around 0 62.0%
Taylor expanded in x around 0 16.0%
*-commutative16.0%
Simplified16.0%
Final simplification32.2%
(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 88.0%
Taylor expanded in y around 0 44.1%
associate-*l/56.0%
div-inv55.9%
associate-*l*70.8%
Applied egg-rr70.8%
Taylor expanded in x around 0 29.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 2024106
(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))