
(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.9%
associate-/l*99.9%
Simplified99.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 1e-6) (/ y (/ x (sin x))) (/ 1.0 (/ 1.0 (sinh y)))))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 1e-6) {
tmp = y / (x / sin(x));
} else {
tmp = 1.0 / (1.0 / 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) <= 1d-6) then
tmp = y / (x / sin(x))
else
tmp = 1.0d0 / (1.0d0 / sinh(y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.sinh(y) <= 1e-6) {
tmp = y / (x / Math.sin(x));
} else {
tmp = 1.0 / (1.0 / Math.sinh(y));
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 1e-6: tmp = y / (x / math.sin(x)) else: tmp = 1.0 / (1.0 / math.sinh(y)) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 1e-6) tmp = Float64(y / Float64(x / sin(x))); else tmp = Float64(1.0 / Float64(1.0 / sinh(y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 1e-6) tmp = y / (x / sin(x)); else tmp = 1.0 / (1.0 / sinh(y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 1e-6], N[(y / N[(x / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 / N[Sinh[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 10^{-6}:\\
\;\;\;\;\frac{y}{\frac{x}{\sin x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{\sinh y}}\\
\end{array}
\end{array}
if (sinh.f64 y) < 9.99999999999999955e-7Initial program 86.0%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 52.8%
associate-/l*66.7%
Simplified66.7%
clear-num66.7%
un-div-inv66.7%
Applied egg-rr66.7%
if 9.99999999999999955e-7 < (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 75.5%
metadata-eval75.5%
associate-*l/75.5%
associate-/r/75.5%
rec-exp75.5%
sinh-def75.5%
Simplified75.5%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 1e-6) (* y (/ (sin x) x)) (/ 1.0 (/ 1.0 (sinh y)))))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 1e-6) {
tmp = y * (sin(x) / x);
} else {
tmp = 1.0 / (1.0 / 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) <= 1d-6) then
tmp = y * (sin(x) / x)
else
tmp = 1.0d0 / (1.0d0 / sinh(y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.sinh(y) <= 1e-6) {
tmp = y * (Math.sin(x) / x);
} else {
tmp = 1.0 / (1.0 / Math.sinh(y));
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 1e-6: tmp = y * (math.sin(x) / x) else: tmp = 1.0 / (1.0 / math.sinh(y)) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 1e-6) tmp = Float64(y * Float64(sin(x) / x)); else tmp = Float64(1.0 / Float64(1.0 / sinh(y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 1e-6) tmp = y * (sin(x) / x); else tmp = 1.0 / (1.0 / sinh(y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 1e-6], N[(y * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 / N[Sinh[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 10^{-6}:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{\sinh y}}\\
\end{array}
\end{array}
if (sinh.f64 y) < 9.99999999999999955e-7Initial program 86.0%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 52.8%
associate-/l*66.7%
Simplified66.7%
if 9.99999999999999955e-7 < (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 75.5%
metadata-eval75.5%
associate-*l/75.5%
associate-/r/75.5%
rec-exp75.5%
sinh-def75.5%
Simplified75.5%
(FPCore (x y) :precision binary64 (if (<= x 7.8e-5) (* x (/ y x)) (* y (/ (sin x) x))))
double code(double x, double y) {
double tmp;
if (x <= 7.8e-5) {
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 <= 7.8d-5) 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 <= 7.8e-5) {
tmp = x * (y / x);
} else {
tmp = y * (Math.sin(x) / x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 7.8e-5: tmp = x * (y / x) else: tmp = y * (math.sin(x) / x) return tmp
function code(x, y) tmp = 0.0 if (x <= 7.8e-5) 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 <= 7.8e-5) tmp = x * (y / x); else tmp = y * (sin(x) / x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 7.8e-5], 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 7.8 \cdot 10^{-5}:\\
\;\;\;\;x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\end{array}
\end{array}
if x < 7.7999999999999999e-5Initial program 85.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 37.2%
associate-/l*51.6%
Simplified51.6%
associate-*r/37.2%
*-commutative37.2%
clear-num36.9%
Applied egg-rr36.9%
Taylor expanded in x around 0 24.6%
*-commutative24.6%
Simplified24.6%
associate-/r*62.6%
associate-/r/64.9%
clear-num64.3%
Applied egg-rr64.3%
if 7.7999999999999999e-5 < x Initial program 99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 61.0%
associate-/l*60.9%
Simplified60.9%
Final simplification63.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 88.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 68.0%
(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 88.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 42.8%
associate-/l*53.8%
Simplified53.8%
associate-*r/42.8%
*-commutative42.8%
clear-num41.9%
Applied egg-rr41.9%
Taylor expanded in x around 0 20.9%
*-commutative20.9%
Simplified20.9%
associate-/r*54.1%
associate-/r/55.8%
clear-num54.6%
Applied egg-rr54.6%
Final simplification54.6%
(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.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 42.8%
associate-/l*53.8%
Simplified53.8%
Taylor expanded in x around 0 28.9%
(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 2024088
(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))