
(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 6 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.6%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= y 25.5) (/ y (/ x (sin x))) (log (exp y))))
double code(double x, double y) {
double tmp;
if (y <= 25.5) {
tmp = y / (x / sin(x));
} else {
tmp = log(exp(y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 25.5d0) then
tmp = y / (x / sin(x))
else
tmp = log(exp(y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 25.5) {
tmp = y / (x / Math.sin(x));
} else {
tmp = Math.log(Math.exp(y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 25.5: tmp = y / (x / math.sin(x)) else: tmp = math.log(math.exp(y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 25.5) tmp = Float64(y / Float64(x / sin(x))); else tmp = log(exp(y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 25.5) tmp = y / (x / sin(x)); else tmp = log(exp(y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 25.5], N[(y / N[(x / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Log[N[Exp[y], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 25.5:\\
\;\;\;\;\frac{y}{\frac{x}{\sin x}}\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{y}\right)\\
\end{array}
\end{array}
if y < 25.5Initial program 86.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 50.8%
associate-/l*64.1%
Simplified64.1%
clear-num64.1%
un-div-inv64.2%
Applied egg-rr64.2%
if 25.5 < y Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 4.3%
Taylor expanded in x around 0 15.1%
*-commutative15.1%
Simplified15.1%
associate-/l*3.9%
*-inverses3.9%
*-commutative3.9%
add-log-exp68.4%
*-un-lft-identity68.4%
Applied egg-rr68.4%
Final simplification65.1%
(FPCore (x y) :precision binary64 (if (<= x 5e-33) (* x (/ y x)) (* y (/ (sin x) x))))
double code(double x, double y) {
double tmp;
if (x <= 5e-33) {
tmp = x * (y / x);
} else {
tmp = y * (sin(x) / x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 5d-33) then
tmp = x * (y / x)
else
tmp = y * (sin(x) / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 5e-33) {
tmp = x * (y / x);
} else {
tmp = y * (Math.sin(x) / x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 5e-33: tmp = x * (y / x) else: tmp = y * (math.sin(x) / x) return tmp
function code(x, y) tmp = 0.0 if (x <= 5e-33) tmp = Float64(x * Float64(y / x)); else tmp = Float64(y * Float64(sin(x) / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 5e-33) tmp = x * (y / x); else tmp = y * (sin(x) / x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 5e-33], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{-33}:\\
\;\;\;\;x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\end{array}
\end{array}
if x < 5.00000000000000028e-33Initial program 86.1%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 35.9%
Taylor expanded in x around 0 23.5%
*-commutative23.5%
Simplified23.5%
*-commutative23.5%
associate-/l*56.1%
Applied egg-rr56.1%
if 5.00000000000000028e-33 < x Initial program 99.5%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 53.5%
associate-/l*53.9%
Simplified53.9%
Final simplification55.5%
(FPCore (x y) :precision binary64 (* (sin x) (/ y x)))
double code(double x, double y) {
return sin(x) * (y / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (y / x)
end function
public static double code(double x, double y) {
return Math.sin(x) * (y / x);
}
def code(x, y): return math.sin(x) * (y / x)
function code(x, y) return Float64(sin(x) * Float64(y / x)) end
function tmp = code(x, y) tmp = sin(x) * (y / x); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{y}{x}
\end{array}
Initial program 89.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 62.8%
Final simplification62.8%
(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.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 40.5%
Taylor expanded in x around 0 22.9%
*-commutative22.9%
Simplified22.9%
*-commutative22.9%
associate-/l*49.3%
Applied egg-rr49.3%
Final simplification49.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.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 40.5%
associate-/l*50.8%
Simplified50.8%
Taylor expanded in x around 0 28.2%
Final simplification28.2%
(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 2024053
(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))