
(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 5 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 89.1%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 5e-14) (* y (/ (sin x) x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 5e-14) {
tmp = y * (sin(x) / x);
} else {
tmp = 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) <= 5d-14) then
tmp = y * (sin(x) / x)
else
tmp = sinh(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.sinh(y) <= 5e-14) {
tmp = y * (Math.sin(x) / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 5e-14: tmp = y * (math.sin(x) / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 5e-14) tmp = Float64(y * Float64(sin(x) / x)); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 5e-14) tmp = y * (sin(x) / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 5e-14], N[(y * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 5 \cdot 10^{-14}:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 5.0000000000000002e-14Initial program 85.4%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 55.4%
associate-/l*69.8%
Simplified69.8%
if 5.0000000000000002e-14 < (sinh.f64 y) Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
associate-*r/100.0%
clear-num100.0%
*-commutative100.0%
associate-/r*100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 78.0%
metadata-eval78.0%
associate-*l/78.0%
associate-/r/78.0%
rec-exp78.0%
sinh-def78.1%
Simplified78.1%
remove-double-div78.1%
sinh-def78.0%
div-sub78.0%
Applied egg-rr78.0%
div-sub78.0%
sinh-def78.1%
Simplified78.1%
Final simplification71.9%
(FPCore (x y) :precision binary64 (sinh y))
double code(double x, double y) {
return sinh(y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sinh(y)
end function
public static double code(double x, double y) {
return Math.sinh(y);
}
def code(x, y): return math.sinh(y)
function code(x, y) return sinh(y) end
function tmp = code(x, y) tmp = sinh(y); end
code[x_, y_] := N[Sinh[y], $MachinePrecision]
\begin{array}{l}
\\
\sinh y
\end{array}
Initial program 89.1%
associate-/l*99.9%
Simplified99.9%
associate-*r/89.1%
clear-num88.3%
*-commutative88.3%
associate-/r*99.0%
Applied egg-rr99.0%
Taylor expanded in x around 0 53.1%
metadata-eval53.1%
associate-*l/53.1%
associate-/r/53.1%
rec-exp53.1%
sinh-def67.3%
Simplified67.3%
remove-double-div67.3%
sinh-def53.1%
div-sub53.1%
Applied egg-rr53.1%
div-sub53.1%
sinh-def67.3%
Simplified67.3%
Final simplification67.3%
(FPCore (x y) :precision binary64 (if (<= y 4e+79) y (/ (* x y) x)))
double code(double x, double y) {
double tmp;
if (y <= 4e+79) {
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 <= 4d+79) 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 <= 4e+79) {
tmp = y;
} else {
tmp = (x * y) / x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 4e+79: tmp = y else: tmp = (x * y) / x return tmp
function code(x, y) tmp = 0.0 if (y <= 4e+79) tmp = y; else tmp = Float64(Float64(x * y) / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 4e+79) tmp = y; else tmp = (x * y) / x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 4e+79], y, N[(N[(x * y), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4 \cdot 10^{+79}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{x}\\
\end{array}
\end{array}
if y < 3.99999999999999987e79Initial program 86.4%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 52.0%
associate-/l*65.5%
Simplified65.5%
Taylor expanded in x around 0 34.7%
if 3.99999999999999987e79 < y Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 4.9%
Taylor expanded in x around 0 19.7%
*-commutative19.7%
Simplified19.7%
Final simplification31.8%
(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 89.1%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 42.8%
associate-/l*53.6%
Simplified53.6%
Taylor expanded in x around 0 28.8%
Final simplification28.8%
(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 2024078
(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))