
(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 (* (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 90.3%
associate-/l*99.8%
Simplified99.8%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 2.0) (* y (/ (sin x) x)) (/ 1.0 (/ (/ x (sinh y)) x))))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 2.0) {
tmp = y * (sin(x) / x);
} else {
tmp = 1.0 / ((x / sinh(y)) / x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (sinh(y) <= 2.0d0) then
tmp = y * (sin(x) / x)
else
tmp = 1.0d0 / ((x / sinh(y)) / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.sinh(y) <= 2.0) {
tmp = y * (Math.sin(x) / x);
} else {
tmp = 1.0 / ((x / Math.sinh(y)) / x);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 2.0: tmp = y * (math.sin(x) / x) else: tmp = 1.0 / ((x / math.sinh(y)) / x) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 2.0) tmp = Float64(y * Float64(sin(x) / x)); else tmp = Float64(1.0 / Float64(Float64(x / sinh(y)) / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 2.0) tmp = y * (sin(x) / x); else tmp = 1.0 / ((x / sinh(y)) / x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 2.0], N[(y * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(x / N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 2:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\frac{x}{\sinh y}}{x}}\\
\end{array}
\end{array}
if (sinh.f64 y) < 2Initial program 87.1%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 53.7%
associate-/l*66.4%
Simplified66.4%
if 2 < (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 71.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 2.0) (* y (/ (sin x) x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 2.0) {
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) <= 2.0d0) 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) <= 2.0) {
tmp = y * (Math.sin(x) / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 2.0: tmp = y * (math.sin(x) / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 2.0) 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) <= 2.0) tmp = y * (sin(x) / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 2.0], 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:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 2Initial program 87.1%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 53.7%
associate-/l*66.4%
Simplified66.4%
if 2 < (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 71.9%
clear-num71.9%
*-un-lft-identity71.9%
div-inv71.9%
clear-num71.9%
Applied egg-rr71.9%
*-lft-identity71.9%
associate-*r/71.9%
associate-*l/71.9%
*-inverses71.9%
*-lft-identity71.9%
Simplified71.9%
(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 86.4%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 72.7%
Taylor expanded in y around 0 54.8%
clear-num56.6%
un-div-inv56.1%
Applied egg-rr56.1%
if 1.9999999999999999e-72 < (sinh.f64 y) Initial program 98.7%
associate-/l*99.9%
Simplified99.9%
associate-*r/98.7%
clear-num98.7%
*-commutative98.7%
associate-/r*99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 71.3%
clear-num71.4%
*-un-lft-identity71.4%
div-inv71.3%
clear-num71.3%
Applied egg-rr71.3%
*-lft-identity71.3%
associate-*r/70.2%
associate-*l/71.4%
*-inverses71.4%
*-lft-identity71.4%
Simplified71.4%
(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 90.3%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 72.3%
(FPCore (x y)
:precision binary64
(if (<= y 2.5e-48)
(/ x (/ x y))
(if (<= y 1.85e+88)
(+ y (* y (* -0.16666666666666666 (* x x))))
(* x (* y (/ 1.0 x))))))
double code(double x, double y) {
double tmp;
if (y <= 2.5e-48) {
tmp = x / (x / y);
} else if (y <= 1.85e+88) {
tmp = y + (y * (-0.16666666666666666 * (x * x)));
} else {
tmp = x * (y * (1.0 / x));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 2.5d-48) then
tmp = x / (x / y)
else if (y <= 1.85d+88) then
tmp = y + (y * ((-0.16666666666666666d0) * (x * x)))
else
tmp = x * (y * (1.0d0 / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 2.5e-48) {
tmp = x / (x / y);
} else if (y <= 1.85e+88) {
tmp = y + (y * (-0.16666666666666666 * (x * x)));
} else {
tmp = x * (y * (1.0 / x));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2.5e-48: tmp = x / (x / y) elif y <= 1.85e+88: tmp = y + (y * (-0.16666666666666666 * (x * x))) else: tmp = x * (y * (1.0 / x)) return tmp
function code(x, y) tmp = 0.0 if (y <= 2.5e-48) tmp = Float64(x / Float64(x / y)); elseif (y <= 1.85e+88) tmp = Float64(y + Float64(y * Float64(-0.16666666666666666 * Float64(x * x)))); else tmp = Float64(x * Float64(y * Float64(1.0 / x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 2.5e-48) tmp = x / (x / y); elseif (y <= 1.85e+88) tmp = y + (y * (-0.16666666666666666 * (x * x))); else tmp = x * (y * (1.0 / x)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2.5e-48], N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.85e+88], N[(y + N[(y * N[(-0.16666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(y * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.5 \cdot 10^{-48}:\\
\;\;\;\;\frac{x}{\frac{x}{y}}\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{+88}:\\
\;\;\;\;y + y \cdot \left(-0.16666666666666666 \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y \cdot \frac{1}{x}\right)\\
\end{array}
\end{array}
if y < 2.4999999999999999e-48Initial program 86.4%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 73.2%
Taylor expanded in y around 0 56.0%
clear-num57.7%
un-div-inv57.2%
Applied egg-rr57.2%
if 2.4999999999999999e-48 < y < 1.84999999999999997e88Initial program 99.8%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in y around 0 40.5%
Taylor expanded in x around 0 36.3%
associate-*r*36.3%
Simplified36.3%
unpow236.3%
Applied egg-rr36.3%
if 1.84999999999999997e88 < y Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 32.8%
clear-num32.8%
associate-/r/32.8%
Applied egg-rr32.8%
Taylor expanded in x around 0 32.6%
Final simplification50.6%
(FPCore (x y) :precision binary64 (/ x (/ x y)))
double code(double x, double y) {
return x / (x / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x / (x / y)
end function
public static double code(double x, double y) {
return x / (x / y);
}
def code(x, y): return x / (x / y)
function code(x, y) return Float64(x / Float64(x / y)) end
function tmp = code(x, y) tmp = x / (x / y); end
code[x_, y_] := N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{\frac{x}{y}}
\end{array}
Initial program 90.3%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 72.3%
Taylor expanded in y around 0 48.8%
clear-num50.0%
un-div-inv48.9%
Applied egg-rr48.9%
(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 90.3%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 72.3%
Taylor expanded in y around 0 48.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 90.3%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 72.3%
Taylor expanded in y around 0 48.8%
Taylor expanded in x around 0 27.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 2024146
(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))