
(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 8 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.6%
associate-/l*99.9%
Simplified99.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 2e-16) (/ x (/ x y)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 2e-16) {
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-16) 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-16) {
tmp = x / (x / y);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 2e-16: tmp = x / (x / y) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 2e-16) 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-16) tmp = x / (x / y); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 2e-16], 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^{-16}:\\
\;\;\;\;\frac{x}{\frac{x}{y}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 2e-16Initial program 86.3%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 45.6%
associate-/l*59.2%
Simplified59.2%
Taylor expanded in y around 0 45.6%
associate-*l/69.7%
*-commutative69.7%
Simplified69.7%
Taylor expanded in x around 0 57.4%
clear-num58.1%
div-inv57.7%
Applied egg-rr57.7%
if 2e-16 < (sinh.f64 y) Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 76.0%
clear-num76.0%
un-div-inv76.0%
Applied egg-rr76.0%
associate-/r/76.0%
*-inverses76.0%
*-lft-identity76.0%
Simplified76.0%
(FPCore (x y)
:precision binary64
(if (<= y 0.0045)
(* y (/ (sin x) x))
(if (<= y 3.4e+264)
(* x (/ (sinh y) x))
(/ 1.0 (/ (/ x y) (+ x (* -0.16666666666666666 (pow x 3.0))))))))
double code(double x, double y) {
double tmp;
if (y <= 0.0045) {
tmp = y * (sin(x) / x);
} else if (y <= 3.4e+264) {
tmp = x * (sinh(y) / x);
} else {
tmp = 1.0 / ((x / y) / (x + (-0.16666666666666666 * pow(x, 3.0))));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 0.0045d0) then
tmp = y * (sin(x) / x)
else if (y <= 3.4d+264) then
tmp = x * (sinh(y) / x)
else
tmp = 1.0d0 / ((x / y) / (x + ((-0.16666666666666666d0) * (x ** 3.0d0))))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 0.0045) {
tmp = y * (Math.sin(x) / x);
} else if (y <= 3.4e+264) {
tmp = x * (Math.sinh(y) / x);
} else {
tmp = 1.0 / ((x / y) / (x + (-0.16666666666666666 * Math.pow(x, 3.0))));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 0.0045: tmp = y * (math.sin(x) / x) elif y <= 3.4e+264: tmp = x * (math.sinh(y) / x) else: tmp = 1.0 / ((x / y) / (x + (-0.16666666666666666 * math.pow(x, 3.0)))) return tmp
function code(x, y) tmp = 0.0 if (y <= 0.0045) tmp = Float64(y * Float64(sin(x) / x)); elseif (y <= 3.4e+264) tmp = Float64(x * Float64(sinh(y) / x)); else tmp = Float64(1.0 / Float64(Float64(x / y) / Float64(x + Float64(-0.16666666666666666 * (x ^ 3.0))))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 0.0045) tmp = y * (sin(x) / x); elseif (y <= 3.4e+264) tmp = x * (sinh(y) / x); else tmp = 1.0 / ((x / y) / (x + (-0.16666666666666666 * (x ^ 3.0)))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 0.0045], N[(y * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.4e+264], N[(x * N[(N[Sinh[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(x / y), $MachinePrecision] / N[(x + N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.0045:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{+264}:\\
\;\;\;\;x \cdot \frac{\sinh y}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\frac{x}{y}}{x + -0.16666666666666666 \cdot {x}^{3}}}\\
\end{array}
\end{array}
if y < 0.00449999999999999966Initial program 86.4%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 45.9%
associate-/l*59.4%
Simplified59.4%
if 0.00449999999999999966 < y < 3.4000000000000001e264Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 76.3%
if 3.4000000000000001e264 < y Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 7.8%
associate-/l*7.8%
Simplified7.8%
associate-*r/7.8%
clear-num7.8%
associate-/r*64.8%
Applied egg-rr64.8%
Taylor expanded in x around 0 84.2%
distribute-rgt-in84.2%
*-lft-identity84.2%
associate-*l*84.2%
unpow284.2%
unpow384.2%
Simplified84.2%
(FPCore (x y) :precision binary64 (if (<= y 0.0014) (* y (/ (sin x) x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (y <= 0.0014) {
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 (y <= 0.0014d0) 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 (y <= 0.0014) {
tmp = y * (Math.sin(x) / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 0.0014: tmp = y * (math.sin(x) / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (y <= 0.0014) 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 (y <= 0.0014) tmp = y * (sin(x) / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 0.0014], N[(y * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.0014:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if y < 0.00139999999999999999Initial program 86.4%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 45.9%
associate-/l*59.4%
Simplified59.4%
if 0.00139999999999999999 < y Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 76.9%
clear-num76.9%
un-div-inv76.9%
Applied egg-rr76.9%
associate-/r/76.9%
*-inverses76.9%
*-lft-identity76.9%
Simplified76.9%
(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.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 76.4%
(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.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 33.4%
associate-/l*42.8%
Simplified42.8%
Taylor expanded in y around 0 33.4%
associate-*l/60.2%
*-commutative60.2%
Simplified60.2%
Taylor expanded in x around 0 51.3%
clear-num51.8%
div-inv51.5%
Applied egg-rr51.5%
(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.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 33.4%
associate-/l*42.8%
Simplified42.8%
Taylor expanded in y around 0 33.4%
associate-*l/60.2%
*-commutative60.2%
Simplified60.2%
Taylor expanded in x around 0 51.3%
(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.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 76.4%
Taylor expanded in y around 0 23.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 2024091
(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))