
(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 6 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 93.5%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 0.002) (* y (/ (sin x) x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 0.002) {
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) <= 0.002d0) 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) <= 0.002) {
tmp = y * (Math.sin(x) / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 0.002: tmp = y * (math.sin(x) / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 0.002) 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) <= 0.002) tmp = y * (sin(x) / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 0.002], 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 0.002:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 2e-3Initial program 91.3%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 57.1%
associate-/l*65.8%
Simplified65.8%
if 2e-3 < (sinh.f64 y) Initial program 100.0%
associate-/l*99.9%
Simplified99.9%
associate-*r/100.0%
clear-num99.9%
*-commutative99.9%
associate-/r*100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 75.6%
metadata-eval75.6%
associate-*l/75.6%
associate-/r/75.6%
rec-exp75.7%
sinh-def75.7%
Simplified75.7%
remove-double-div75.8%
sinh-def75.7%
div-sub75.7%
Applied egg-rr75.7%
div-sub75.7%
sinh-def75.8%
Simplified75.8%
Final simplification68.3%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 0.002) (/ y (/ x (sin x))) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 0.002) {
tmp = y / (x / sin(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) <= 0.002d0) then
tmp = y / (x / sin(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) <= 0.002) {
tmp = y / (x / Math.sin(x));
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 0.002: tmp = y / (x / math.sin(x)) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 0.002) tmp = Float64(y / Float64(x / sin(x))); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 0.002) tmp = y / (x / sin(x)); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 0.002], N[(y / N[(x / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 0.002:\\
\;\;\;\;\frac{y}{\frac{x}{\sin x}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 2e-3Initial program 91.3%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 57.1%
associate-/l*65.8%
Simplified65.8%
clear-num65.8%
un-div-inv65.8%
Applied egg-rr65.8%
if 2e-3 < (sinh.f64 y) Initial program 100.0%
associate-/l*99.9%
Simplified99.9%
associate-*r/100.0%
clear-num99.9%
*-commutative99.9%
associate-/r*100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 75.6%
metadata-eval75.6%
associate-*l/75.6%
associate-/r/75.6%
rec-exp75.7%
sinh-def75.7%
Simplified75.7%
remove-double-div75.8%
sinh-def75.7%
div-sub75.7%
Applied egg-rr75.7%
div-sub75.7%
sinh-def75.8%
Simplified75.8%
Final simplification68.3%
(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 93.5%
associate-/l*99.9%
Simplified99.9%
associate-*r/93.5%
clear-num92.8%
*-commutative92.8%
associate-/r*99.2%
Applied egg-rr99.2%
Taylor expanded in x around 0 55.1%
metadata-eval55.1%
associate-*l/55.1%
associate-/r/55.1%
rec-exp55.2%
sinh-def61.8%
Simplified61.8%
remove-double-div61.8%
sinh-def55.2%
div-sub55.2%
Applied egg-rr55.2%
div-sub55.2%
sinh-def61.8%
Simplified61.8%
Final simplification61.8%
(FPCore (x y) :precision binary64 (if (<= y 7.2e+125) y (/ (* x y) x)))
double code(double x, double y) {
double tmp;
if (y <= 7.2e+125) {
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 <= 7.2d+125) 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 <= 7.2e+125) {
tmp = y;
} else {
tmp = (x * y) / x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 7.2e+125: tmp = y else: tmp = (x * y) / x return tmp
function code(x, y) tmp = 0.0 if (y <= 7.2e+125) tmp = y; else tmp = Float64(Float64(x * y) / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 7.2e+125) tmp = y; else tmp = (x * y) / x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 7.2e+125], y, N[(N[(x * y), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.2 \cdot 10^{+125}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{x}\\
\end{array}
\end{array}
if y < 7.2000000000000007e125Initial program 92.3%
associate-/l*99.9%
Simplified99.9%
associate-*r/92.3%
clear-num91.4%
*-commutative91.4%
associate-/r*99.0%
Applied egg-rr99.0%
Taylor expanded in x around 0 48.7%
metadata-eval48.7%
associate-*l/48.7%
associate-/r/48.7%
rec-exp48.7%
sinh-def56.6%
Simplified56.6%
Taylor expanded in y around 0 29.1%
if 7.2000000000000007e125 < y Initial program 100.0%
Taylor expanded in y around 0 5.0%
Taylor expanded in x around 0 32.2%
*-commutative32.2%
Simplified32.2%
Final simplification29.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 93.5%
associate-/l*99.9%
Simplified99.9%
associate-*r/93.5%
clear-num92.8%
*-commutative92.8%
associate-/r*99.2%
Applied egg-rr99.2%
Taylor expanded in x around 0 55.1%
metadata-eval55.1%
associate-*l/55.1%
associate-/r/55.1%
rec-exp55.2%
sinh-def61.8%
Simplified61.8%
Taylor expanded in y around 0 25.2%
Final simplification25.2%
(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 2024077
(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))