
(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 88.4%
associate-/l*99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x y) :precision binary64 (if (<= y 780.0) (* y (/ (sin x) x)) (log (exp y))))
double code(double x, double y) {
double tmp;
if (y <= 780.0) {
tmp = y * (sin(x) / 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 <= 780.0d0) then
tmp = y * (sin(x) / x)
else
tmp = log(exp(y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 780.0) {
tmp = y * (Math.sin(x) / x);
} else {
tmp = Math.log(Math.exp(y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 780.0: tmp = y * (math.sin(x) / x) else: tmp = math.log(math.exp(y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 780.0) tmp = Float64(y * Float64(sin(x) / x)); else tmp = log(exp(y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 780.0) tmp = y * (sin(x) / x); else tmp = log(exp(y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 780.0], N[(y * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[Log[N[Exp[y], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 780:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{y}\right)\\
\end{array}
\end{array}
if y < 780Initial program 84.6%
associate-/l*99.4%
Simplified99.4%
Taylor expanded in y around 0 49.5%
associate-/l*64.4%
Simplified64.4%
if 780 < y Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 4.2%
associate-/l*4.2%
Simplified4.2%
associate-*r/4.2%
*-commutative4.2%
clear-num4.2%
*-commutative4.2%
associate-/r*23.5%
Applied egg-rr23.5%
Taylor expanded in x around 0 3.9%
remove-double-div3.9%
add-log-exp81.0%
Applied egg-rr81.0%
Final simplification68.5%
(FPCore (x y) :precision binary64 (if (<= x 1.08e-36) (/ (/ y x) (/ 1.0 x)) (* y (/ (sin x) x))))
double code(double x, double y) {
double tmp;
if (x <= 1.08e-36) {
tmp = (y / x) / (1.0 / 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 <= 1.08d-36) then
tmp = (y / x) / (1.0d0 / 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 <= 1.08e-36) {
tmp = (y / x) / (1.0 / x);
} else {
tmp = y * (Math.sin(x) / x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1.08e-36: tmp = (y / x) / (1.0 / x) else: tmp = y * (math.sin(x) / x) return tmp
function code(x, y) tmp = 0.0 if (x <= 1.08e-36) tmp = Float64(Float64(y / x) / Float64(1.0 / x)); else tmp = Float64(y * Float64(sin(x) / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1.08e-36) tmp = (y / x) / (1.0 / x); else tmp = y * (sin(x) / x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1.08e-36], N[(N[(y / x), $MachinePrecision] / N[(1.0 / x), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.08 \cdot 10^{-36}:\\
\;\;\;\;\frac{\frac{y}{x}}{\frac{1}{x}}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\end{array}
\end{array}
if x < 1.08000000000000006e-36Initial program 84.8%
associate-/l*99.9%
Simplified99.9%
clear-num99.5%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 62.4%
*-commutative62.4%
associate-*l/62.6%
*-un-lft-identity62.6%
associate-/r/47.8%
div-inv47.7%
associate-/r*62.4%
Applied egg-rr62.4%
Taylor expanded in x around 0 54.3%
if 1.08000000000000006e-36 < x Initial program 98.5%
associate-/l*98.6%
Simplified98.6%
Taylor expanded in y around 0 54.6%
associate-/l*54.6%
Simplified54.6%
Final simplification54.4%
(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 88.4%
associate-/l*99.6%
Simplified99.6%
Taylor expanded in y around 0 60.5%
Final simplification60.5%
(FPCore (x y) :precision binary64 (if (<= y 200.0) y (/ (* x y) x)))
double code(double x, double y) {
double tmp;
if (y <= 200.0) {
tmp = y;
} 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 <= 200.0d0) then
tmp = y
else
tmp = (x * y) / x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 200.0) {
tmp = y;
} else {
tmp = (x * y) / x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 200.0: tmp = y else: tmp = (x * y) / x return tmp
function code(x, y) tmp = 0.0 if (y <= 200.0) tmp = y; else tmp = Float64(Float64(x * y) / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 200.0) tmp = y; else tmp = (x * y) / x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 200.0], y, N[(N[(x * y), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 200:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{x}\\
\end{array}
\end{array}
if y < 200Initial program 84.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 49.7%
associate-/l*64.7%
Simplified64.7%
Taylor expanded in x around 0 33.0%
if 200 < y Initial program 98.6%
Taylor expanded in y around 0 4.2%
Taylor expanded in x around 0 11.3%
*-commutative11.3%
Simplified11.3%
Final simplification27.6%
(FPCore (x y) :precision binary64 (/ (/ y x) (/ 1.0 x)))
double code(double x, double y) {
return (y / x) / (1.0 / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (y / x) / (1.0d0 / x)
end function
public static double code(double x, double y) {
return (y / x) / (1.0 / x);
}
def code(x, y): return (y / x) / (1.0 / x)
function code(x, y) return Float64(Float64(y / x) / Float64(1.0 / x)) end
function tmp = code(x, y) tmp = (y / x) / (1.0 / x); end
code[x_, y_] := N[(N[(y / x), $MachinePrecision] / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{y}{x}}{\frac{1}{x}}
\end{array}
Initial program 88.4%
associate-/l*99.6%
Simplified99.6%
clear-num98.9%
associate-/r/99.4%
Applied egg-rr99.4%
Taylor expanded in y around 0 60.4%
*-commutative60.4%
associate-*l/60.5%
*-un-lft-identity60.5%
associate-/r/49.6%
div-inv49.5%
associate-/r*60.4%
Applied egg-rr60.4%
Taylor expanded in x around 0 48.3%
Final simplification48.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 88.4%
associate-/l*99.6%
Simplified99.6%
Taylor expanded in y around 0 38.4%
associate-/l*49.6%
Simplified49.6%
Taylor expanded in x around 0 25.7%
Final simplification25.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 2024082
(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))