
(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 10 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) x) (sinh y)))
double code(double x, double y) {
return (sin(x) / x) * sinh(y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (sin(x) / x) * sinh(y)
end function
public static double code(double x, double y) {
return (Math.sin(x) / x) * Math.sinh(y);
}
def code(x, y): return (math.sin(x) / x) * math.sinh(y)
function code(x, y) return Float64(Float64(sin(x) / x) * sinh(y)) end
function tmp = code(x, y) tmp = (sin(x) / x) * sinh(y); end
code[x_, y_] := N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin x}{x} \cdot \sinh y
\end{array}
Initial program 86.2%
associate-*l/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 5e-18) (* (sin x) (/ y x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 5e-18) {
tmp = sin(x) * (y / 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) <= 5d-18) then
tmp = sin(x) * (y / 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) <= 5e-18) {
tmp = Math.sin(x) * (y / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 5e-18: tmp = math.sin(x) * (y / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 5e-18) tmp = Float64(sin(x) * Float64(y / x)); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 5e-18) tmp = sin(x) * (y / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 5e-18], N[(N[Sin[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 5 \cdot 10^{-18}:\\
\;\;\;\;\sin x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 5.00000000000000036e-18Initial program 81.3%
*-commutative81.3%
associate-*l/99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in y around 0 51.2%
associate-/l*69.8%
associate-/r/76.6%
Simplified76.6%
if 5.00000000000000036e-18 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 76.1%
Final simplification76.5%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 5e-18) (/ y (* x (+ (* x 0.16666666666666666) (/ 1.0 x)))) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 5e-18) {
tmp = y / (x * ((x * 0.16666666666666666) + (1.0 / 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) <= 5d-18) then
tmp = y / (x * ((x * 0.16666666666666666d0) + (1.0d0 / 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) <= 5e-18) {
tmp = y / (x * ((x * 0.16666666666666666) + (1.0 / x)));
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 5e-18: tmp = y / (x * ((x * 0.16666666666666666) + (1.0 / x))) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 5e-18) tmp = Float64(y / Float64(x * Float64(Float64(x * 0.16666666666666666) + Float64(1.0 / x)))); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 5e-18) tmp = y / (x * ((x * 0.16666666666666666) + (1.0 / x))); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 5e-18], N[(y / N[(x * N[(N[(x * 0.16666666666666666), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 5 \cdot 10^{-18}:\\
\;\;\;\;\frac{y}{x \cdot \left(x \cdot 0.16666666666666666 + \frac{1}{x}\right)}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 5.00000000000000036e-18Initial program 81.3%
*-commutative81.3%
associate-*l/99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in y around 0 51.2%
associate-/l*69.8%
Simplified69.8%
clear-num69.8%
associate-/r/69.7%
Applied egg-rr69.7%
Taylor expanded in x around 0 55.8%
if 5.00000000000000036e-18 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 76.1%
Final simplification61.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}
Initial program 86.2%
*-commutative86.2%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= y 9200000.0) (/ (sin x) (+ (* -0.16666666666666666 (* x y)) (/ x y))) (sinh y)))
double code(double x, double y) {
double tmp;
if (y <= 9200000.0) {
tmp = sin(x) / ((-0.16666666666666666 * (x * y)) + (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 (y <= 9200000.0d0) then
tmp = sin(x) / (((-0.16666666666666666d0) * (x * y)) + (x / y))
else
tmp = sinh(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 9200000.0) {
tmp = Math.sin(x) / ((-0.16666666666666666 * (x * y)) + (x / y));
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 9200000.0: tmp = math.sin(x) / ((-0.16666666666666666 * (x * y)) + (x / y)) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (y <= 9200000.0) tmp = Float64(sin(x) / Float64(Float64(-0.16666666666666666 * Float64(x * y)) + Float64(x / y))); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 9200000.0) tmp = sin(x) / ((-0.16666666666666666 * (x * y)) + (x / y)); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 9200000.0], N[(N[Sin[x], $MachinePrecision] / N[(N[(-0.16666666666666666 * N[(x * y), $MachinePrecision]), $MachinePrecision] + N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9200000:\\
\;\;\;\;\frac{\sin x}{-0.16666666666666666 \cdot \left(x \cdot y\right) + \frac{x}{y}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if y < 9.2e6Initial program 81.9%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in y around 0 69.1%
if 9.2e6 < y Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 77.0%
Final simplification71.0%
(FPCore (x y) :precision binary64 (if (<= y 1.1e-15) (/ y (/ x (sin x))) (sinh y)))
double code(double x, double y) {
double tmp;
if (y <= 1.1e-15) {
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 (y <= 1.1d-15) 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 (y <= 1.1e-15) {
tmp = y / (x / Math.sin(x));
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.1e-15: tmp = y / (x / math.sin(x)) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.1e-15) 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 (y <= 1.1e-15) tmp = y / (x / sin(x)); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.1e-15], N[(y / N[(x / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.1 \cdot 10^{-15}:\\
\;\;\;\;\frac{y}{\frac{x}{\sin x}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if y < 1.09999999999999993e-15Initial program 81.3%
*-commutative81.3%
associate-*l/99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in y around 0 51.2%
associate-/l*69.8%
Simplified69.8%
if 1.09999999999999993e-15 < y Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 76.1%
Final simplification71.5%
(FPCore (x y) :precision binary64 (if (<= y 1e+27) y (/ 1.0 (/ x (* x y)))))
double code(double x, double y) {
double tmp;
if (y <= 1e+27) {
tmp = y;
} else {
tmp = 1.0 / (x / (x * y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1d+27) then
tmp = y
else
tmp = 1.0d0 / (x / (x * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1e+27) {
tmp = y;
} else {
tmp = 1.0 / (x / (x * y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1e+27: tmp = y else: tmp = 1.0 / (x / (x * y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 1e+27) tmp = y; else tmp = Float64(1.0 / Float64(x / Float64(x * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1e+27) tmp = y; else tmp = 1.0 / (x / (x * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1e+27], y, N[(1.0 / N[(x / N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 10^{+27}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{x}{x \cdot y}}\\
\end{array}
\end{array}
if y < 1e27Initial program 82.4%
*-commutative82.4%
associate-*l/99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in y around 0 50.3%
associate-/l*67.8%
Simplified67.8%
Taylor expanded in x around 0 39.6%
if 1e27 < y Initial program 100.0%
*-commutative100.0%
associate-*l/100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 4.3%
associate-/l*4.3%
Simplified4.3%
clear-num4.3%
inv-pow4.3%
associate-/l/4.3%
Applied egg-rr4.3%
unpow-14.3%
Simplified4.3%
Taylor expanded in x around 0 19.6%
*-commutative19.6%
Simplified19.6%
Final simplification35.3%
(FPCore (x y) :precision binary64 (/ (/ y x) (+ (* x 0.16666666666666666) (/ 1.0 x))))
double code(double x, double y) {
return (y / x) / ((x * 0.16666666666666666) + (1.0 / x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (y / x) / ((x * 0.16666666666666666d0) + (1.0d0 / x))
end function
public static double code(double x, double y) {
return (y / x) / ((x * 0.16666666666666666) + (1.0 / x));
}
def code(x, y): return (y / x) / ((x * 0.16666666666666666) + (1.0 / x))
function code(x, y) return Float64(Float64(y / x) / Float64(Float64(x * 0.16666666666666666) + Float64(1.0 / x))) end
function tmp = code(x, y) tmp = (y / x) / ((x * 0.16666666666666666) + (1.0 / x)); end
code[x_, y_] := N[(N[(y / x), $MachinePrecision] / N[(N[(x * 0.16666666666666666), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{y}{x}}{x \cdot 0.16666666666666666 + \frac{1}{x}}
\end{array}
Initial program 86.2%
*-commutative86.2%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 40.4%
associate-/l*54.1%
associate-/r/65.0%
Simplified65.0%
associate-*l/40.4%
/-rgt-identity40.4%
associate-/r/40.3%
associate-/l/54.0%
associate-/r*64.9%
Applied egg-rr64.9%
Taylor expanded in x around 0 54.4%
Final simplification54.4%
(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 86.2%
*-commutative86.2%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 40.4%
associate-/l*54.1%
associate-/r/65.0%
Simplified65.0%
associate-*l/40.4%
/-rgt-identity40.4%
associate-/r/40.3%
associate-/l/54.0%
associate-/r*64.9%
Applied egg-rr64.9%
Taylor expanded in x around 0 53.9%
Final simplification53.9%
(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 86.2%
*-commutative86.2%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 40.4%
associate-/l*54.1%
Simplified54.1%
Taylor expanded in x around 0 32.0%
Final simplification32.0%
(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 2024019
(FPCore (x y)
:name "Linear.Quaternion:$ccosh from linear-1.19.1.3"
:precision binary64
:herbie-target
(* (sin x) (/ (sinh y) x))
(/ (* (sin x) (sinh y)) x))