
(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 85.3%
associate-/l*99.9%
Simplified99.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 2e-7) (* y (/ (sin x) x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 2e-7) {
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-7) 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-7) {
tmp = y * (Math.sin(x) / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 2e-7: tmp = y * (math.sin(x) / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 2e-7) 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-7) tmp = y * (sin(x) / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 2e-7], 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^{-7}:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 1.9999999999999999e-7Initial program 79.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 54.5%
associate-/l*74.6%
Simplified74.6%
if 1.9999999999999999e-7 < (sinh.f64 y) Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 76.8%
clear-num76.8%
un-div-inv76.8%
Applied egg-rr76.8%
associate-/r/76.8%
*-inverses76.8%
*-lft-identity76.8%
Simplified76.8%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 2e-72) (/ x (/ x y)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 2e-72) {
tmp = x / (x / y);
} 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-72) then
tmp = x / (x / y)
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-72) {
tmp = x / (x / y);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 2e-72: tmp = x / (x / y) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 2e-72) tmp = Float64(x / Float64(x / y)); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 2e-72) tmp = x / (x / y); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 2e-72], N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 2 \cdot 10^{-72}:\\
\;\;\;\;\frac{x}{\frac{x}{y}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 1.9999999999999999e-72Initial program 78.6%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 51.0%
associate-/l*72.3%
Simplified72.3%
associate-*r/51.0%
*-commutative51.0%
associate-*r/78.2%
clear-num77.6%
un-div-inv76.1%
Applied egg-rr76.1%
Taylor expanded in x around 0 61.0%
if 1.9999999999999999e-72 < (sinh.f64 y) Initial program 98.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 72.2%
clear-num72.2%
un-div-inv72.2%
Applied egg-rr72.2%
associate-/r/72.2%
*-inverses72.2%
*-lft-identity72.2%
Simplified72.2%
(FPCore (x y) :precision binary64 (* x (/ (sinh y) x)))
double code(double x, double y) {
return x * (sinh(y) / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (sinh(y) / x)
end function
public static double code(double x, double y) {
return x * (Math.sinh(y) / x);
}
def code(x, y): return x * (math.sinh(y) / x)
function code(x, y) return Float64(x * Float64(sinh(y) / x)) end
function tmp = code(x, y) tmp = x * (sinh(y) / x); end
code[x_, y_] := N[(x * N[(N[Sinh[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{\sinh y}{x}
\end{array}
Initial program 85.3%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 71.8%
(FPCore (x y)
:precision binary64
(if (<= y 2020000000.0)
(/ x (/ x y))
(if (<= y 3.1e+243)
(* y (+ 1.0 (* (* x x) -0.16666666666666666)))
(* x (/ y x)))))
double code(double x, double y) {
double tmp;
if (y <= 2020000000.0) {
tmp = x / (x / y);
} else if (y <= 3.1e+243) {
tmp = y * (1.0 + ((x * x) * -0.16666666666666666));
} 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 <= 2020000000.0d0) then
tmp = x / (x / y)
else if (y <= 3.1d+243) then
tmp = y * (1.0d0 + ((x * x) * (-0.16666666666666666d0)))
else
tmp = x * (y / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 2020000000.0) {
tmp = x / (x / y);
} else if (y <= 3.1e+243) {
tmp = y * (1.0 + ((x * x) * -0.16666666666666666));
} else {
tmp = x * (y / x);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2020000000.0: tmp = x / (x / y) elif y <= 3.1e+243: tmp = y * (1.0 + ((x * x) * -0.16666666666666666)) else: tmp = x * (y / x) return tmp
function code(x, y) tmp = 0.0 if (y <= 2020000000.0) tmp = Float64(x / Float64(x / y)); elseif (y <= 3.1e+243) tmp = Float64(y * Float64(1.0 + Float64(Float64(x * x) * -0.16666666666666666))); else tmp = Float64(x * Float64(y / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 2020000000.0) tmp = x / (x / y); elseif (y <= 3.1e+243) tmp = y * (1.0 + ((x * x) * -0.16666666666666666)); else tmp = x * (y / x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2020000000.0], N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.1e+243], N[(y * N[(1.0 + N[(N[(x * x), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2020000000:\\
\;\;\;\;\frac{x}{\frac{x}{y}}\\
\mathbf{elif}\;y \leq 3.1 \cdot 10^{+243}:\\
\;\;\;\;y \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{x}\\
\end{array}
\end{array}
if y < 2.02e9Initial program 80.1%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 53.9%
associate-/l*73.7%
Simplified73.7%
associate-*r/53.9%
*-commutative53.9%
associate-*r/79.0%
clear-num78.3%
un-div-inv77.1%
Applied egg-rr77.1%
Taylor expanded in x around 0 59.5%
if 2.02e9 < y < 3.1e243Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 3.7%
associate-/l*3.7%
Simplified3.7%
Taylor expanded in x around 0 21.8%
*-commutative21.8%
Simplified21.8%
unpow221.8%
Applied egg-rr21.8%
if 3.1e243 < y Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 53.3%
Taylor expanded in x around 0 53.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 85.3%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 64.9%
Taylor expanded in x around 0 50.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 85.3%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 71.8%
Taylor expanded in y around 0 31.4%
(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 2024132
(FPCore (x y)
:name "Linear.Quaternion:$ccosh from linear-1.19.1.3"
:precision binary64
:alt
(! :herbie-platform default (* (sin x) (/ (sinh y) x)))
(/ (* (sin x) (sinh y)) x))