
(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 90.1%
associate-*l/99.9%
Simplified99.9%
Final simplification99.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}
Initial program 90.1%
*-commutative90.1%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= y 1350.0) (* (sin x) (/ y x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (y <= 1350.0) {
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 (y <= 1350.0d0) 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 (y <= 1350.0) {
tmp = Math.sin(x) * (y / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1350.0: tmp = math.sin(x) * (y / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (y <= 1350.0) 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 (y <= 1350.0) tmp = sin(x) * (y / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1350.0], N[(N[Sin[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1350:\\
\;\;\;\;\sin x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if y < 1350Initial program 87.0%
*-commutative87.0%
associate-*l/99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in y around 0 54.5%
associate-/l*67.4%
Simplified67.4%
associate-/r/76.4%
Applied egg-rr76.4%
if 1350 < y Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 62.3%
Final simplification73.0%
(FPCore (x y) :precision binary64 (if (<= y 1350.0) (* (/ (sin x) x) y) (sinh y)))
double code(double x, double y) {
double tmp;
if (y <= 1350.0) {
tmp = (sin(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 (y <= 1350.0d0) then
tmp = (sin(x) / x) * y
else
tmp = sinh(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1350.0) {
tmp = (Math.sin(x) / x) * y;
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1350.0: tmp = (math.sin(x) / x) * y else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (y <= 1350.0) tmp = Float64(Float64(sin(x) / x) * y); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1350.0) tmp = (sin(x) / x) * y; else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1350.0], N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1350:\\
\;\;\;\;\frac{\sin x}{x} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if y < 1350Initial program 87.0%
*-commutative87.0%
associate-*l/99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in y around 0 54.5%
associate-/l*67.4%
Simplified67.4%
clear-num66.8%
associate-/r/67.3%
clear-num67.4%
Applied egg-rr67.4%
if 1350 < y Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 62.3%
Final simplification66.2%
(FPCore (x y) :precision binary64 (if (<= y 1350.0) (/ y (/ x (sin x))) (sinh y)))
double code(double x, double y) {
double tmp;
if (y <= 1350.0) {
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 <= 1350.0d0) 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 <= 1350.0) {
tmp = y / (x / Math.sin(x));
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1350.0: tmp = y / (x / math.sin(x)) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (y <= 1350.0) 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 <= 1350.0) tmp = y / (x / sin(x)); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1350.0], N[(y / N[(x / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1350:\\
\;\;\;\;\frac{y}{\frac{x}{\sin x}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if y < 1350Initial program 87.0%
*-commutative87.0%
associate-*l/99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in y around 0 54.5%
associate-/l*67.4%
Simplified67.4%
if 1350 < y Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 62.3%
Final simplification66.2%
(FPCore (x y) :precision binary64 (if (<= y 4.3e-8) (/ y (+ 1.0 (* x (* x 0.16666666666666666)))) (sinh y)))
double code(double x, double y) {
double tmp;
if (y <= 4.3e-8) {
tmp = y / (1.0 + (x * (x * 0.16666666666666666)));
} 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 <= 4.3d-8) then
tmp = y / (1.0d0 + (x * (x * 0.16666666666666666d0)))
else
tmp = sinh(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 4.3e-8) {
tmp = y / (1.0 + (x * (x * 0.16666666666666666)));
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 4.3e-8: tmp = y / (1.0 + (x * (x * 0.16666666666666666))) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (y <= 4.3e-8) tmp = Float64(y / Float64(1.0 + Float64(x * Float64(x * 0.16666666666666666)))); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 4.3e-8) tmp = y / (1.0 + (x * (x * 0.16666666666666666))); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 4.3e-8], N[(y / N[(1.0 + N[(x * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.3 \cdot 10^{-8}:\\
\;\;\;\;\frac{y}{1 + x \cdot \left(x \cdot 0.16666666666666666\right)}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if y < 4.3000000000000001e-8Initial program 86.9%
*-commutative86.9%
associate-*l/99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in y around 0 54.8%
associate-/l*67.7%
Simplified67.7%
clear-num67.7%
associate-/r/67.6%
Applied egg-rr67.6%
Taylor expanded in x around 0 47.8%
*-commutative47.8%
distribute-lft-in47.8%
*-commutative47.8%
div-inv47.8%
*-inverses47.8%
Applied egg-rr47.8%
if 4.3000000000000001e-8 < y Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 61.3%
Final simplification51.1%
(FPCore (x y) :precision binary64 (let* ((t_0 (* x (* x 0.16666666666666666)))) (if (<= y 1.55e-5) (/ y (+ 1.0 t_0)) (/ y t_0))))
double code(double x, double y) {
double t_0 = x * (x * 0.16666666666666666);
double tmp;
if (y <= 1.55e-5) {
tmp = y / (1.0 + t_0);
} else {
tmp = y / t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x * (x * 0.16666666666666666d0)
if (y <= 1.55d-5) then
tmp = y / (1.0d0 + t_0)
else
tmp = y / t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x * (x * 0.16666666666666666);
double tmp;
if (y <= 1.55e-5) {
tmp = y / (1.0 + t_0);
} else {
tmp = y / t_0;
}
return tmp;
}
def code(x, y): t_0 = x * (x * 0.16666666666666666) tmp = 0 if y <= 1.55e-5: tmp = y / (1.0 + t_0) else: tmp = y / t_0 return tmp
function code(x, y) t_0 = Float64(x * Float64(x * 0.16666666666666666)) tmp = 0.0 if (y <= 1.55e-5) tmp = Float64(y / Float64(1.0 + t_0)); else tmp = Float64(y / t_0); end return tmp end
function tmp_2 = code(x, y) t_0 = x * (x * 0.16666666666666666); tmp = 0.0; if (y <= 1.55e-5) tmp = y / (1.0 + t_0); else tmp = y / t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 1.55e-5], N[(y / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision], N[(y / t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(x \cdot 0.16666666666666666\right)\\
\mathbf{if}\;y \leq 1.55 \cdot 10^{-5}:\\
\;\;\;\;\frac{y}{1 + t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{t\_0}\\
\end{array}
\end{array}
if y < 1.55000000000000007e-5Initial program 86.9%
*-commutative86.9%
associate-*l/99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in y around 0 54.8%
associate-/l*67.7%
Simplified67.7%
clear-num67.7%
associate-/r/67.6%
Applied egg-rr67.6%
Taylor expanded in x around 0 47.8%
*-commutative47.8%
distribute-lft-in47.8%
*-commutative47.8%
div-inv47.8%
*-inverses47.8%
Applied egg-rr47.8%
if 1.55000000000000007e-5 < y Initial program 100.0%
*-commutative100.0%
associate-*l/100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 4.2%
associate-/l*4.2%
Simplified4.2%
clear-num4.2%
associate-/r/4.2%
Applied egg-rr4.2%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around inf 30.7%
*-commutative30.7%
Simplified30.7%
Final simplification43.7%
(FPCore (x y) :precision binary64 (if (<= y 1.55e-5) (* x (/ y x)) (/ y (* x (* x 0.16666666666666666)))))
double code(double x, double y) {
double tmp;
if (y <= 1.55e-5) {
tmp = x * (y / x);
} else {
tmp = y / (x * (x * 0.16666666666666666));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.55d-5) then
tmp = x * (y / x)
else
tmp = y / (x * (x * 0.16666666666666666d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1.55e-5) {
tmp = x * (y / x);
} else {
tmp = y / (x * (x * 0.16666666666666666));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.55e-5: tmp = x * (y / x) else: tmp = y / (x * (x * 0.16666666666666666)) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.55e-5) tmp = Float64(x * Float64(y / x)); else tmp = Float64(y / Float64(x * Float64(x * 0.16666666666666666))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.55e-5) tmp = x * (y / x); else tmp = y / (x * (x * 0.16666666666666666)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.55e-5], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision], N[(y / N[(x * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.55 \cdot 10^{-5}:\\
\;\;\;\;x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{x \cdot \left(x \cdot 0.16666666666666666\right)}\\
\end{array}
\end{array}
if y < 1.55000000000000007e-5Initial program 86.9%
*-commutative86.9%
associate-*l/99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in y around 0 54.8%
Taylor expanded in x around 0 22.9%
associate-*r*22.9%
distribute-rgt-out29.1%
Simplified29.1%
Taylor expanded in x around 0 23.9%
*-commutative23.9%
Simplified23.9%
associate-/l*34.8%
associate-/r/55.4%
Applied egg-rr55.4%
if 1.55000000000000007e-5 < y Initial program 100.0%
*-commutative100.0%
associate-*l/100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 4.2%
associate-/l*4.2%
Simplified4.2%
clear-num4.2%
associate-/r/4.2%
Applied egg-rr4.2%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around inf 30.7%
*-commutative30.7%
Simplified30.7%
Final simplification49.4%
(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 90.1%
*-commutative90.1%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 42.5%
Taylor expanded in x around 0 22.2%
associate-*r*22.2%
distribute-rgt-out30.8%
Simplified30.8%
Taylor expanded in x around 0 20.7%
*-commutative20.7%
Simplified20.7%
associate-/l*27.2%
associate-/r/46.7%
Applied egg-rr46.7%
Final simplification46.7%
(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 90.1%
*-commutative90.1%
associate-*l/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 42.5%
associate-/l*52.3%
Simplified52.3%
Taylor expanded in x around 0 27.2%
Final simplification27.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 2024041
(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))