
(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 91.3%
associate-/l*99.9%
Simplified99.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 2e+20) (/ y (/ x (sin x))) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 2e+20) {
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) <= 2d+20) 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) <= 2e+20) {
tmp = y / (x / Math.sin(x));
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 2e+20: tmp = y / (x / math.sin(x)) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 2e+20) 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) <= 2e+20) tmp = y / (x / sin(x)); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 2e+20], 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 2 \cdot 10^{+20}:\\
\;\;\;\;\frac{y}{\frac{x}{\sin x}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 2e20Initial program 87.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 49.7%
associate-/l*61.8%
Simplified61.8%
clear-num61.8%
un-div-inv61.8%
Applied egg-rr61.8%
if 2e20 < (sinh.f64 y) Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
add-cube-cbrt100.0%
pow3100.0%
Applied egg-rr100.0%
rem-cube-cbrt100.0%
clear-num100.0%
div-inv100.0%
div-inv100.0%
associate-/r*100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 77.0%
remove-double-div77.0%
sinh-def77.0%
div-sub77.0%
Applied egg-rr77.0%
div-sub77.0%
sinh-def77.0%
Simplified77.0%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 2e+20) (* y (/ (sin x) x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 2e+20) {
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) <= 2d+20) 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) <= 2e+20) {
tmp = y * (Math.sin(x) / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 2e+20: tmp = y * (math.sin(x) / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 2e+20) 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) <= 2e+20) tmp = y * (sin(x) / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 2e+20], 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 2 \cdot 10^{+20}:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 2e20Initial program 87.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 49.7%
associate-/l*61.8%
Simplified61.8%
if 2e20 < (sinh.f64 y) Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
add-cube-cbrt100.0%
pow3100.0%
Applied egg-rr100.0%
rem-cube-cbrt100.0%
clear-num100.0%
div-inv100.0%
div-inv100.0%
associate-/r*100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 77.0%
remove-double-div77.0%
sinh-def77.0%
div-sub77.0%
Applied egg-rr77.0%
div-sub77.0%
sinh-def77.0%
Simplified77.0%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 1e-30) (* x (/ y x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 1e-30) {
tmp = x * (y / 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) <= 1d-30) then
tmp = x * (y / 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) <= 1e-30) {
tmp = x * (y / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 1e-30: tmp = x * (y / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 1e-30) tmp = Float64(x * Float64(y / x)); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 1e-30) tmp = x * (y / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 1e-30], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 10^{-30}:\\
\;\;\;\;x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 1e-30Initial program 87.3%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 47.9%
Taylor expanded in x around 0 21.0%
*-commutative21.0%
Simplified21.0%
*-commutative21.0%
associate-/l*56.2%
Applied egg-rr56.2%
if 1e-30 < (sinh.f64 y) Initial program 100.0%
associate-/l*99.9%
Simplified99.9%
add-cube-cbrt99.8%
pow399.8%
Applied egg-rr99.8%
rem-cube-cbrt99.9%
clear-num99.2%
div-inv99.2%
div-inv99.1%
associate-/r*99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 71.1%
remove-double-div71.1%
sinh-def70.3%
div-sub70.3%
Applied egg-rr70.3%
div-sub70.3%
sinh-def71.1%
Simplified71.1%
(FPCore (x y) :precision binary64 (* x (/ y x)))
double code(double x, double y) {
return x * (y / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (y / x)
end function
public static double code(double x, double y) {
return x * (y / x);
}
def code(x, y): return x * (y / x)
function code(x, y) return Float64(x * Float64(y / x)) end
function tmp = code(x, y) tmp = x * (y / x); end
code[x_, y_] := N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{y}{x}
\end{array}
Initial program 91.3%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 36.6%
Taylor expanded in x around 0 18.9%
*-commutative18.9%
Simplified18.9%
*-commutative18.9%
associate-/l*47.6%
Applied egg-rr47.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 91.3%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 36.6%
associate-/l*45.2%
Simplified45.2%
Taylor expanded in x around 0 20.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 2024087
(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))