
(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 7 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 87.2%
associate-/l*99.5%
Simplified99.5%
(FPCore (x y) :precision binary64 (if (<= y 0.001) (/ y (/ x (sin x))) (log (exp y))))
double code(double x, double y) {
double tmp;
if (y <= 0.001) {
tmp = y / (x / sin(x));
} else {
tmp = log(exp(y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 0.001d0) then
tmp = y / (x / sin(x))
else
tmp = log(exp(y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 0.001) {
tmp = y / (x / Math.sin(x));
} else {
tmp = Math.log(Math.exp(y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 0.001: tmp = y / (x / math.sin(x)) else: tmp = math.log(math.exp(y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 0.001) tmp = Float64(y / Float64(x / sin(x))); else tmp = log(exp(y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 0.001) tmp = y / (x / sin(x)); else tmp = log(exp(y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 0.001], N[(y / N[(x / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Log[N[Exp[y], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.001:\\
\;\;\;\;\frac{y}{\frac{x}{\sin x}}\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{y}\right)\\
\end{array}
\end{array}
if y < 1e-3Initial program 82.2%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 54.9%
associate-/l*72.6%
Simplified72.6%
clear-num72.7%
un-div-inv72.7%
Applied egg-rr72.7%
if 1e-3 < y Initial program 100.0%
associate-/l*98.7%
Simplified98.7%
Taylor expanded in y around 0 4.8%
associate-/l*4.8%
Simplified4.8%
associate-*r/4.8%
*-commutative4.8%
clear-num4.8%
*-commutative4.8%
associate-/r*26.7%
Applied egg-rr26.7%
Taylor expanded in x around 0 4.4%
remove-double-div4.4%
add-log-exp68.6%
Applied egg-rr68.6%
(FPCore (x y) :precision binary64 (if (<= y 3.4e+79) (* y (/ (sin x) x)) (/ (/ y x) (/ 1.0 x))))
double code(double x, double y) {
double tmp;
if (y <= 3.4e+79) {
tmp = y * (sin(x) / x);
} else {
tmp = (y / x) / (1.0 / x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 3.4d+79) then
tmp = y * (sin(x) / x)
else
tmp = (y / x) / (1.0d0 / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 3.4e+79) {
tmp = y * (Math.sin(x) / x);
} else {
tmp = (y / x) / (1.0 / x);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 3.4e+79: tmp = y * (math.sin(x) / x) else: tmp = (y / x) / (1.0 / x) return tmp
function code(x, y) tmp = 0.0 if (y <= 3.4e+79) tmp = Float64(y * Float64(sin(x) / x)); else tmp = Float64(Float64(y / x) / Float64(1.0 / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 3.4e+79) tmp = y * (sin(x) / x); else tmp = (y / x) / (1.0 / x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 3.4e+79], N[(y * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(N[(y / x), $MachinePrecision] / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.4 \cdot 10^{+79}:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{x}}{\frac{1}{x}}\\
\end{array}
\end{array}
if y < 3.40000000000000032e79Initial program 84.0%
associate-/l*99.4%
Simplified99.4%
Taylor expanded in y around 0 49.7%
associate-/l*65.6%
Simplified65.6%
if 3.40000000000000032e79 < y Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
clear-num100.0%
associate-/r/100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 35.9%
*-commutative35.9%
associate-*l/35.9%
*-un-lft-identity35.9%
associate-/r/4.9%
div-inv4.9%
associate-/r*35.9%
Applied egg-rr35.9%
Taylor expanded in x around 0 35.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 87.2%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in y around 0 64.5%
(FPCore (x y) :precision binary64 (if (<= y 5e-17) y (/ (* x y) x)))
double code(double x, double y) {
double tmp;
if (y <= 5e-17) {
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 (y <= 5d-17) 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 (y <= 5e-17) {
tmp = y;
} else {
tmp = (x * y) / x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 5e-17: tmp = y else: tmp = (x * y) / x return tmp
function code(x, y) tmp = 0.0 if (y <= 5e-17) tmp = y; else tmp = Float64(Float64(x * y) / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 5e-17) tmp = y; else tmp = (x * y) / x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 5e-17], y, N[(N[(x * y), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5 \cdot 10^{-17}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{x}\\
\end{array}
\end{array}
if y < 4.9999999999999999e-17Initial program 82.1%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 54.7%
associate-/l*72.5%
Simplified72.5%
Taylor expanded in x around 0 39.1%
if 4.9999999999999999e-17 < y Initial program 100.0%
Taylor expanded in y around 0 6.0%
Taylor expanded in x around 0 16.0%
*-commutative16.0%
Simplified16.0%
Final simplification32.5%
(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 87.2%
associate-/l*99.5%
Simplified99.5%
clear-num99.2%
associate-/r/99.5%
Applied egg-rr99.5%
Taylor expanded in y around 0 64.4%
*-commutative64.4%
associate-*l/64.5%
*-un-lft-identity64.5%
associate-/r/53.6%
div-inv53.5%
associate-/r*64.3%
Applied egg-rr64.3%
Taylor expanded in x around 0 51.6%
(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 87.2%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in y around 0 40.8%
associate-/l*53.5%
Simplified53.5%
Taylor expanded in x around 0 29.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}
herbie shell --seed 2024096
(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))