
(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 9 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 (* (sinh y) (/ (sin x) x)))
double code(double x, double y) {
return sinh(y) * (sin(x) / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sinh(y) * (sin(x) / x)
end function
public static double code(double x, double y) {
return Math.sinh(y) * (Math.sin(x) / x);
}
def code(x, y): return math.sinh(y) * (math.sin(x) / x)
function code(x, y) return Float64(sinh(y) * Float64(sin(x) / x)) end
function tmp = code(x, y) tmp = sinh(y) * (sin(x) / x); end
code[x_, y_] := N[(N[Sinh[y], $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sinh y \cdot \frac{\sin x}{x}
\end{array}
Initial program 87.3%
*-commutative87.3%
associate-/l*99.9%
Applied egg-rr99.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 2e-9) (/ y (/ x (sin x))) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 2e-9) {
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-9) 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-9) {
tmp = y / (x / Math.sin(x));
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 2e-9: tmp = y / (x / math.sin(x)) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 2e-9) 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-9) tmp = y / (x / sin(x)); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 2e-9], 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^{-9}:\\
\;\;\;\;\frac{y}{\frac{x}{\sin x}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 2.00000000000000012e-9Initial program 82.2%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 51.8%
associate-/l*69.6%
Simplified69.6%
clear-num69.5%
un-div-inv69.6%
Applied egg-rr69.6%
if 2.00000000000000012e-9 < (sinh.f64 y) Initial program 100.0%
*-commutative100.0%
associate-/l*100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 77.1%
Final simplification71.8%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 2e-9) (* y (/ (sin x) x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 2e-9) {
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-9) 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-9) {
tmp = y * (Math.sin(x) / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 2e-9: tmp = y * (math.sin(x) / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 2e-9) 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-9) tmp = y * (sin(x) / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 2e-9], 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^{-9}:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 2.00000000000000012e-9Initial program 82.2%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 51.8%
associate-/l*69.6%
Simplified69.6%
if 2.00000000000000012e-9 < (sinh.f64 y) Initial program 100.0%
*-commutative100.0%
associate-/l*100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 77.1%
Final simplification71.8%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 4e-56) (/ 1.0 (* (/ x y) (/ 1.0 x))) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 4e-56) {
tmp = 1.0 / ((x / y) * (1.0 / 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) <= 4d-56) then
tmp = 1.0d0 / ((x / y) * (1.0d0 / 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) <= 4e-56) {
tmp = 1.0 / ((x / y) * (1.0 / x));
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 4e-56: tmp = 1.0 / ((x / y) * (1.0 / x)) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 4e-56) tmp = Float64(1.0 / Float64(Float64(x / y) * Float64(1.0 / x))); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 4e-56) tmp = 1.0 / ((x / y) * (1.0 / x)); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 4e-56], N[(1.0 / N[(N[(x / y), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 4 \cdot 10^{-56}:\\
\;\;\;\;\frac{1}{\frac{x}{y} \cdot \frac{1}{x}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 4.0000000000000002e-56Initial program 81.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 48.7%
associate-/l*66.8%
Simplified66.8%
associate-*r/48.7%
*-commutative48.7%
clear-num47.7%
*-commutative47.7%
associate-/r*76.4%
Applied egg-rr76.4%
div-inv76.3%
Applied egg-rr76.3%
Taylor expanded in x around 0 59.9%
if 4.0000000000000002e-56 < (sinh.f64 y) Initial program 97.7%
*-commutative97.7%
associate-/l*99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 73.4%
Final simplification64.6%
(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.3%
associate-/l*99.9%
Simplified99.9%
(FPCore (x y) :precision binary64 (if (<= y 2e+17) y (/ (* y x) x)))
double code(double x, double y) {
double tmp;
if (y <= 2e+17) {
tmp = y;
} else {
tmp = (y * x) / x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 2d+17) then
tmp = y
else
tmp = (y * x) / x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 2e+17) {
tmp = y;
} else {
tmp = (y * x) / x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2e+17: tmp = y else: tmp = (y * x) / x return tmp
function code(x, y) tmp = 0.0 if (y <= 2e+17) tmp = y; else tmp = Float64(Float64(y * x) / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 2e+17) tmp = y; else tmp = (y * x) / x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2e+17], y, N[(N[(y * x), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2 \cdot 10^{+17}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{x}\\
\end{array}
\end{array}
if y < 2e17Initial program 83.2%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 49.9%
associate-/l*66.6%
Simplified66.6%
Taylor expanded in x around 0 35.2%
if 2e17 < y Initial program 100.0%
Taylor expanded in y around 0 4.4%
Taylor expanded in x around 0 23.8%
Final simplification32.4%
(FPCore (x y) :precision binary64 (/ 1.0 (* (/ x y) (/ 1.0 x))))
double code(double x, double y) {
return 1.0 / ((x / y) * (1.0 / x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 / ((x / y) * (1.0d0 / x))
end function
public static double code(double x, double y) {
return 1.0 / ((x / y) * (1.0 / x));
}
def code(x, y): return 1.0 / ((x / y) * (1.0 / x))
function code(x, y) return Float64(1.0 / Float64(Float64(x / y) * Float64(1.0 / x))) end
function tmp = code(x, y) tmp = 1.0 / ((x / y) * (1.0 / x)); end
code[x_, y_] := N[(1.0 / N[(N[(x / y), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{x}{y} \cdot \frac{1}{x}}
\end{array}
Initial program 87.3%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 38.7%
associate-/l*51.3%
Simplified51.3%
associate-*r/38.7%
*-commutative38.7%
clear-num38.1%
*-commutative38.1%
associate-/r*62.9%
Applied egg-rr62.9%
div-inv62.9%
Applied egg-rr62.9%
Taylor expanded in x around 0 49.6%
(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.3%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 38.7%
associate-/l*51.3%
Simplified51.3%
clear-num51.3%
associate-/r/51.3%
Applied egg-rr51.3%
associate-*r*63.9%
div-inv64.0%
associate-/r/51.3%
div-inv51.3%
associate-/r*63.9%
Applied egg-rr63.9%
Taylor expanded in x around 0 48.7%
(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.3%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 38.7%
associate-/l*51.3%
Simplified51.3%
Taylor expanded in x around 0 27.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 2024103
(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))