
(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 89.5%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 4e-13) (/ y (/ x (sin x))) (/ 1.0 (/ x (* x (sinh y))))))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 4e-13) {
tmp = y / (x / sin(x));
} else {
tmp = 1.0 / (x / (x * 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-13) then
tmp = y / (x / sin(x))
else
tmp = 1.0d0 / (x / (x * sinh(y)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.sinh(y) <= 4e-13) {
tmp = y / (x / Math.sin(x));
} else {
tmp = 1.0 / (x / (x * Math.sinh(y)));
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 4e-13: tmp = y / (x / math.sin(x)) else: tmp = 1.0 / (x / (x * math.sinh(y))) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 4e-13) tmp = Float64(y / Float64(x / sin(x))); else tmp = Float64(1.0 / Float64(x / Float64(x * sinh(y)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 4e-13) tmp = y / (x / sin(x)); else tmp = 1.0 / (x / (x * sinh(y))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 4e-13], N[(y / N[(x / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(x / N[(x * N[Sinh[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 4 \cdot 10^{-13}:\\
\;\;\;\;\frac{y}{\frac{x}{\sin x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{x}{x \cdot \sinh y}}\\
\end{array}
\end{array}
if (sinh.f64 y) < 4.0000000000000001e-13Initial program 86.0%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 50.7%
associate-/l*64.6%
Simplified64.6%
clear-num64.5%
un-div-inv64.6%
Applied egg-rr64.6%
if 4.0000000000000001e-13 < (sinh.f64 y) Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 79.7%
associate-*r/79.7%
clear-num79.7%
Applied egg-rr79.7%
Final simplification68.4%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 4e-13) (* y (/ (sin x) x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 4e-13) {
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) <= 4d-13) 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) <= 4e-13) {
tmp = y * (Math.sin(x) / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 4e-13: tmp = y * (math.sin(x) / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 4e-13) 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) <= 4e-13) tmp = y * (sin(x) / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 4e-13], 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 4 \cdot 10^{-13}:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 4.0000000000000001e-13Initial program 86.0%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 50.7%
associate-/l*64.6%
Simplified64.6%
if 4.0000000000000001e-13 < (sinh.f64 y) Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 79.7%
associate-*r/79.7%
clear-num79.7%
Applied egg-rr79.7%
clear-num79.7%
*-commutative79.7%
associate-/l*79.7%
*-inverses79.7%
*-commutative79.7%
*-un-lft-identity79.7%
sinh-def79.7%
div-sub79.7%
Applied egg-rr79.7%
div-sub79.7%
sinh-def79.7%
Simplified79.7%
Final simplification68.3%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 4e-13) (/ y (/ x (sin x))) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 4e-13) {
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) <= 4d-13) 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) <= 4e-13) {
tmp = y / (x / Math.sin(x));
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 4e-13: tmp = y / (x / math.sin(x)) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 4e-13) 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) <= 4e-13) tmp = y / (x / sin(x)); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 4e-13], 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 4 \cdot 10^{-13}:\\
\;\;\;\;\frac{y}{\frac{x}{\sin x}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 4.0000000000000001e-13Initial program 86.0%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 50.7%
associate-/l*64.6%
Simplified64.6%
clear-num64.5%
un-div-inv64.6%
Applied egg-rr64.6%
if 4.0000000000000001e-13 < (sinh.f64 y) Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 79.7%
associate-*r/79.7%
clear-num79.7%
Applied egg-rr79.7%
clear-num79.7%
*-commutative79.7%
associate-/l*79.7%
*-inverses79.7%
*-commutative79.7%
*-un-lft-identity79.7%
sinh-def79.7%
div-sub79.7%
Applied egg-rr79.7%
div-sub79.7%
sinh-def79.7%
Simplified79.7%
Final simplification68.4%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 5e-66) (/ 1.0 (* (/ 1.0 x) (/ x y))) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 5e-66) {
tmp = 1.0 / ((1.0 / 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) <= 5d-66) then
tmp = 1.0d0 / ((1.0d0 / 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) <= 5e-66) {
tmp = 1.0 / ((1.0 / x) * (x / y));
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 5e-66: tmp = 1.0 / ((1.0 / x) * (x / y)) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 5e-66) tmp = Float64(1.0 / Float64(Float64(1.0 / x) * Float64(x / y))); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 5e-66) tmp = 1.0 / ((1.0 / x) * (x / y)); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 5e-66], N[(1.0 / N[(N[(1.0 / x), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 5 \cdot 10^{-66}:\\
\;\;\;\;\frac{1}{\frac{1}{x} \cdot \frac{x}{y}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 4.99999999999999962e-66Initial program 85.4%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 80.5%
associate-*r/52.4%
clear-num52.4%
Applied egg-rr52.4%
Taylor expanded in y around 0 29.8%
*-un-lft-identity29.8%
times-frac60.1%
Applied egg-rr60.1%
if 4.99999999999999962e-66 < (sinh.f64 y) Initial program 99.3%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 77.8%
associate-*r/77.2%
clear-num77.2%
Applied egg-rr77.2%
clear-num77.2%
*-commutative77.2%
associate-/l*77.8%
*-inverses77.8%
*-commutative77.8%
*-un-lft-identity77.8%
sinh-def67.7%
div-sub67.7%
Applied egg-rr67.7%
div-sub67.7%
sinh-def77.8%
Simplified77.8%
Final simplification65.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 89.5%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 79.7%
Final simplification79.7%
(FPCore (x y) :precision binary64 (if (or (<= y 4e+96) (not (<= y 1.85e+194))) (* x (/ y x)) (/ (* x y) x)))
double code(double x, double y) {
double tmp;
if ((y <= 4e+96) || !(y <= 1.85e+194)) {
tmp = x * (y / x);
} 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 <= 4d+96) .or. (.not. (y <= 1.85d+194))) then
tmp = x * (y / x)
else
tmp = (x * y) / x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= 4e+96) || !(y <= 1.85e+194)) {
tmp = x * (y / x);
} else {
tmp = (x * y) / x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= 4e+96) or not (y <= 1.85e+194): tmp = x * (y / x) else: tmp = (x * y) / x return tmp
function code(x, y) tmp = 0.0 if ((y <= 4e+96) || !(y <= 1.85e+194)) tmp = Float64(x * Float64(y / x)); else tmp = Float64(Float64(x * y) / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= 4e+96) || ~((y <= 1.85e+194))) tmp = x * (y / x); else tmp = (x * y) / x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, 4e+96], N[Not[LessEqual[y, 1.85e+194]], $MachinePrecision]], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4 \cdot 10^{+96} \lor \neg \left(y \leq 1.85 \cdot 10^{+194}\right):\\
\;\;\;\;x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{x}\\
\end{array}
\end{array}
if y < 4.0000000000000002e96 or 1.8500000000000001e194 < y Initial program 88.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 80.0%
Taylor expanded in y around 0 56.3%
if 4.0000000000000002e96 < y < 1.8500000000000001e194Initial program 100.0%
Taylor expanded in y around 0 3.5%
Taylor expanded in x around 0 30.7%
*-commutative30.7%
Simplified30.7%
Final simplification54.2%
(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 89.5%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 79.7%
Taylor expanded in y around 0 52.3%
Final simplification52.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 89.5%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 79.7%
associate-*r/59.8%
clear-num59.8%
Applied egg-rr59.8%
Taylor expanded in y around 0 31.1%
Final simplification31.1%
(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 2024081
(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))